app.js 1.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767
  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/views/App.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/views/App.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. //
  1598. //
  1599. //
  1600. //
  1601. //
  1602. //
  1603. //
  1604. //
  1605. //
  1606. //
  1607. //
  1608. //
  1609. //
  1610. //
  1611. //
  1612. //
  1613. //
  1614. //
  1615. //
  1616. //
  1617. //
  1618. //
  1619. //
  1620. //
  1621. //
  1622. //
  1623. //
  1624. //
  1625. //
  1626. //
  1627. //
  1628. //
  1629. //
  1630. //
  1631. //
  1632. //
  1633. //
  1634. //
  1635. //
  1636. //
  1637. //
  1638. //
  1639. //
  1640. //
  1641. //
  1642. //
  1643. //
  1644. //
  1645. //
  1646. //
  1647. //
  1648. //
  1649. /* harmony default export */ __webpack_exports__["default"] = ({});
  1650. /***/ }),
  1651. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=script&lang=js&":
  1652. /*!*************************************************************************************************************************************************************!*\
  1653. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/Welcome.vue?vue&type=script&lang=js& ***!
  1654. \*************************************************************************************************************************************************************/
  1655. /*! exports provided: default */
  1656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1657. "use strict";
  1658. __webpack_require__.r(__webpack_exports__);
  1659. //
  1660. //
  1661. //
  1662. //
  1663. //
  1664. //
  1665. //
  1666. //
  1667. //
  1668. //
  1669. //
  1670. //
  1671. //
  1672. //
  1673. //
  1674. //
  1675. //
  1676. //
  1677. //
  1678. //
  1679. //
  1680. //
  1681. //
  1682. //
  1683. //
  1684. //
  1685. //
  1686. //
  1687. //
  1688. //
  1689. //
  1690. //
  1691. //
  1692. //
  1693. //
  1694. //
  1695. //
  1696. //
  1697. //
  1698. //
  1699. //
  1700. //
  1701. //
  1702. //
  1703. //
  1704. //
  1705. //
  1706. //
  1707. //
  1708. //
  1709. //
  1710. /* harmony default export */ __webpack_exports__["default"] = ({});
  1711. /***/ }),
  1712. /***/ "./node_modules/base64-js/index.js":
  1713. /*!*****************************************!*\
  1714. !*** ./node_modules/base64-js/index.js ***!
  1715. \*****************************************/
  1716. /*! no static exports found */
  1717. /***/ (function(module, exports, __webpack_require__) {
  1718. "use strict";
  1719. exports.byteLength = byteLength
  1720. exports.toByteArray = toByteArray
  1721. exports.fromByteArray = fromByteArray
  1722. var lookup = []
  1723. var revLookup = []
  1724. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1725. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1726. for (var i = 0, len = code.length; i < len; ++i) {
  1727. lookup[i] = code[i]
  1728. revLookup[code.charCodeAt(i)] = i
  1729. }
  1730. // Support decoding URL-safe base64 strings, as Node.js does.
  1731. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1732. revLookup['-'.charCodeAt(0)] = 62
  1733. revLookup['_'.charCodeAt(0)] = 63
  1734. function getLens (b64) {
  1735. var len = b64.length
  1736. if (len % 4 > 0) {
  1737. throw new Error('Invalid string. Length must be a multiple of 4')
  1738. }
  1739. // Trim off extra bytes after placeholder bytes are found
  1740. // See: https://github.com/beatgammit/base64-js/issues/42
  1741. var validLen = b64.indexOf('=')
  1742. if (validLen === -1) validLen = len
  1743. var placeHoldersLen = validLen === len
  1744. ? 0
  1745. : 4 - (validLen % 4)
  1746. return [validLen, placeHoldersLen]
  1747. }
  1748. // base64 is 4/3 + up to two characters of the original data
  1749. function byteLength (b64) {
  1750. var lens = getLens(b64)
  1751. var validLen = lens[0]
  1752. var placeHoldersLen = lens[1]
  1753. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1754. }
  1755. function _byteLength (b64, validLen, placeHoldersLen) {
  1756. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1757. }
  1758. function toByteArray (b64) {
  1759. var tmp
  1760. var lens = getLens(b64)
  1761. var validLen = lens[0]
  1762. var placeHoldersLen = lens[1]
  1763. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1764. var curByte = 0
  1765. // if there are placeholders, only get up to the last complete 4 chars
  1766. var len = placeHoldersLen > 0
  1767. ? validLen - 4
  1768. : validLen
  1769. var i
  1770. for (i = 0; i < len; i += 4) {
  1771. tmp =
  1772. (revLookup[b64.charCodeAt(i)] << 18) |
  1773. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1774. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1775. revLookup[b64.charCodeAt(i + 3)]
  1776. arr[curByte++] = (tmp >> 16) & 0xFF
  1777. arr[curByte++] = (tmp >> 8) & 0xFF
  1778. arr[curByte++] = tmp & 0xFF
  1779. }
  1780. if (placeHoldersLen === 2) {
  1781. tmp =
  1782. (revLookup[b64.charCodeAt(i)] << 2) |
  1783. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1784. arr[curByte++] = tmp & 0xFF
  1785. }
  1786. if (placeHoldersLen === 1) {
  1787. tmp =
  1788. (revLookup[b64.charCodeAt(i)] << 10) |
  1789. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1790. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1791. arr[curByte++] = (tmp >> 8) & 0xFF
  1792. arr[curByte++] = tmp & 0xFF
  1793. }
  1794. return arr
  1795. }
  1796. function tripletToBase64 (num) {
  1797. return lookup[num >> 18 & 0x3F] +
  1798. lookup[num >> 12 & 0x3F] +
  1799. lookup[num >> 6 & 0x3F] +
  1800. lookup[num & 0x3F]
  1801. }
  1802. function encodeChunk (uint8, start, end) {
  1803. var tmp
  1804. var output = []
  1805. for (var i = start; i < end; i += 3) {
  1806. tmp =
  1807. ((uint8[i] << 16) & 0xFF0000) +
  1808. ((uint8[i + 1] << 8) & 0xFF00) +
  1809. (uint8[i + 2] & 0xFF)
  1810. output.push(tripletToBase64(tmp))
  1811. }
  1812. return output.join('')
  1813. }
  1814. function fromByteArray (uint8) {
  1815. var tmp
  1816. var len = uint8.length
  1817. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1818. var parts = []
  1819. var maxChunkLength = 16383 // must be multiple of 3
  1820. // go through the array every three bytes, we'll deal with trailing stuff later
  1821. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1822. parts.push(encodeChunk(
  1823. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1824. ))
  1825. }
  1826. // pad the end with zeros, but make sure to not forget the extra bytes
  1827. if (extraBytes === 1) {
  1828. tmp = uint8[len - 1]
  1829. parts.push(
  1830. lookup[tmp >> 2] +
  1831. lookup[(tmp << 4) & 0x3F] +
  1832. '=='
  1833. )
  1834. } else if (extraBytes === 2) {
  1835. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1836. parts.push(
  1837. lookup[tmp >> 10] +
  1838. lookup[(tmp >> 4) & 0x3F] +
  1839. lookup[(tmp << 2) & 0x3F] +
  1840. '='
  1841. )
  1842. }
  1843. return parts.join('')
  1844. }
  1845. /***/ }),
  1846. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1847. /*!*****************************************************!*\
  1848. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1849. \*****************************************************/
  1850. /*! no static exports found */
  1851. /***/ (function(module, exports, __webpack_require__) {
  1852. /*!
  1853. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1854. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1855. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1856. */
  1857. (function (global, factory) {
  1858. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1859. undefined;
  1860. }(this, (function (exports, $, Popper) { 'use strict';
  1861. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1862. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1863. function _defineProperties(target, props) {
  1864. for (var i = 0; i < props.length; i++) {
  1865. var descriptor = props[i];
  1866. descriptor.enumerable = descriptor.enumerable || false;
  1867. descriptor.configurable = true;
  1868. if ("value" in descriptor) descriptor.writable = true;
  1869. Object.defineProperty(target, descriptor.key, descriptor);
  1870. }
  1871. }
  1872. function _createClass(Constructor, protoProps, staticProps) {
  1873. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1874. if (staticProps) _defineProperties(Constructor, staticProps);
  1875. return Constructor;
  1876. }
  1877. function _defineProperty(obj, key, value) {
  1878. if (key in obj) {
  1879. Object.defineProperty(obj, key, {
  1880. value: value,
  1881. enumerable: true,
  1882. configurable: true,
  1883. writable: true
  1884. });
  1885. } else {
  1886. obj[key] = value;
  1887. }
  1888. return obj;
  1889. }
  1890. function ownKeys(object, enumerableOnly) {
  1891. var keys = Object.keys(object);
  1892. if (Object.getOwnPropertySymbols) {
  1893. var symbols = Object.getOwnPropertySymbols(object);
  1894. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1895. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1896. });
  1897. keys.push.apply(keys, symbols);
  1898. }
  1899. return keys;
  1900. }
  1901. function _objectSpread2(target) {
  1902. for (var i = 1; i < arguments.length; i++) {
  1903. var source = arguments[i] != null ? arguments[i] : {};
  1904. if (i % 2) {
  1905. ownKeys(Object(source), true).forEach(function (key) {
  1906. _defineProperty(target, key, source[key]);
  1907. });
  1908. } else if (Object.getOwnPropertyDescriptors) {
  1909. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1910. } else {
  1911. ownKeys(Object(source)).forEach(function (key) {
  1912. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1913. });
  1914. }
  1915. }
  1916. return target;
  1917. }
  1918. function _inheritsLoose(subClass, superClass) {
  1919. subClass.prototype = Object.create(superClass.prototype);
  1920. subClass.prototype.constructor = subClass;
  1921. subClass.__proto__ = superClass;
  1922. }
  1923. /**
  1924. * --------------------------------------------------------------------------
  1925. * Bootstrap (v4.4.1): util.js
  1926. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1927. * --------------------------------------------------------------------------
  1928. */
  1929. /**
  1930. * ------------------------------------------------------------------------
  1931. * Private TransitionEnd Helpers
  1932. * ------------------------------------------------------------------------
  1933. */
  1934. var TRANSITION_END = 'transitionend';
  1935. var MAX_UID = 1000000;
  1936. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1937. function toType(obj) {
  1938. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1939. }
  1940. function getSpecialTransitionEndEvent() {
  1941. return {
  1942. bindType: TRANSITION_END,
  1943. delegateType: TRANSITION_END,
  1944. handle: function handle(event) {
  1945. if ($(event.target).is(this)) {
  1946. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1947. }
  1948. return undefined; // eslint-disable-line no-undefined
  1949. }
  1950. };
  1951. }
  1952. function transitionEndEmulator(duration) {
  1953. var _this = this;
  1954. var called = false;
  1955. $(this).one(Util.TRANSITION_END, function () {
  1956. called = true;
  1957. });
  1958. setTimeout(function () {
  1959. if (!called) {
  1960. Util.triggerTransitionEnd(_this);
  1961. }
  1962. }, duration);
  1963. return this;
  1964. }
  1965. function setTransitionEndSupport() {
  1966. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1967. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1968. }
  1969. /**
  1970. * --------------------------------------------------------------------------
  1971. * Public Util Api
  1972. * --------------------------------------------------------------------------
  1973. */
  1974. var Util = {
  1975. TRANSITION_END: 'bsTransitionEnd',
  1976. getUID: function getUID(prefix) {
  1977. do {
  1978. // eslint-disable-next-line no-bitwise
  1979. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1980. } while (document.getElementById(prefix));
  1981. return prefix;
  1982. },
  1983. getSelectorFromElement: function getSelectorFromElement(element) {
  1984. var selector = element.getAttribute('data-target');
  1985. if (!selector || selector === '#') {
  1986. var hrefAttr = element.getAttribute('href');
  1987. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1988. }
  1989. try {
  1990. return document.querySelector(selector) ? selector : null;
  1991. } catch (err) {
  1992. return null;
  1993. }
  1994. },
  1995. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1996. if (!element) {
  1997. return 0;
  1998. } // Get transition-duration of the element
  1999. var transitionDuration = $(element).css('transition-duration');
  2000. var transitionDelay = $(element).css('transition-delay');
  2001. var floatTransitionDuration = parseFloat(transitionDuration);
  2002. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  2003. if (!floatTransitionDuration && !floatTransitionDelay) {
  2004. return 0;
  2005. } // If multiple durations are defined, take the first
  2006. transitionDuration = transitionDuration.split(',')[0];
  2007. transitionDelay = transitionDelay.split(',')[0];
  2008. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  2009. },
  2010. reflow: function reflow(element) {
  2011. return element.offsetHeight;
  2012. },
  2013. triggerTransitionEnd: function triggerTransitionEnd(element) {
  2014. $(element).trigger(TRANSITION_END);
  2015. },
  2016. // TODO: Remove in v5
  2017. supportsTransitionEnd: function supportsTransitionEnd() {
  2018. return Boolean(TRANSITION_END);
  2019. },
  2020. isElement: function isElement(obj) {
  2021. return (obj[0] || obj).nodeType;
  2022. },
  2023. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  2024. for (var property in configTypes) {
  2025. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  2026. var expectedTypes = configTypes[property];
  2027. var value = config[property];
  2028. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  2029. if (!new RegExp(expectedTypes).test(valueType)) {
  2030. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  2031. }
  2032. }
  2033. }
  2034. },
  2035. findShadowRoot: function findShadowRoot(element) {
  2036. if (!document.documentElement.attachShadow) {
  2037. return null;
  2038. } // Can find the shadow root otherwise it'll return the document
  2039. if (typeof element.getRootNode === 'function') {
  2040. var root = element.getRootNode();
  2041. return root instanceof ShadowRoot ? root : null;
  2042. }
  2043. if (element instanceof ShadowRoot) {
  2044. return element;
  2045. } // when we don't find a shadow root
  2046. if (!element.parentNode) {
  2047. return null;
  2048. }
  2049. return Util.findShadowRoot(element.parentNode);
  2050. },
  2051. jQueryDetection: function jQueryDetection() {
  2052. if (typeof $ === 'undefined') {
  2053. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2054. }
  2055. var version = $.fn.jquery.split(' ')[0].split('.');
  2056. var minMajor = 1;
  2057. var ltMajor = 2;
  2058. var minMinor = 9;
  2059. var minPatch = 1;
  2060. var maxMajor = 4;
  2061. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2062. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2063. }
  2064. }
  2065. };
  2066. Util.jQueryDetection();
  2067. setTransitionEndSupport();
  2068. /**
  2069. * ------------------------------------------------------------------------
  2070. * Constants
  2071. * ------------------------------------------------------------------------
  2072. */
  2073. var NAME = 'alert';
  2074. var VERSION = '4.4.1';
  2075. var DATA_KEY = 'bs.alert';
  2076. var EVENT_KEY = "." + DATA_KEY;
  2077. var DATA_API_KEY = '.data-api';
  2078. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2079. var Selector = {
  2080. DISMISS: '[data-dismiss="alert"]'
  2081. };
  2082. var Event = {
  2083. CLOSE: "close" + EVENT_KEY,
  2084. CLOSED: "closed" + EVENT_KEY,
  2085. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2086. };
  2087. var ClassName = {
  2088. ALERT: 'alert',
  2089. FADE: 'fade',
  2090. SHOW: 'show'
  2091. };
  2092. /**
  2093. * ------------------------------------------------------------------------
  2094. * Class Definition
  2095. * ------------------------------------------------------------------------
  2096. */
  2097. var Alert =
  2098. /*#__PURE__*/
  2099. function () {
  2100. function Alert(element) {
  2101. this._element = element;
  2102. } // Getters
  2103. var _proto = Alert.prototype;
  2104. // Public
  2105. _proto.close = function close(element) {
  2106. var rootElement = this._element;
  2107. if (element) {
  2108. rootElement = this._getRootElement(element);
  2109. }
  2110. var customEvent = this._triggerCloseEvent(rootElement);
  2111. if (customEvent.isDefaultPrevented()) {
  2112. return;
  2113. }
  2114. this._removeElement(rootElement);
  2115. };
  2116. _proto.dispose = function dispose() {
  2117. $.removeData(this._element, DATA_KEY);
  2118. this._element = null;
  2119. } // Private
  2120. ;
  2121. _proto._getRootElement = function _getRootElement(element) {
  2122. var selector = Util.getSelectorFromElement(element);
  2123. var parent = false;
  2124. if (selector) {
  2125. parent = document.querySelector(selector);
  2126. }
  2127. if (!parent) {
  2128. parent = $(element).closest("." + ClassName.ALERT)[0];
  2129. }
  2130. return parent;
  2131. };
  2132. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2133. var closeEvent = $.Event(Event.CLOSE);
  2134. $(element).trigger(closeEvent);
  2135. return closeEvent;
  2136. };
  2137. _proto._removeElement = function _removeElement(element) {
  2138. var _this = this;
  2139. $(element).removeClass(ClassName.SHOW);
  2140. if (!$(element).hasClass(ClassName.FADE)) {
  2141. this._destroyElement(element);
  2142. return;
  2143. }
  2144. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2145. $(element).one(Util.TRANSITION_END, function (event) {
  2146. return _this._destroyElement(element, event);
  2147. }).emulateTransitionEnd(transitionDuration);
  2148. };
  2149. _proto._destroyElement = function _destroyElement(element) {
  2150. $(element).detach().trigger(Event.CLOSED).remove();
  2151. } // Static
  2152. ;
  2153. Alert._jQueryInterface = function _jQueryInterface(config) {
  2154. return this.each(function () {
  2155. var $element = $(this);
  2156. var data = $element.data(DATA_KEY);
  2157. if (!data) {
  2158. data = new Alert(this);
  2159. $element.data(DATA_KEY, data);
  2160. }
  2161. if (config === 'close') {
  2162. data[config](this);
  2163. }
  2164. });
  2165. };
  2166. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2167. return function (event) {
  2168. if (event) {
  2169. event.preventDefault();
  2170. }
  2171. alertInstance.close(this);
  2172. };
  2173. };
  2174. _createClass(Alert, null, [{
  2175. key: "VERSION",
  2176. get: function get() {
  2177. return VERSION;
  2178. }
  2179. }]);
  2180. return Alert;
  2181. }();
  2182. /**
  2183. * ------------------------------------------------------------------------
  2184. * Data Api implementation
  2185. * ------------------------------------------------------------------------
  2186. */
  2187. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2188. /**
  2189. * ------------------------------------------------------------------------
  2190. * jQuery
  2191. * ------------------------------------------------------------------------
  2192. */
  2193. $.fn[NAME] = Alert._jQueryInterface;
  2194. $.fn[NAME].Constructor = Alert;
  2195. $.fn[NAME].noConflict = function () {
  2196. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2197. return Alert._jQueryInterface;
  2198. };
  2199. /**
  2200. * ------------------------------------------------------------------------
  2201. * Constants
  2202. * ------------------------------------------------------------------------
  2203. */
  2204. var NAME$1 = 'button';
  2205. var VERSION$1 = '4.4.1';
  2206. var DATA_KEY$1 = 'bs.button';
  2207. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2208. var DATA_API_KEY$1 = '.data-api';
  2209. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2210. var ClassName$1 = {
  2211. ACTIVE: 'active',
  2212. BUTTON: 'btn',
  2213. FOCUS: 'focus'
  2214. };
  2215. var Selector$1 = {
  2216. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2217. DATA_TOGGLES: '[data-toggle="buttons"]',
  2218. DATA_TOGGLE: '[data-toggle="button"]',
  2219. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2220. INPUT: 'input:not([type="hidden"])',
  2221. ACTIVE: '.active',
  2222. BUTTON: '.btn'
  2223. };
  2224. var Event$1 = {
  2225. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2226. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2227. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2228. };
  2229. /**
  2230. * ------------------------------------------------------------------------
  2231. * Class Definition
  2232. * ------------------------------------------------------------------------
  2233. */
  2234. var Button =
  2235. /*#__PURE__*/
  2236. function () {
  2237. function Button(element) {
  2238. this._element = element;
  2239. } // Getters
  2240. var _proto = Button.prototype;
  2241. // Public
  2242. _proto.toggle = function toggle() {
  2243. var triggerChangeEvent = true;
  2244. var addAriaPressed = true;
  2245. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2246. if (rootElement) {
  2247. var input = this._element.querySelector(Selector$1.INPUT);
  2248. if (input) {
  2249. if (input.type === 'radio') {
  2250. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2251. triggerChangeEvent = false;
  2252. } else {
  2253. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2254. if (activeElement) {
  2255. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2256. }
  2257. }
  2258. } else if (input.type === 'checkbox') {
  2259. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2260. triggerChangeEvent = false;
  2261. }
  2262. } else {
  2263. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2264. triggerChangeEvent = false;
  2265. }
  2266. if (triggerChangeEvent) {
  2267. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2268. $(input).trigger('change');
  2269. }
  2270. input.focus();
  2271. addAriaPressed = false;
  2272. }
  2273. }
  2274. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2275. if (addAriaPressed) {
  2276. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2277. }
  2278. if (triggerChangeEvent) {
  2279. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2280. }
  2281. }
  2282. };
  2283. _proto.dispose = function dispose() {
  2284. $.removeData(this._element, DATA_KEY$1);
  2285. this._element = null;
  2286. } // Static
  2287. ;
  2288. Button._jQueryInterface = function _jQueryInterface(config) {
  2289. return this.each(function () {
  2290. var data = $(this).data(DATA_KEY$1);
  2291. if (!data) {
  2292. data = new Button(this);
  2293. $(this).data(DATA_KEY$1, data);
  2294. }
  2295. if (config === 'toggle') {
  2296. data[config]();
  2297. }
  2298. });
  2299. };
  2300. _createClass(Button, null, [{
  2301. key: "VERSION",
  2302. get: function get() {
  2303. return VERSION$1;
  2304. }
  2305. }]);
  2306. return Button;
  2307. }();
  2308. /**
  2309. * ------------------------------------------------------------------------
  2310. * Data Api implementation
  2311. * ------------------------------------------------------------------------
  2312. */
  2313. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2314. var button = event.target;
  2315. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2316. button = $(button).closest(Selector$1.BUTTON)[0];
  2317. }
  2318. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2319. event.preventDefault(); // work around Firefox bug #1540995
  2320. } else {
  2321. var inputBtn = button.querySelector(Selector$1.INPUT);
  2322. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2323. event.preventDefault(); // work around Firefox bug #1540995
  2324. return;
  2325. }
  2326. Button._jQueryInterface.call($(button), 'toggle');
  2327. }
  2328. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2329. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2330. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2331. });
  2332. $(window).on(Event$1.LOAD_DATA_API, function () {
  2333. // ensure correct active class is set to match the controls' actual values/states
  2334. // find all checkboxes/readio buttons inside data-toggle groups
  2335. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2336. for (var i = 0, len = buttons.length; i < len; i++) {
  2337. var button = buttons[i];
  2338. var input = button.querySelector(Selector$1.INPUT);
  2339. if (input.checked || input.hasAttribute('checked')) {
  2340. button.classList.add(ClassName$1.ACTIVE);
  2341. } else {
  2342. button.classList.remove(ClassName$1.ACTIVE);
  2343. }
  2344. } // find all button toggles
  2345. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2346. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2347. var _button = buttons[_i];
  2348. if (_button.getAttribute('aria-pressed') === 'true') {
  2349. _button.classList.add(ClassName$1.ACTIVE);
  2350. } else {
  2351. _button.classList.remove(ClassName$1.ACTIVE);
  2352. }
  2353. }
  2354. });
  2355. /**
  2356. * ------------------------------------------------------------------------
  2357. * jQuery
  2358. * ------------------------------------------------------------------------
  2359. */
  2360. $.fn[NAME$1] = Button._jQueryInterface;
  2361. $.fn[NAME$1].Constructor = Button;
  2362. $.fn[NAME$1].noConflict = function () {
  2363. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2364. return Button._jQueryInterface;
  2365. };
  2366. /**
  2367. * ------------------------------------------------------------------------
  2368. * Constants
  2369. * ------------------------------------------------------------------------
  2370. */
  2371. var NAME$2 = 'carousel';
  2372. var VERSION$2 = '4.4.1';
  2373. var DATA_KEY$2 = 'bs.carousel';
  2374. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2375. var DATA_API_KEY$2 = '.data-api';
  2376. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2377. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2378. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2379. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2380. var SWIPE_THRESHOLD = 40;
  2381. var Default = {
  2382. interval: 5000,
  2383. keyboard: true,
  2384. slide: false,
  2385. pause: 'hover',
  2386. wrap: true,
  2387. touch: true
  2388. };
  2389. var DefaultType = {
  2390. interval: '(number|boolean)',
  2391. keyboard: 'boolean',
  2392. slide: '(boolean|string)',
  2393. pause: '(string|boolean)',
  2394. wrap: 'boolean',
  2395. touch: 'boolean'
  2396. };
  2397. var Direction = {
  2398. NEXT: 'next',
  2399. PREV: 'prev',
  2400. LEFT: 'left',
  2401. RIGHT: 'right'
  2402. };
  2403. var Event$2 = {
  2404. SLIDE: "slide" + EVENT_KEY$2,
  2405. SLID: "slid" + EVENT_KEY$2,
  2406. KEYDOWN: "keydown" + EVENT_KEY$2,
  2407. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2408. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2409. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2410. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2411. TOUCHEND: "touchend" + EVENT_KEY$2,
  2412. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2413. POINTERUP: "pointerup" + EVENT_KEY$2,
  2414. DRAG_START: "dragstart" + EVENT_KEY$2,
  2415. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2416. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2417. };
  2418. var ClassName$2 = {
  2419. CAROUSEL: 'carousel',
  2420. ACTIVE: 'active',
  2421. SLIDE: 'slide',
  2422. RIGHT: 'carousel-item-right',
  2423. LEFT: 'carousel-item-left',
  2424. NEXT: 'carousel-item-next',
  2425. PREV: 'carousel-item-prev',
  2426. ITEM: 'carousel-item',
  2427. POINTER_EVENT: 'pointer-event'
  2428. };
  2429. var Selector$2 = {
  2430. ACTIVE: '.active',
  2431. ACTIVE_ITEM: '.active.carousel-item',
  2432. ITEM: '.carousel-item',
  2433. ITEM_IMG: '.carousel-item img',
  2434. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2435. INDICATORS: '.carousel-indicators',
  2436. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2437. DATA_RIDE: '[data-ride="carousel"]'
  2438. };
  2439. var PointerType = {
  2440. TOUCH: 'touch',
  2441. PEN: 'pen'
  2442. };
  2443. /**
  2444. * ------------------------------------------------------------------------
  2445. * Class Definition
  2446. * ------------------------------------------------------------------------
  2447. */
  2448. var Carousel =
  2449. /*#__PURE__*/
  2450. function () {
  2451. function Carousel(element, config) {
  2452. this._items = null;
  2453. this._interval = null;
  2454. this._activeElement = null;
  2455. this._isPaused = false;
  2456. this._isSliding = false;
  2457. this.touchTimeout = null;
  2458. this.touchStartX = 0;
  2459. this.touchDeltaX = 0;
  2460. this._config = this._getConfig(config);
  2461. this._element = element;
  2462. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2463. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2464. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2465. this._addEventListeners();
  2466. } // Getters
  2467. var _proto = Carousel.prototype;
  2468. // Public
  2469. _proto.next = function next() {
  2470. if (!this._isSliding) {
  2471. this._slide(Direction.NEXT);
  2472. }
  2473. };
  2474. _proto.nextWhenVisible = function nextWhenVisible() {
  2475. // Don't call next when the page isn't visible
  2476. // or the carousel or its parent isn't visible
  2477. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2478. this.next();
  2479. }
  2480. };
  2481. _proto.prev = function prev() {
  2482. if (!this._isSliding) {
  2483. this._slide(Direction.PREV);
  2484. }
  2485. };
  2486. _proto.pause = function pause(event) {
  2487. if (!event) {
  2488. this._isPaused = true;
  2489. }
  2490. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2491. Util.triggerTransitionEnd(this._element);
  2492. this.cycle(true);
  2493. }
  2494. clearInterval(this._interval);
  2495. this._interval = null;
  2496. };
  2497. _proto.cycle = function cycle(event) {
  2498. if (!event) {
  2499. this._isPaused = false;
  2500. }
  2501. if (this._interval) {
  2502. clearInterval(this._interval);
  2503. this._interval = null;
  2504. }
  2505. if (this._config.interval && !this._isPaused) {
  2506. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2507. }
  2508. };
  2509. _proto.to = function to(index) {
  2510. var _this = this;
  2511. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2512. var activeIndex = this._getItemIndex(this._activeElement);
  2513. if (index > this._items.length - 1 || index < 0) {
  2514. return;
  2515. }
  2516. if (this._isSliding) {
  2517. $(this._element).one(Event$2.SLID, function () {
  2518. return _this.to(index);
  2519. });
  2520. return;
  2521. }
  2522. if (activeIndex === index) {
  2523. this.pause();
  2524. this.cycle();
  2525. return;
  2526. }
  2527. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2528. this._slide(direction, this._items[index]);
  2529. };
  2530. _proto.dispose = function dispose() {
  2531. $(this._element).off(EVENT_KEY$2);
  2532. $.removeData(this._element, DATA_KEY$2);
  2533. this._items = null;
  2534. this._config = null;
  2535. this._element = null;
  2536. this._interval = null;
  2537. this._isPaused = null;
  2538. this._isSliding = null;
  2539. this._activeElement = null;
  2540. this._indicatorsElement = null;
  2541. } // Private
  2542. ;
  2543. _proto._getConfig = function _getConfig(config) {
  2544. config = _objectSpread2({}, Default, {}, config);
  2545. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2546. return config;
  2547. };
  2548. _proto._handleSwipe = function _handleSwipe() {
  2549. var absDeltax = Math.abs(this.touchDeltaX);
  2550. if (absDeltax <= SWIPE_THRESHOLD) {
  2551. return;
  2552. }
  2553. var direction = absDeltax / this.touchDeltaX;
  2554. this.touchDeltaX = 0; // swipe left
  2555. if (direction > 0) {
  2556. this.prev();
  2557. } // swipe right
  2558. if (direction < 0) {
  2559. this.next();
  2560. }
  2561. };
  2562. _proto._addEventListeners = function _addEventListeners() {
  2563. var _this2 = this;
  2564. if (this._config.keyboard) {
  2565. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2566. return _this2._keydown(event);
  2567. });
  2568. }
  2569. if (this._config.pause === 'hover') {
  2570. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2571. return _this2.pause(event);
  2572. }).on(Event$2.MOUSELEAVE, function (event) {
  2573. return _this2.cycle(event);
  2574. });
  2575. }
  2576. if (this._config.touch) {
  2577. this._addTouchEventListeners();
  2578. }
  2579. };
  2580. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2581. var _this3 = this;
  2582. if (!this._touchSupported) {
  2583. return;
  2584. }
  2585. var start = function start(event) {
  2586. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2587. _this3.touchStartX = event.originalEvent.clientX;
  2588. } else if (!_this3._pointerEvent) {
  2589. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2590. }
  2591. };
  2592. var move = function move(event) {
  2593. // ensure swiping with one touch and not pinching
  2594. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2595. _this3.touchDeltaX = 0;
  2596. } else {
  2597. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2598. }
  2599. };
  2600. var end = function end(event) {
  2601. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2602. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2603. }
  2604. _this3._handleSwipe();
  2605. if (_this3._config.pause === 'hover') {
  2606. // If it's a touch-enabled device, mouseenter/leave are fired as
  2607. // part of the mouse compatibility events on first tap - the carousel
  2608. // would stop cycling until user tapped out of it;
  2609. // here, we listen for touchend, explicitly pause the carousel
  2610. // (as if it's the second time we tap on it, mouseenter compat event
  2611. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2612. // events to fire) we explicitly restart cycling
  2613. _this3.pause();
  2614. if (_this3.touchTimeout) {
  2615. clearTimeout(_this3.touchTimeout);
  2616. }
  2617. _this3.touchTimeout = setTimeout(function (event) {
  2618. return _this3.cycle(event);
  2619. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2620. }
  2621. };
  2622. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2623. return e.preventDefault();
  2624. });
  2625. if (this._pointerEvent) {
  2626. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2627. return start(event);
  2628. });
  2629. $(this._element).on(Event$2.POINTERUP, function (event) {
  2630. return end(event);
  2631. });
  2632. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2633. } else {
  2634. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2635. return start(event);
  2636. });
  2637. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2638. return move(event);
  2639. });
  2640. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2641. return end(event);
  2642. });
  2643. }
  2644. };
  2645. _proto._keydown = function _keydown(event) {
  2646. if (/input|textarea/i.test(event.target.tagName)) {
  2647. return;
  2648. }
  2649. switch (event.which) {
  2650. case ARROW_LEFT_KEYCODE:
  2651. event.preventDefault();
  2652. this.prev();
  2653. break;
  2654. case ARROW_RIGHT_KEYCODE:
  2655. event.preventDefault();
  2656. this.next();
  2657. break;
  2658. }
  2659. };
  2660. _proto._getItemIndex = function _getItemIndex(element) {
  2661. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2662. return this._items.indexOf(element);
  2663. };
  2664. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2665. var isNextDirection = direction === Direction.NEXT;
  2666. var isPrevDirection = direction === Direction.PREV;
  2667. var activeIndex = this._getItemIndex(activeElement);
  2668. var lastItemIndex = this._items.length - 1;
  2669. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2670. if (isGoingToWrap && !this._config.wrap) {
  2671. return activeElement;
  2672. }
  2673. var delta = direction === Direction.PREV ? -1 : 1;
  2674. var itemIndex = (activeIndex + delta) % this._items.length;
  2675. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2676. };
  2677. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2678. var targetIndex = this._getItemIndex(relatedTarget);
  2679. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2680. var slideEvent = $.Event(Event$2.SLIDE, {
  2681. relatedTarget: relatedTarget,
  2682. direction: eventDirectionName,
  2683. from: fromIndex,
  2684. to: targetIndex
  2685. });
  2686. $(this._element).trigger(slideEvent);
  2687. return slideEvent;
  2688. };
  2689. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2690. if (this._indicatorsElement) {
  2691. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2692. $(indicators).removeClass(ClassName$2.ACTIVE);
  2693. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2694. if (nextIndicator) {
  2695. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2696. }
  2697. }
  2698. };
  2699. _proto._slide = function _slide(direction, element) {
  2700. var _this4 = this;
  2701. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2702. var activeElementIndex = this._getItemIndex(activeElement);
  2703. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2704. var nextElementIndex = this._getItemIndex(nextElement);
  2705. var isCycling = Boolean(this._interval);
  2706. var directionalClassName;
  2707. var orderClassName;
  2708. var eventDirectionName;
  2709. if (direction === Direction.NEXT) {
  2710. directionalClassName = ClassName$2.LEFT;
  2711. orderClassName = ClassName$2.NEXT;
  2712. eventDirectionName = Direction.LEFT;
  2713. } else {
  2714. directionalClassName = ClassName$2.RIGHT;
  2715. orderClassName = ClassName$2.PREV;
  2716. eventDirectionName = Direction.RIGHT;
  2717. }
  2718. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2719. this._isSliding = false;
  2720. return;
  2721. }
  2722. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2723. if (slideEvent.isDefaultPrevented()) {
  2724. return;
  2725. }
  2726. if (!activeElement || !nextElement) {
  2727. // Some weirdness is happening, so we bail
  2728. return;
  2729. }
  2730. this._isSliding = true;
  2731. if (isCycling) {
  2732. this.pause();
  2733. }
  2734. this._setActiveIndicatorElement(nextElement);
  2735. var slidEvent = $.Event(Event$2.SLID, {
  2736. relatedTarget: nextElement,
  2737. direction: eventDirectionName,
  2738. from: activeElementIndex,
  2739. to: nextElementIndex
  2740. });
  2741. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2742. $(nextElement).addClass(orderClassName);
  2743. Util.reflow(nextElement);
  2744. $(activeElement).addClass(directionalClassName);
  2745. $(nextElement).addClass(directionalClassName);
  2746. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2747. if (nextElementInterval) {
  2748. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2749. this._config.interval = nextElementInterval;
  2750. } else {
  2751. this._config.interval = this._config.defaultInterval || this._config.interval;
  2752. }
  2753. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2754. $(activeElement).one(Util.TRANSITION_END, function () {
  2755. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2756. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2757. _this4._isSliding = false;
  2758. setTimeout(function () {
  2759. return $(_this4._element).trigger(slidEvent);
  2760. }, 0);
  2761. }).emulateTransitionEnd(transitionDuration);
  2762. } else {
  2763. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2764. $(nextElement).addClass(ClassName$2.ACTIVE);
  2765. this._isSliding = false;
  2766. $(this._element).trigger(slidEvent);
  2767. }
  2768. if (isCycling) {
  2769. this.cycle();
  2770. }
  2771. } // Static
  2772. ;
  2773. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2774. return this.each(function () {
  2775. var data = $(this).data(DATA_KEY$2);
  2776. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2777. if (typeof config === 'object') {
  2778. _config = _objectSpread2({}, _config, {}, config);
  2779. }
  2780. var action = typeof config === 'string' ? config : _config.slide;
  2781. if (!data) {
  2782. data = new Carousel(this, _config);
  2783. $(this).data(DATA_KEY$2, data);
  2784. }
  2785. if (typeof config === 'number') {
  2786. data.to(config);
  2787. } else if (typeof action === 'string') {
  2788. if (typeof data[action] === 'undefined') {
  2789. throw new TypeError("No method named \"" + action + "\"");
  2790. }
  2791. data[action]();
  2792. } else if (_config.interval && _config.ride) {
  2793. data.pause();
  2794. data.cycle();
  2795. }
  2796. });
  2797. };
  2798. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2799. var selector = Util.getSelectorFromElement(this);
  2800. if (!selector) {
  2801. return;
  2802. }
  2803. var target = $(selector)[0];
  2804. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2805. return;
  2806. }
  2807. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2808. var slideIndex = this.getAttribute('data-slide-to');
  2809. if (slideIndex) {
  2810. config.interval = false;
  2811. }
  2812. Carousel._jQueryInterface.call($(target), config);
  2813. if (slideIndex) {
  2814. $(target).data(DATA_KEY$2).to(slideIndex);
  2815. }
  2816. event.preventDefault();
  2817. };
  2818. _createClass(Carousel, null, [{
  2819. key: "VERSION",
  2820. get: function get() {
  2821. return VERSION$2;
  2822. }
  2823. }, {
  2824. key: "Default",
  2825. get: function get() {
  2826. return Default;
  2827. }
  2828. }]);
  2829. return Carousel;
  2830. }();
  2831. /**
  2832. * ------------------------------------------------------------------------
  2833. * Data Api implementation
  2834. * ------------------------------------------------------------------------
  2835. */
  2836. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2837. $(window).on(Event$2.LOAD_DATA_API, function () {
  2838. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2839. for (var i = 0, len = carousels.length; i < len; i++) {
  2840. var $carousel = $(carousels[i]);
  2841. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2842. }
  2843. });
  2844. /**
  2845. * ------------------------------------------------------------------------
  2846. * jQuery
  2847. * ------------------------------------------------------------------------
  2848. */
  2849. $.fn[NAME$2] = Carousel._jQueryInterface;
  2850. $.fn[NAME$2].Constructor = Carousel;
  2851. $.fn[NAME$2].noConflict = function () {
  2852. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2853. return Carousel._jQueryInterface;
  2854. };
  2855. /**
  2856. * ------------------------------------------------------------------------
  2857. * Constants
  2858. * ------------------------------------------------------------------------
  2859. */
  2860. var NAME$3 = 'collapse';
  2861. var VERSION$3 = '4.4.1';
  2862. var DATA_KEY$3 = 'bs.collapse';
  2863. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2864. var DATA_API_KEY$3 = '.data-api';
  2865. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2866. var Default$1 = {
  2867. toggle: true,
  2868. parent: ''
  2869. };
  2870. var DefaultType$1 = {
  2871. toggle: 'boolean',
  2872. parent: '(string|element)'
  2873. };
  2874. var Event$3 = {
  2875. SHOW: "show" + EVENT_KEY$3,
  2876. SHOWN: "shown" + EVENT_KEY$3,
  2877. HIDE: "hide" + EVENT_KEY$3,
  2878. HIDDEN: "hidden" + EVENT_KEY$3,
  2879. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2880. };
  2881. var ClassName$3 = {
  2882. SHOW: 'show',
  2883. COLLAPSE: 'collapse',
  2884. COLLAPSING: 'collapsing',
  2885. COLLAPSED: 'collapsed'
  2886. };
  2887. var Dimension = {
  2888. WIDTH: 'width',
  2889. HEIGHT: 'height'
  2890. };
  2891. var Selector$3 = {
  2892. ACTIVES: '.show, .collapsing',
  2893. DATA_TOGGLE: '[data-toggle="collapse"]'
  2894. };
  2895. /**
  2896. * ------------------------------------------------------------------------
  2897. * Class Definition
  2898. * ------------------------------------------------------------------------
  2899. */
  2900. var Collapse =
  2901. /*#__PURE__*/
  2902. function () {
  2903. function Collapse(element, config) {
  2904. this._isTransitioning = false;
  2905. this._element = element;
  2906. this._config = this._getConfig(config);
  2907. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2908. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2909. for (var i = 0, len = toggleList.length; i < len; i++) {
  2910. var elem = toggleList[i];
  2911. var selector = Util.getSelectorFromElement(elem);
  2912. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2913. return foundElem === element;
  2914. });
  2915. if (selector !== null && filterElement.length > 0) {
  2916. this._selector = selector;
  2917. this._triggerArray.push(elem);
  2918. }
  2919. }
  2920. this._parent = this._config.parent ? this._getParent() : null;
  2921. if (!this._config.parent) {
  2922. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2923. }
  2924. if (this._config.toggle) {
  2925. this.toggle();
  2926. }
  2927. } // Getters
  2928. var _proto = Collapse.prototype;
  2929. // Public
  2930. _proto.toggle = function toggle() {
  2931. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2932. this.hide();
  2933. } else {
  2934. this.show();
  2935. }
  2936. };
  2937. _proto.show = function show() {
  2938. var _this = this;
  2939. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2940. return;
  2941. }
  2942. var actives;
  2943. var activesData;
  2944. if (this._parent) {
  2945. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2946. if (typeof _this._config.parent === 'string') {
  2947. return elem.getAttribute('data-parent') === _this._config.parent;
  2948. }
  2949. return elem.classList.contains(ClassName$3.COLLAPSE);
  2950. });
  2951. if (actives.length === 0) {
  2952. actives = null;
  2953. }
  2954. }
  2955. if (actives) {
  2956. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2957. if (activesData && activesData._isTransitioning) {
  2958. return;
  2959. }
  2960. }
  2961. var startEvent = $.Event(Event$3.SHOW);
  2962. $(this._element).trigger(startEvent);
  2963. if (startEvent.isDefaultPrevented()) {
  2964. return;
  2965. }
  2966. if (actives) {
  2967. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2968. if (!activesData) {
  2969. $(actives).data(DATA_KEY$3, null);
  2970. }
  2971. }
  2972. var dimension = this._getDimension();
  2973. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  2974. this._element.style[dimension] = 0;
  2975. if (this._triggerArray.length) {
  2976. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  2977. }
  2978. this.setTransitioning(true);
  2979. var complete = function complete() {
  2980. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  2981. _this._element.style[dimension] = '';
  2982. _this.setTransitioning(false);
  2983. $(_this._element).trigger(Event$3.SHOWN);
  2984. };
  2985. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2986. var scrollSize = "scroll" + capitalizedDimension;
  2987. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2988. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2989. this._element.style[dimension] = this._element[scrollSize] + "px";
  2990. };
  2991. _proto.hide = function hide() {
  2992. var _this2 = this;
  2993. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  2994. return;
  2995. }
  2996. var startEvent = $.Event(Event$3.HIDE);
  2997. $(this._element).trigger(startEvent);
  2998. if (startEvent.isDefaultPrevented()) {
  2999. return;
  3000. }
  3001. var dimension = this._getDimension();
  3002. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  3003. Util.reflow(this._element);
  3004. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  3005. var triggerArrayLength = this._triggerArray.length;
  3006. if (triggerArrayLength > 0) {
  3007. for (var i = 0; i < triggerArrayLength; i++) {
  3008. var trigger = this._triggerArray[i];
  3009. var selector = Util.getSelectorFromElement(trigger);
  3010. if (selector !== null) {
  3011. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  3012. if (!$elem.hasClass(ClassName$3.SHOW)) {
  3013. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  3014. }
  3015. }
  3016. }
  3017. }
  3018. this.setTransitioning(true);
  3019. var complete = function complete() {
  3020. _this2.setTransitioning(false);
  3021. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  3022. };
  3023. this._element.style[dimension] = '';
  3024. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3025. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3026. };
  3027. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  3028. this._isTransitioning = isTransitioning;
  3029. };
  3030. _proto.dispose = function dispose() {
  3031. $.removeData(this._element, DATA_KEY$3);
  3032. this._config = null;
  3033. this._parent = null;
  3034. this._element = null;
  3035. this._triggerArray = null;
  3036. this._isTransitioning = null;
  3037. } // Private
  3038. ;
  3039. _proto._getConfig = function _getConfig(config) {
  3040. config = _objectSpread2({}, Default$1, {}, config);
  3041. config.toggle = Boolean(config.toggle); // Coerce string values
  3042. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3043. return config;
  3044. };
  3045. _proto._getDimension = function _getDimension() {
  3046. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3047. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3048. };
  3049. _proto._getParent = function _getParent() {
  3050. var _this3 = this;
  3051. var parent;
  3052. if (Util.isElement(this._config.parent)) {
  3053. parent = this._config.parent; // It's a jQuery object
  3054. if (typeof this._config.parent.jquery !== 'undefined') {
  3055. parent = this._config.parent[0];
  3056. }
  3057. } else {
  3058. parent = document.querySelector(this._config.parent);
  3059. }
  3060. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3061. var children = [].slice.call(parent.querySelectorAll(selector));
  3062. $(children).each(function (i, element) {
  3063. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3064. });
  3065. return parent;
  3066. };
  3067. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3068. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3069. if (triggerArray.length) {
  3070. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3071. }
  3072. } // Static
  3073. ;
  3074. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3075. var selector = Util.getSelectorFromElement(element);
  3076. return selector ? document.querySelector(selector) : null;
  3077. };
  3078. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3079. return this.each(function () {
  3080. var $this = $(this);
  3081. var data = $this.data(DATA_KEY$3);
  3082. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3083. if (!data && _config.toggle && /show|hide/.test(config)) {
  3084. _config.toggle = false;
  3085. }
  3086. if (!data) {
  3087. data = new Collapse(this, _config);
  3088. $this.data(DATA_KEY$3, data);
  3089. }
  3090. if (typeof config === 'string') {
  3091. if (typeof data[config] === 'undefined') {
  3092. throw new TypeError("No method named \"" + config + "\"");
  3093. }
  3094. data[config]();
  3095. }
  3096. });
  3097. };
  3098. _createClass(Collapse, null, [{
  3099. key: "VERSION",
  3100. get: function get() {
  3101. return VERSION$3;
  3102. }
  3103. }, {
  3104. key: "Default",
  3105. get: function get() {
  3106. return Default$1;
  3107. }
  3108. }]);
  3109. return Collapse;
  3110. }();
  3111. /**
  3112. * ------------------------------------------------------------------------
  3113. * Data Api implementation
  3114. * ------------------------------------------------------------------------
  3115. */
  3116. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3117. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3118. if (event.currentTarget.tagName === 'A') {
  3119. event.preventDefault();
  3120. }
  3121. var $trigger = $(this);
  3122. var selector = Util.getSelectorFromElement(this);
  3123. var selectors = [].slice.call(document.querySelectorAll(selector));
  3124. $(selectors).each(function () {
  3125. var $target = $(this);
  3126. var data = $target.data(DATA_KEY$3);
  3127. var config = data ? 'toggle' : $trigger.data();
  3128. Collapse._jQueryInterface.call($target, config);
  3129. });
  3130. });
  3131. /**
  3132. * ------------------------------------------------------------------------
  3133. * jQuery
  3134. * ------------------------------------------------------------------------
  3135. */
  3136. $.fn[NAME$3] = Collapse._jQueryInterface;
  3137. $.fn[NAME$3].Constructor = Collapse;
  3138. $.fn[NAME$3].noConflict = function () {
  3139. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3140. return Collapse._jQueryInterface;
  3141. };
  3142. /**
  3143. * ------------------------------------------------------------------------
  3144. * Constants
  3145. * ------------------------------------------------------------------------
  3146. */
  3147. var NAME$4 = 'dropdown';
  3148. var VERSION$4 = '4.4.1';
  3149. var DATA_KEY$4 = 'bs.dropdown';
  3150. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3151. var DATA_API_KEY$4 = '.data-api';
  3152. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3153. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3154. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3155. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3156. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3157. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3158. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3159. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3160. var Event$4 = {
  3161. HIDE: "hide" + EVENT_KEY$4,
  3162. HIDDEN: "hidden" + EVENT_KEY$4,
  3163. SHOW: "show" + EVENT_KEY$4,
  3164. SHOWN: "shown" + EVENT_KEY$4,
  3165. CLICK: "click" + EVENT_KEY$4,
  3166. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3167. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3168. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3169. };
  3170. var ClassName$4 = {
  3171. DISABLED: 'disabled',
  3172. SHOW: 'show',
  3173. DROPUP: 'dropup',
  3174. DROPRIGHT: 'dropright',
  3175. DROPLEFT: 'dropleft',
  3176. MENURIGHT: 'dropdown-menu-right',
  3177. MENULEFT: 'dropdown-menu-left',
  3178. POSITION_STATIC: 'position-static'
  3179. };
  3180. var Selector$4 = {
  3181. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3182. FORM_CHILD: '.dropdown form',
  3183. MENU: '.dropdown-menu',
  3184. NAVBAR_NAV: '.navbar-nav',
  3185. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3186. };
  3187. var AttachmentMap = {
  3188. TOP: 'top-start',
  3189. TOPEND: 'top-end',
  3190. BOTTOM: 'bottom-start',
  3191. BOTTOMEND: 'bottom-end',
  3192. RIGHT: 'right-start',
  3193. RIGHTEND: 'right-end',
  3194. LEFT: 'left-start',
  3195. LEFTEND: 'left-end'
  3196. };
  3197. var Default$2 = {
  3198. offset: 0,
  3199. flip: true,
  3200. boundary: 'scrollParent',
  3201. reference: 'toggle',
  3202. display: 'dynamic',
  3203. popperConfig: null
  3204. };
  3205. var DefaultType$2 = {
  3206. offset: '(number|string|function)',
  3207. flip: 'boolean',
  3208. boundary: '(string|element)',
  3209. reference: '(string|element)',
  3210. display: 'string',
  3211. popperConfig: '(null|object)'
  3212. };
  3213. /**
  3214. * ------------------------------------------------------------------------
  3215. * Class Definition
  3216. * ------------------------------------------------------------------------
  3217. */
  3218. var Dropdown =
  3219. /*#__PURE__*/
  3220. function () {
  3221. function Dropdown(element, config) {
  3222. this._element = element;
  3223. this._popper = null;
  3224. this._config = this._getConfig(config);
  3225. this._menu = this._getMenuElement();
  3226. this._inNavbar = this._detectNavbar();
  3227. this._addEventListeners();
  3228. } // Getters
  3229. var _proto = Dropdown.prototype;
  3230. // Public
  3231. _proto.toggle = function toggle() {
  3232. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3233. return;
  3234. }
  3235. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3236. Dropdown._clearMenus();
  3237. if (isActive) {
  3238. return;
  3239. }
  3240. this.show(true);
  3241. };
  3242. _proto.show = function show(usePopper) {
  3243. if (usePopper === void 0) {
  3244. usePopper = false;
  3245. }
  3246. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3247. return;
  3248. }
  3249. var relatedTarget = {
  3250. relatedTarget: this._element
  3251. };
  3252. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3253. var parent = Dropdown._getParentFromElement(this._element);
  3254. $(parent).trigger(showEvent);
  3255. if (showEvent.isDefaultPrevented()) {
  3256. return;
  3257. } // Disable totally Popper.js for Dropdown in Navbar
  3258. if (!this._inNavbar && usePopper) {
  3259. /**
  3260. * Check for Popper dependency
  3261. * Popper - https://popper.js.org
  3262. */
  3263. if (typeof Popper === 'undefined') {
  3264. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3265. }
  3266. var referenceElement = this._element;
  3267. if (this._config.reference === 'parent') {
  3268. referenceElement = parent;
  3269. } else if (Util.isElement(this._config.reference)) {
  3270. referenceElement = this._config.reference; // Check if it's jQuery element
  3271. if (typeof this._config.reference.jquery !== 'undefined') {
  3272. referenceElement = this._config.reference[0];
  3273. }
  3274. } // If boundary is not `scrollParent`, then set position to `static`
  3275. // to allow the menu to "escape" the scroll parent's boundaries
  3276. // https://github.com/twbs/bootstrap/issues/24251
  3277. if (this._config.boundary !== 'scrollParent') {
  3278. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3279. }
  3280. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3281. } // If this is a touch-enabled device we add extra
  3282. // empty mouseover listeners to the body's immediate children;
  3283. // only needed because of broken event delegation on iOS
  3284. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3285. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3286. $(document.body).children().on('mouseover', null, $.noop);
  3287. }
  3288. this._element.focus();
  3289. this._element.setAttribute('aria-expanded', true);
  3290. $(this._menu).toggleClass(ClassName$4.SHOW);
  3291. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3292. };
  3293. _proto.hide = function hide() {
  3294. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3295. return;
  3296. }
  3297. var relatedTarget = {
  3298. relatedTarget: this._element
  3299. };
  3300. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3301. var parent = Dropdown._getParentFromElement(this._element);
  3302. $(parent).trigger(hideEvent);
  3303. if (hideEvent.isDefaultPrevented()) {
  3304. return;
  3305. }
  3306. if (this._popper) {
  3307. this._popper.destroy();
  3308. }
  3309. $(this._menu).toggleClass(ClassName$4.SHOW);
  3310. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3311. };
  3312. _proto.dispose = function dispose() {
  3313. $.removeData(this._element, DATA_KEY$4);
  3314. $(this._element).off(EVENT_KEY$4);
  3315. this._element = null;
  3316. this._menu = null;
  3317. if (this._popper !== null) {
  3318. this._popper.destroy();
  3319. this._popper = null;
  3320. }
  3321. };
  3322. _proto.update = function update() {
  3323. this._inNavbar = this._detectNavbar();
  3324. if (this._popper !== null) {
  3325. this._popper.scheduleUpdate();
  3326. }
  3327. } // Private
  3328. ;
  3329. _proto._addEventListeners = function _addEventListeners() {
  3330. var _this = this;
  3331. $(this._element).on(Event$4.CLICK, function (event) {
  3332. event.preventDefault();
  3333. event.stopPropagation();
  3334. _this.toggle();
  3335. });
  3336. };
  3337. _proto._getConfig = function _getConfig(config) {
  3338. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3339. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3340. return config;
  3341. };
  3342. _proto._getMenuElement = function _getMenuElement() {
  3343. if (!this._menu) {
  3344. var parent = Dropdown._getParentFromElement(this._element);
  3345. if (parent) {
  3346. this._menu = parent.querySelector(Selector$4.MENU);
  3347. }
  3348. }
  3349. return this._menu;
  3350. };
  3351. _proto._getPlacement = function _getPlacement() {
  3352. var $parentDropdown = $(this._element.parentNode);
  3353. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3354. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3355. placement = AttachmentMap.TOP;
  3356. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3357. placement = AttachmentMap.TOPEND;
  3358. }
  3359. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3360. placement = AttachmentMap.RIGHT;
  3361. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3362. placement = AttachmentMap.LEFT;
  3363. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3364. placement = AttachmentMap.BOTTOMEND;
  3365. }
  3366. return placement;
  3367. };
  3368. _proto._detectNavbar = function _detectNavbar() {
  3369. return $(this._element).closest('.navbar').length > 0;
  3370. };
  3371. _proto._getOffset = function _getOffset() {
  3372. var _this2 = this;
  3373. var offset = {};
  3374. if (typeof this._config.offset === 'function') {
  3375. offset.fn = function (data) {
  3376. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3377. return data;
  3378. };
  3379. } else {
  3380. offset.offset = this._config.offset;
  3381. }
  3382. return offset;
  3383. };
  3384. _proto._getPopperConfig = function _getPopperConfig() {
  3385. var popperConfig = {
  3386. placement: this._getPlacement(),
  3387. modifiers: {
  3388. offset: this._getOffset(),
  3389. flip: {
  3390. enabled: this._config.flip
  3391. },
  3392. preventOverflow: {
  3393. boundariesElement: this._config.boundary
  3394. }
  3395. }
  3396. }; // Disable Popper.js if we have a static display
  3397. if (this._config.display === 'static') {
  3398. popperConfig.modifiers.applyStyle = {
  3399. enabled: false
  3400. };
  3401. }
  3402. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3403. } // Static
  3404. ;
  3405. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3406. return this.each(function () {
  3407. var data = $(this).data(DATA_KEY$4);
  3408. var _config = typeof config === 'object' ? config : null;
  3409. if (!data) {
  3410. data = new Dropdown(this, _config);
  3411. $(this).data(DATA_KEY$4, data);
  3412. }
  3413. if (typeof config === 'string') {
  3414. if (typeof data[config] === 'undefined') {
  3415. throw new TypeError("No method named \"" + config + "\"");
  3416. }
  3417. data[config]();
  3418. }
  3419. });
  3420. };
  3421. Dropdown._clearMenus = function _clearMenus(event) {
  3422. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3423. return;
  3424. }
  3425. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3426. for (var i = 0, len = toggles.length; i < len; i++) {
  3427. var parent = Dropdown._getParentFromElement(toggles[i]);
  3428. var context = $(toggles[i]).data(DATA_KEY$4);
  3429. var relatedTarget = {
  3430. relatedTarget: toggles[i]
  3431. };
  3432. if (event && event.type === 'click') {
  3433. relatedTarget.clickEvent = event;
  3434. }
  3435. if (!context) {
  3436. continue;
  3437. }
  3438. var dropdownMenu = context._menu;
  3439. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3440. continue;
  3441. }
  3442. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3443. continue;
  3444. }
  3445. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3446. $(parent).trigger(hideEvent);
  3447. if (hideEvent.isDefaultPrevented()) {
  3448. continue;
  3449. } // If this is a touch-enabled device we remove the extra
  3450. // empty mouseover listeners we added for iOS support
  3451. if ('ontouchstart' in document.documentElement) {
  3452. $(document.body).children().off('mouseover', null, $.noop);
  3453. }
  3454. toggles[i].setAttribute('aria-expanded', 'false');
  3455. if (context._popper) {
  3456. context._popper.destroy();
  3457. }
  3458. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3459. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3460. }
  3461. };
  3462. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3463. var parent;
  3464. var selector = Util.getSelectorFromElement(element);
  3465. if (selector) {
  3466. parent = document.querySelector(selector);
  3467. }
  3468. return parent || element.parentNode;
  3469. } // eslint-disable-next-line complexity
  3470. ;
  3471. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3472. // If not input/textarea:
  3473. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3474. // If input/textarea:
  3475. // - If space key => not a dropdown command
  3476. // - If key is other than escape
  3477. // - If key is not up or down => not a dropdown command
  3478. // - If trigger inside the menu => not a dropdown command
  3479. 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)) {
  3480. return;
  3481. }
  3482. event.preventDefault();
  3483. event.stopPropagation();
  3484. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3485. return;
  3486. }
  3487. var parent = Dropdown._getParentFromElement(this);
  3488. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3489. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3490. return;
  3491. }
  3492. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3493. if (event.which === ESCAPE_KEYCODE) {
  3494. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3495. $(toggle).trigger('focus');
  3496. }
  3497. $(this).trigger('click');
  3498. return;
  3499. }
  3500. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3501. return $(item).is(':visible');
  3502. });
  3503. if (items.length === 0) {
  3504. return;
  3505. }
  3506. var index = items.indexOf(event.target);
  3507. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3508. // Up
  3509. index--;
  3510. }
  3511. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3512. // Down
  3513. index++;
  3514. }
  3515. if (index < 0) {
  3516. index = 0;
  3517. }
  3518. items[index].focus();
  3519. };
  3520. _createClass(Dropdown, null, [{
  3521. key: "VERSION",
  3522. get: function get() {
  3523. return VERSION$4;
  3524. }
  3525. }, {
  3526. key: "Default",
  3527. get: function get() {
  3528. return Default$2;
  3529. }
  3530. }, {
  3531. key: "DefaultType",
  3532. get: function get() {
  3533. return DefaultType$2;
  3534. }
  3535. }]);
  3536. return Dropdown;
  3537. }();
  3538. /**
  3539. * ------------------------------------------------------------------------
  3540. * Data Api implementation
  3541. * ------------------------------------------------------------------------
  3542. */
  3543. $(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) {
  3544. event.preventDefault();
  3545. event.stopPropagation();
  3546. Dropdown._jQueryInterface.call($(this), 'toggle');
  3547. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3548. e.stopPropagation();
  3549. });
  3550. /**
  3551. * ------------------------------------------------------------------------
  3552. * jQuery
  3553. * ------------------------------------------------------------------------
  3554. */
  3555. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3556. $.fn[NAME$4].Constructor = Dropdown;
  3557. $.fn[NAME$4].noConflict = function () {
  3558. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3559. return Dropdown._jQueryInterface;
  3560. };
  3561. /**
  3562. * ------------------------------------------------------------------------
  3563. * Constants
  3564. * ------------------------------------------------------------------------
  3565. */
  3566. var NAME$5 = 'modal';
  3567. var VERSION$5 = '4.4.1';
  3568. var DATA_KEY$5 = 'bs.modal';
  3569. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3570. var DATA_API_KEY$5 = '.data-api';
  3571. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3572. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3573. var Default$3 = {
  3574. backdrop: true,
  3575. keyboard: true,
  3576. focus: true,
  3577. show: true
  3578. };
  3579. var DefaultType$3 = {
  3580. backdrop: '(boolean|string)',
  3581. keyboard: 'boolean',
  3582. focus: 'boolean',
  3583. show: 'boolean'
  3584. };
  3585. var Event$5 = {
  3586. HIDE: "hide" + EVENT_KEY$5,
  3587. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3588. HIDDEN: "hidden" + EVENT_KEY$5,
  3589. SHOW: "show" + EVENT_KEY$5,
  3590. SHOWN: "shown" + EVENT_KEY$5,
  3591. FOCUSIN: "focusin" + EVENT_KEY$5,
  3592. RESIZE: "resize" + EVENT_KEY$5,
  3593. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3594. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3595. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3596. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3597. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3598. };
  3599. var ClassName$5 = {
  3600. SCROLLABLE: 'modal-dialog-scrollable',
  3601. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3602. BACKDROP: 'modal-backdrop',
  3603. OPEN: 'modal-open',
  3604. FADE: 'fade',
  3605. SHOW: 'show',
  3606. STATIC: 'modal-static'
  3607. };
  3608. var Selector$5 = {
  3609. DIALOG: '.modal-dialog',
  3610. MODAL_BODY: '.modal-body',
  3611. DATA_TOGGLE: '[data-toggle="modal"]',
  3612. DATA_DISMISS: '[data-dismiss="modal"]',
  3613. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3614. STICKY_CONTENT: '.sticky-top'
  3615. };
  3616. /**
  3617. * ------------------------------------------------------------------------
  3618. * Class Definition
  3619. * ------------------------------------------------------------------------
  3620. */
  3621. var Modal =
  3622. /*#__PURE__*/
  3623. function () {
  3624. function Modal(element, config) {
  3625. this._config = this._getConfig(config);
  3626. this._element = element;
  3627. this._dialog = element.querySelector(Selector$5.DIALOG);
  3628. this._backdrop = null;
  3629. this._isShown = false;
  3630. this._isBodyOverflowing = false;
  3631. this._ignoreBackdropClick = false;
  3632. this._isTransitioning = false;
  3633. this._scrollbarWidth = 0;
  3634. } // Getters
  3635. var _proto = Modal.prototype;
  3636. // Public
  3637. _proto.toggle = function toggle(relatedTarget) {
  3638. return this._isShown ? this.hide() : this.show(relatedTarget);
  3639. };
  3640. _proto.show = function show(relatedTarget) {
  3641. var _this = this;
  3642. if (this._isShown || this._isTransitioning) {
  3643. return;
  3644. }
  3645. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3646. this._isTransitioning = true;
  3647. }
  3648. var showEvent = $.Event(Event$5.SHOW, {
  3649. relatedTarget: relatedTarget
  3650. });
  3651. $(this._element).trigger(showEvent);
  3652. if (this._isShown || showEvent.isDefaultPrevented()) {
  3653. return;
  3654. }
  3655. this._isShown = true;
  3656. this._checkScrollbar();
  3657. this._setScrollbar();
  3658. this._adjustDialog();
  3659. this._setEscapeEvent();
  3660. this._setResizeEvent();
  3661. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3662. return _this.hide(event);
  3663. });
  3664. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3665. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3666. if ($(event.target).is(_this._element)) {
  3667. _this._ignoreBackdropClick = true;
  3668. }
  3669. });
  3670. });
  3671. this._showBackdrop(function () {
  3672. return _this._showElement(relatedTarget);
  3673. });
  3674. };
  3675. _proto.hide = function hide(event) {
  3676. var _this2 = this;
  3677. if (event) {
  3678. event.preventDefault();
  3679. }
  3680. if (!this._isShown || this._isTransitioning) {
  3681. return;
  3682. }
  3683. var hideEvent = $.Event(Event$5.HIDE);
  3684. $(this._element).trigger(hideEvent);
  3685. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3686. return;
  3687. }
  3688. this._isShown = false;
  3689. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3690. if (transition) {
  3691. this._isTransitioning = true;
  3692. }
  3693. this._setEscapeEvent();
  3694. this._setResizeEvent();
  3695. $(document).off(Event$5.FOCUSIN);
  3696. $(this._element).removeClass(ClassName$5.SHOW);
  3697. $(this._element).off(Event$5.CLICK_DISMISS);
  3698. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3699. if (transition) {
  3700. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3701. $(this._element).one(Util.TRANSITION_END, function (event) {
  3702. return _this2._hideModal(event);
  3703. }).emulateTransitionEnd(transitionDuration);
  3704. } else {
  3705. this._hideModal();
  3706. }
  3707. };
  3708. _proto.dispose = function dispose() {
  3709. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3710. return $(htmlElement).off(EVENT_KEY$5);
  3711. });
  3712. /**
  3713. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3714. * Do not move `document` in `htmlElements` array
  3715. * It will remove `Event.CLICK_DATA_API` event that should remain
  3716. */
  3717. $(document).off(Event$5.FOCUSIN);
  3718. $.removeData(this._element, DATA_KEY$5);
  3719. this._config = null;
  3720. this._element = null;
  3721. this._dialog = null;
  3722. this._backdrop = null;
  3723. this._isShown = null;
  3724. this._isBodyOverflowing = null;
  3725. this._ignoreBackdropClick = null;
  3726. this._isTransitioning = null;
  3727. this._scrollbarWidth = null;
  3728. };
  3729. _proto.handleUpdate = function handleUpdate() {
  3730. this._adjustDialog();
  3731. } // Private
  3732. ;
  3733. _proto._getConfig = function _getConfig(config) {
  3734. config = _objectSpread2({}, Default$3, {}, config);
  3735. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3736. return config;
  3737. };
  3738. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3739. var _this3 = this;
  3740. if (this._config.backdrop === 'static') {
  3741. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3742. $(this._element).trigger(hideEventPrevented);
  3743. if (hideEventPrevented.defaultPrevented) {
  3744. return;
  3745. }
  3746. this._element.classList.add(ClassName$5.STATIC);
  3747. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3748. $(this._element).one(Util.TRANSITION_END, function () {
  3749. _this3._element.classList.remove(ClassName$5.STATIC);
  3750. }).emulateTransitionEnd(modalTransitionDuration);
  3751. this._element.focus();
  3752. } else {
  3753. this.hide();
  3754. }
  3755. };
  3756. _proto._showElement = function _showElement(relatedTarget) {
  3757. var _this4 = this;
  3758. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3759. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3760. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3761. // Don't move modal's DOM position
  3762. document.body.appendChild(this._element);
  3763. }
  3764. this._element.style.display = 'block';
  3765. this._element.removeAttribute('aria-hidden');
  3766. this._element.setAttribute('aria-modal', true);
  3767. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3768. modalBody.scrollTop = 0;
  3769. } else {
  3770. this._element.scrollTop = 0;
  3771. }
  3772. if (transition) {
  3773. Util.reflow(this._element);
  3774. }
  3775. $(this._element).addClass(ClassName$5.SHOW);
  3776. if (this._config.focus) {
  3777. this._enforceFocus();
  3778. }
  3779. var shownEvent = $.Event(Event$5.SHOWN, {
  3780. relatedTarget: relatedTarget
  3781. });
  3782. var transitionComplete = function transitionComplete() {
  3783. if (_this4._config.focus) {
  3784. _this4._element.focus();
  3785. }
  3786. _this4._isTransitioning = false;
  3787. $(_this4._element).trigger(shownEvent);
  3788. };
  3789. if (transition) {
  3790. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3791. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3792. } else {
  3793. transitionComplete();
  3794. }
  3795. };
  3796. _proto._enforceFocus = function _enforceFocus() {
  3797. var _this5 = this;
  3798. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3799. .on(Event$5.FOCUSIN, function (event) {
  3800. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3801. _this5._element.focus();
  3802. }
  3803. });
  3804. };
  3805. _proto._setEscapeEvent = function _setEscapeEvent() {
  3806. var _this6 = this;
  3807. if (this._isShown && this._config.keyboard) {
  3808. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3809. if (event.which === ESCAPE_KEYCODE$1) {
  3810. _this6._triggerBackdropTransition();
  3811. }
  3812. });
  3813. } else if (!this._isShown) {
  3814. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3815. }
  3816. };
  3817. _proto._setResizeEvent = function _setResizeEvent() {
  3818. var _this7 = this;
  3819. if (this._isShown) {
  3820. $(window).on(Event$5.RESIZE, function (event) {
  3821. return _this7.handleUpdate(event);
  3822. });
  3823. } else {
  3824. $(window).off(Event$5.RESIZE);
  3825. }
  3826. };
  3827. _proto._hideModal = function _hideModal() {
  3828. var _this8 = this;
  3829. this._element.style.display = 'none';
  3830. this._element.setAttribute('aria-hidden', true);
  3831. this._element.removeAttribute('aria-modal');
  3832. this._isTransitioning = false;
  3833. this._showBackdrop(function () {
  3834. $(document.body).removeClass(ClassName$5.OPEN);
  3835. _this8._resetAdjustments();
  3836. _this8._resetScrollbar();
  3837. $(_this8._element).trigger(Event$5.HIDDEN);
  3838. });
  3839. };
  3840. _proto._removeBackdrop = function _removeBackdrop() {
  3841. if (this._backdrop) {
  3842. $(this._backdrop).remove();
  3843. this._backdrop = null;
  3844. }
  3845. };
  3846. _proto._showBackdrop = function _showBackdrop(callback) {
  3847. var _this9 = this;
  3848. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3849. if (this._isShown && this._config.backdrop) {
  3850. this._backdrop = document.createElement('div');
  3851. this._backdrop.className = ClassName$5.BACKDROP;
  3852. if (animate) {
  3853. this._backdrop.classList.add(animate);
  3854. }
  3855. $(this._backdrop).appendTo(document.body);
  3856. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3857. if (_this9._ignoreBackdropClick) {
  3858. _this9._ignoreBackdropClick = false;
  3859. return;
  3860. }
  3861. if (event.target !== event.currentTarget) {
  3862. return;
  3863. }
  3864. _this9._triggerBackdropTransition();
  3865. });
  3866. if (animate) {
  3867. Util.reflow(this._backdrop);
  3868. }
  3869. $(this._backdrop).addClass(ClassName$5.SHOW);
  3870. if (!callback) {
  3871. return;
  3872. }
  3873. if (!animate) {
  3874. callback();
  3875. return;
  3876. }
  3877. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3878. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3879. } else if (!this._isShown && this._backdrop) {
  3880. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3881. var callbackRemove = function callbackRemove() {
  3882. _this9._removeBackdrop();
  3883. if (callback) {
  3884. callback();
  3885. }
  3886. };
  3887. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3888. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3889. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3890. } else {
  3891. callbackRemove();
  3892. }
  3893. } else if (callback) {
  3894. callback();
  3895. }
  3896. } // ----------------------------------------------------------------------
  3897. // the following methods are used to handle overflowing modals
  3898. // todo (fat): these should probably be refactored out of modal.js
  3899. // ----------------------------------------------------------------------
  3900. ;
  3901. _proto._adjustDialog = function _adjustDialog() {
  3902. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3903. if (!this._isBodyOverflowing && isModalOverflowing) {
  3904. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3905. }
  3906. if (this._isBodyOverflowing && !isModalOverflowing) {
  3907. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3908. }
  3909. };
  3910. _proto._resetAdjustments = function _resetAdjustments() {
  3911. this._element.style.paddingLeft = '';
  3912. this._element.style.paddingRight = '';
  3913. };
  3914. _proto._checkScrollbar = function _checkScrollbar() {
  3915. var rect = document.body.getBoundingClientRect();
  3916. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3917. this._scrollbarWidth = this._getScrollbarWidth();
  3918. };
  3919. _proto._setScrollbar = function _setScrollbar() {
  3920. var _this10 = this;
  3921. if (this._isBodyOverflowing) {
  3922. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3923. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3924. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3925. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3926. $(fixedContent).each(function (index, element) {
  3927. var actualPadding = element.style.paddingRight;
  3928. var calculatedPadding = $(element).css('padding-right');
  3929. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3930. }); // Adjust sticky content margin
  3931. $(stickyContent).each(function (index, element) {
  3932. var actualMargin = element.style.marginRight;
  3933. var calculatedMargin = $(element).css('margin-right');
  3934. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3935. }); // Adjust body padding
  3936. var actualPadding = document.body.style.paddingRight;
  3937. var calculatedPadding = $(document.body).css('padding-right');
  3938. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3939. }
  3940. $(document.body).addClass(ClassName$5.OPEN);
  3941. };
  3942. _proto._resetScrollbar = function _resetScrollbar() {
  3943. // Restore fixed content padding
  3944. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3945. $(fixedContent).each(function (index, element) {
  3946. var padding = $(element).data('padding-right');
  3947. $(element).removeData('padding-right');
  3948. element.style.paddingRight = padding ? padding : '';
  3949. }); // Restore sticky content
  3950. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  3951. $(elements).each(function (index, element) {
  3952. var margin = $(element).data('margin-right');
  3953. if (typeof margin !== 'undefined') {
  3954. $(element).css('margin-right', margin).removeData('margin-right');
  3955. }
  3956. }); // Restore body padding
  3957. var padding = $(document.body).data('padding-right');
  3958. $(document.body).removeData('padding-right');
  3959. document.body.style.paddingRight = padding ? padding : '';
  3960. };
  3961. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3962. // thx d.walsh
  3963. var scrollDiv = document.createElement('div');
  3964. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  3965. document.body.appendChild(scrollDiv);
  3966. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3967. document.body.removeChild(scrollDiv);
  3968. return scrollbarWidth;
  3969. } // Static
  3970. ;
  3971. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3972. return this.each(function () {
  3973. var data = $(this).data(DATA_KEY$5);
  3974. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  3975. if (!data) {
  3976. data = new Modal(this, _config);
  3977. $(this).data(DATA_KEY$5, data);
  3978. }
  3979. if (typeof config === 'string') {
  3980. if (typeof data[config] === 'undefined') {
  3981. throw new TypeError("No method named \"" + config + "\"");
  3982. }
  3983. data[config](relatedTarget);
  3984. } else if (_config.show) {
  3985. data.show(relatedTarget);
  3986. }
  3987. });
  3988. };
  3989. _createClass(Modal, null, [{
  3990. key: "VERSION",
  3991. get: function get() {
  3992. return VERSION$5;
  3993. }
  3994. }, {
  3995. key: "Default",
  3996. get: function get() {
  3997. return Default$3;
  3998. }
  3999. }]);
  4000. return Modal;
  4001. }();
  4002. /**
  4003. * ------------------------------------------------------------------------
  4004. * Data Api implementation
  4005. * ------------------------------------------------------------------------
  4006. */
  4007. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  4008. var _this11 = this;
  4009. var target;
  4010. var selector = Util.getSelectorFromElement(this);
  4011. if (selector) {
  4012. target = document.querySelector(selector);
  4013. }
  4014. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  4015. if (this.tagName === 'A' || this.tagName === 'AREA') {
  4016. event.preventDefault();
  4017. }
  4018. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  4019. if (showEvent.isDefaultPrevented()) {
  4020. // Only register focus restorer if modal will actually get shown
  4021. return;
  4022. }
  4023. $target.one(Event$5.HIDDEN, function () {
  4024. if ($(_this11).is(':visible')) {
  4025. _this11.focus();
  4026. }
  4027. });
  4028. });
  4029. Modal._jQueryInterface.call($(target), config, this);
  4030. });
  4031. /**
  4032. * ------------------------------------------------------------------------
  4033. * jQuery
  4034. * ------------------------------------------------------------------------
  4035. */
  4036. $.fn[NAME$5] = Modal._jQueryInterface;
  4037. $.fn[NAME$5].Constructor = Modal;
  4038. $.fn[NAME$5].noConflict = function () {
  4039. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4040. return Modal._jQueryInterface;
  4041. };
  4042. /**
  4043. * --------------------------------------------------------------------------
  4044. * Bootstrap (v4.4.1): tools/sanitizer.js
  4045. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4046. * --------------------------------------------------------------------------
  4047. */
  4048. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4049. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4050. var DefaultWhitelist = {
  4051. // Global attributes allowed on any supplied element below.
  4052. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4053. a: ['target', 'href', 'title', 'rel'],
  4054. area: [],
  4055. b: [],
  4056. br: [],
  4057. col: [],
  4058. code: [],
  4059. div: [],
  4060. em: [],
  4061. hr: [],
  4062. h1: [],
  4063. h2: [],
  4064. h3: [],
  4065. h4: [],
  4066. h5: [],
  4067. h6: [],
  4068. i: [],
  4069. img: ['src', 'alt', 'title', 'width', 'height'],
  4070. li: [],
  4071. ol: [],
  4072. p: [],
  4073. pre: [],
  4074. s: [],
  4075. small: [],
  4076. span: [],
  4077. sub: [],
  4078. sup: [],
  4079. strong: [],
  4080. u: [],
  4081. ul: []
  4082. };
  4083. /**
  4084. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4085. *
  4086. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4087. */
  4088. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4089. /**
  4090. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4091. *
  4092. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4093. */
  4094. 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;
  4095. function allowedAttribute(attr, allowedAttributeList) {
  4096. var attrName = attr.nodeName.toLowerCase();
  4097. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4098. if (uriAttrs.indexOf(attrName) !== -1) {
  4099. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4100. }
  4101. return true;
  4102. }
  4103. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4104. return attrRegex instanceof RegExp;
  4105. }); // Check if a regular expression validates the attribute.
  4106. for (var i = 0, l = regExp.length; i < l; i++) {
  4107. if (attrName.match(regExp[i])) {
  4108. return true;
  4109. }
  4110. }
  4111. return false;
  4112. }
  4113. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4114. if (unsafeHtml.length === 0) {
  4115. return unsafeHtml;
  4116. }
  4117. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4118. return sanitizeFn(unsafeHtml);
  4119. }
  4120. var domParser = new window.DOMParser();
  4121. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4122. var whitelistKeys = Object.keys(whiteList);
  4123. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4124. var _loop = function _loop(i, len) {
  4125. var el = elements[i];
  4126. var elName = el.nodeName.toLowerCase();
  4127. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4128. el.parentNode.removeChild(el);
  4129. return "continue";
  4130. }
  4131. var attributeList = [].slice.call(el.attributes);
  4132. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4133. attributeList.forEach(function (attr) {
  4134. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4135. el.removeAttribute(attr.nodeName);
  4136. }
  4137. });
  4138. };
  4139. for (var i = 0, len = elements.length; i < len; i++) {
  4140. var _ret = _loop(i);
  4141. if (_ret === "continue") continue;
  4142. }
  4143. return createdDocument.body.innerHTML;
  4144. }
  4145. /**
  4146. * ------------------------------------------------------------------------
  4147. * Constants
  4148. * ------------------------------------------------------------------------
  4149. */
  4150. var NAME$6 = 'tooltip';
  4151. var VERSION$6 = '4.4.1';
  4152. var DATA_KEY$6 = 'bs.tooltip';
  4153. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4154. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4155. var CLASS_PREFIX = 'bs-tooltip';
  4156. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4157. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4158. var DefaultType$4 = {
  4159. animation: 'boolean',
  4160. template: 'string',
  4161. title: '(string|element|function)',
  4162. trigger: 'string',
  4163. delay: '(number|object)',
  4164. html: 'boolean',
  4165. selector: '(string|boolean)',
  4166. placement: '(string|function)',
  4167. offset: '(number|string|function)',
  4168. container: '(string|element|boolean)',
  4169. fallbackPlacement: '(string|array)',
  4170. boundary: '(string|element)',
  4171. sanitize: 'boolean',
  4172. sanitizeFn: '(null|function)',
  4173. whiteList: 'object',
  4174. popperConfig: '(null|object)'
  4175. };
  4176. var AttachmentMap$1 = {
  4177. AUTO: 'auto',
  4178. TOP: 'top',
  4179. RIGHT: 'right',
  4180. BOTTOM: 'bottom',
  4181. LEFT: 'left'
  4182. };
  4183. var Default$4 = {
  4184. animation: true,
  4185. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4186. trigger: 'hover focus',
  4187. title: '',
  4188. delay: 0,
  4189. html: false,
  4190. selector: false,
  4191. placement: 'top',
  4192. offset: 0,
  4193. container: false,
  4194. fallbackPlacement: 'flip',
  4195. boundary: 'scrollParent',
  4196. sanitize: true,
  4197. sanitizeFn: null,
  4198. whiteList: DefaultWhitelist,
  4199. popperConfig: null
  4200. };
  4201. var HoverState = {
  4202. SHOW: 'show',
  4203. OUT: 'out'
  4204. };
  4205. var Event$6 = {
  4206. HIDE: "hide" + EVENT_KEY$6,
  4207. HIDDEN: "hidden" + EVENT_KEY$6,
  4208. SHOW: "show" + EVENT_KEY$6,
  4209. SHOWN: "shown" + EVENT_KEY$6,
  4210. INSERTED: "inserted" + EVENT_KEY$6,
  4211. CLICK: "click" + EVENT_KEY$6,
  4212. FOCUSIN: "focusin" + EVENT_KEY$6,
  4213. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4214. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4215. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4216. };
  4217. var ClassName$6 = {
  4218. FADE: 'fade',
  4219. SHOW: 'show'
  4220. };
  4221. var Selector$6 = {
  4222. TOOLTIP: '.tooltip',
  4223. TOOLTIP_INNER: '.tooltip-inner',
  4224. ARROW: '.arrow'
  4225. };
  4226. var Trigger = {
  4227. HOVER: 'hover',
  4228. FOCUS: 'focus',
  4229. CLICK: 'click',
  4230. MANUAL: 'manual'
  4231. };
  4232. /**
  4233. * ------------------------------------------------------------------------
  4234. * Class Definition
  4235. * ------------------------------------------------------------------------
  4236. */
  4237. var Tooltip =
  4238. /*#__PURE__*/
  4239. function () {
  4240. function Tooltip(element, config) {
  4241. if (typeof Popper === 'undefined') {
  4242. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4243. } // private
  4244. this._isEnabled = true;
  4245. this._timeout = 0;
  4246. this._hoverState = '';
  4247. this._activeTrigger = {};
  4248. this._popper = null; // Protected
  4249. this.element = element;
  4250. this.config = this._getConfig(config);
  4251. this.tip = null;
  4252. this._setListeners();
  4253. } // Getters
  4254. var _proto = Tooltip.prototype;
  4255. // Public
  4256. _proto.enable = function enable() {
  4257. this._isEnabled = true;
  4258. };
  4259. _proto.disable = function disable() {
  4260. this._isEnabled = false;
  4261. };
  4262. _proto.toggleEnabled = function toggleEnabled() {
  4263. this._isEnabled = !this._isEnabled;
  4264. };
  4265. _proto.toggle = function toggle(event) {
  4266. if (!this._isEnabled) {
  4267. return;
  4268. }
  4269. if (event) {
  4270. var dataKey = this.constructor.DATA_KEY;
  4271. var context = $(event.currentTarget).data(dataKey);
  4272. if (!context) {
  4273. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4274. $(event.currentTarget).data(dataKey, context);
  4275. }
  4276. context._activeTrigger.click = !context._activeTrigger.click;
  4277. if (context._isWithActiveTrigger()) {
  4278. context._enter(null, context);
  4279. } else {
  4280. context._leave(null, context);
  4281. }
  4282. } else {
  4283. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4284. this._leave(null, this);
  4285. return;
  4286. }
  4287. this._enter(null, this);
  4288. }
  4289. };
  4290. _proto.dispose = function dispose() {
  4291. clearTimeout(this._timeout);
  4292. $.removeData(this.element, this.constructor.DATA_KEY);
  4293. $(this.element).off(this.constructor.EVENT_KEY);
  4294. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4295. if (this.tip) {
  4296. $(this.tip).remove();
  4297. }
  4298. this._isEnabled = null;
  4299. this._timeout = null;
  4300. this._hoverState = null;
  4301. this._activeTrigger = null;
  4302. if (this._popper) {
  4303. this._popper.destroy();
  4304. }
  4305. this._popper = null;
  4306. this.element = null;
  4307. this.config = null;
  4308. this.tip = null;
  4309. };
  4310. _proto.show = function show() {
  4311. var _this = this;
  4312. if ($(this.element).css('display') === 'none') {
  4313. throw new Error('Please use show on visible elements');
  4314. }
  4315. var showEvent = $.Event(this.constructor.Event.SHOW);
  4316. if (this.isWithContent() && this._isEnabled) {
  4317. $(this.element).trigger(showEvent);
  4318. var shadowRoot = Util.findShadowRoot(this.element);
  4319. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4320. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4321. return;
  4322. }
  4323. var tip = this.getTipElement();
  4324. var tipId = Util.getUID(this.constructor.NAME);
  4325. tip.setAttribute('id', tipId);
  4326. this.element.setAttribute('aria-describedby', tipId);
  4327. this.setContent();
  4328. if (this.config.animation) {
  4329. $(tip).addClass(ClassName$6.FADE);
  4330. }
  4331. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4332. var attachment = this._getAttachment(placement);
  4333. this.addAttachmentClass(attachment);
  4334. var container = this._getContainer();
  4335. $(tip).data(this.constructor.DATA_KEY, this);
  4336. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4337. $(tip).appendTo(container);
  4338. }
  4339. $(this.element).trigger(this.constructor.Event.INSERTED);
  4340. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4341. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4342. // empty mouseover listeners to the body's immediate children;
  4343. // only needed because of broken event delegation on iOS
  4344. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4345. if ('ontouchstart' in document.documentElement) {
  4346. $(document.body).children().on('mouseover', null, $.noop);
  4347. }
  4348. var complete = function complete() {
  4349. if (_this.config.animation) {
  4350. _this._fixTransition();
  4351. }
  4352. var prevHoverState = _this._hoverState;
  4353. _this._hoverState = null;
  4354. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4355. if (prevHoverState === HoverState.OUT) {
  4356. _this._leave(null, _this);
  4357. }
  4358. };
  4359. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4360. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4361. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4362. } else {
  4363. complete();
  4364. }
  4365. }
  4366. };
  4367. _proto.hide = function hide(callback) {
  4368. var _this2 = this;
  4369. var tip = this.getTipElement();
  4370. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4371. var complete = function complete() {
  4372. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4373. tip.parentNode.removeChild(tip);
  4374. }
  4375. _this2._cleanTipClass();
  4376. _this2.element.removeAttribute('aria-describedby');
  4377. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4378. if (_this2._popper !== null) {
  4379. _this2._popper.destroy();
  4380. }
  4381. if (callback) {
  4382. callback();
  4383. }
  4384. };
  4385. $(this.element).trigger(hideEvent);
  4386. if (hideEvent.isDefaultPrevented()) {
  4387. return;
  4388. }
  4389. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4390. // empty mouseover listeners we added for iOS support
  4391. if ('ontouchstart' in document.documentElement) {
  4392. $(document.body).children().off('mouseover', null, $.noop);
  4393. }
  4394. this._activeTrigger[Trigger.CLICK] = false;
  4395. this._activeTrigger[Trigger.FOCUS] = false;
  4396. this._activeTrigger[Trigger.HOVER] = false;
  4397. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4398. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4399. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4400. } else {
  4401. complete();
  4402. }
  4403. this._hoverState = '';
  4404. };
  4405. _proto.update = function update() {
  4406. if (this._popper !== null) {
  4407. this._popper.scheduleUpdate();
  4408. }
  4409. } // Protected
  4410. ;
  4411. _proto.isWithContent = function isWithContent() {
  4412. return Boolean(this.getTitle());
  4413. };
  4414. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4415. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4416. };
  4417. _proto.getTipElement = function getTipElement() {
  4418. this.tip = this.tip || $(this.config.template)[0];
  4419. return this.tip;
  4420. };
  4421. _proto.setContent = function setContent() {
  4422. var tip = this.getTipElement();
  4423. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4424. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4425. };
  4426. _proto.setElementContent = function setElementContent($element, content) {
  4427. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4428. // Content is a DOM node or a jQuery
  4429. if (this.config.html) {
  4430. if (!$(content).parent().is($element)) {
  4431. $element.empty().append(content);
  4432. }
  4433. } else {
  4434. $element.text($(content).text());
  4435. }
  4436. return;
  4437. }
  4438. if (this.config.html) {
  4439. if (this.config.sanitize) {
  4440. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4441. }
  4442. $element.html(content);
  4443. } else {
  4444. $element.text(content);
  4445. }
  4446. };
  4447. _proto.getTitle = function getTitle() {
  4448. var title = this.element.getAttribute('data-original-title');
  4449. if (!title) {
  4450. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4451. }
  4452. return title;
  4453. } // Private
  4454. ;
  4455. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4456. var _this3 = this;
  4457. var defaultBsConfig = {
  4458. placement: attachment,
  4459. modifiers: {
  4460. offset: this._getOffset(),
  4461. flip: {
  4462. behavior: this.config.fallbackPlacement
  4463. },
  4464. arrow: {
  4465. element: Selector$6.ARROW
  4466. },
  4467. preventOverflow: {
  4468. boundariesElement: this.config.boundary
  4469. }
  4470. },
  4471. onCreate: function onCreate(data) {
  4472. if (data.originalPlacement !== data.placement) {
  4473. _this3._handlePopperPlacementChange(data);
  4474. }
  4475. },
  4476. onUpdate: function onUpdate(data) {
  4477. return _this3._handlePopperPlacementChange(data);
  4478. }
  4479. };
  4480. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4481. };
  4482. _proto._getOffset = function _getOffset() {
  4483. var _this4 = this;
  4484. var offset = {};
  4485. if (typeof this.config.offset === 'function') {
  4486. offset.fn = function (data) {
  4487. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4488. return data;
  4489. };
  4490. } else {
  4491. offset.offset = this.config.offset;
  4492. }
  4493. return offset;
  4494. };
  4495. _proto._getContainer = function _getContainer() {
  4496. if (this.config.container === false) {
  4497. return document.body;
  4498. }
  4499. if (Util.isElement(this.config.container)) {
  4500. return $(this.config.container);
  4501. }
  4502. return $(document).find(this.config.container);
  4503. };
  4504. _proto._getAttachment = function _getAttachment(placement) {
  4505. return AttachmentMap$1[placement.toUpperCase()];
  4506. };
  4507. _proto._setListeners = function _setListeners() {
  4508. var _this5 = this;
  4509. var triggers = this.config.trigger.split(' ');
  4510. triggers.forEach(function (trigger) {
  4511. if (trigger === 'click') {
  4512. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4513. return _this5.toggle(event);
  4514. });
  4515. } else if (trigger !== Trigger.MANUAL) {
  4516. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4517. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4518. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4519. return _this5._enter(event);
  4520. }).on(eventOut, _this5.config.selector, function (event) {
  4521. return _this5._leave(event);
  4522. });
  4523. }
  4524. });
  4525. this._hideModalHandler = function () {
  4526. if (_this5.element) {
  4527. _this5.hide();
  4528. }
  4529. };
  4530. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4531. if (this.config.selector) {
  4532. this.config = _objectSpread2({}, this.config, {
  4533. trigger: 'manual',
  4534. selector: ''
  4535. });
  4536. } else {
  4537. this._fixTitle();
  4538. }
  4539. };
  4540. _proto._fixTitle = function _fixTitle() {
  4541. var titleType = typeof this.element.getAttribute('data-original-title');
  4542. if (this.element.getAttribute('title') || titleType !== 'string') {
  4543. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4544. this.element.setAttribute('title', '');
  4545. }
  4546. };
  4547. _proto._enter = function _enter(event, context) {
  4548. var dataKey = this.constructor.DATA_KEY;
  4549. context = context || $(event.currentTarget).data(dataKey);
  4550. if (!context) {
  4551. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4552. $(event.currentTarget).data(dataKey, context);
  4553. }
  4554. if (event) {
  4555. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4556. }
  4557. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4558. context._hoverState = HoverState.SHOW;
  4559. return;
  4560. }
  4561. clearTimeout(context._timeout);
  4562. context._hoverState = HoverState.SHOW;
  4563. if (!context.config.delay || !context.config.delay.show) {
  4564. context.show();
  4565. return;
  4566. }
  4567. context._timeout = setTimeout(function () {
  4568. if (context._hoverState === HoverState.SHOW) {
  4569. context.show();
  4570. }
  4571. }, context.config.delay.show);
  4572. };
  4573. _proto._leave = function _leave(event, context) {
  4574. var dataKey = this.constructor.DATA_KEY;
  4575. context = context || $(event.currentTarget).data(dataKey);
  4576. if (!context) {
  4577. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4578. $(event.currentTarget).data(dataKey, context);
  4579. }
  4580. if (event) {
  4581. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4582. }
  4583. if (context._isWithActiveTrigger()) {
  4584. return;
  4585. }
  4586. clearTimeout(context._timeout);
  4587. context._hoverState = HoverState.OUT;
  4588. if (!context.config.delay || !context.config.delay.hide) {
  4589. context.hide();
  4590. return;
  4591. }
  4592. context._timeout = setTimeout(function () {
  4593. if (context._hoverState === HoverState.OUT) {
  4594. context.hide();
  4595. }
  4596. }, context.config.delay.hide);
  4597. };
  4598. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4599. for (var trigger in this._activeTrigger) {
  4600. if (this._activeTrigger[trigger]) {
  4601. return true;
  4602. }
  4603. }
  4604. return false;
  4605. };
  4606. _proto._getConfig = function _getConfig(config) {
  4607. var dataAttributes = $(this.element).data();
  4608. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4609. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4610. delete dataAttributes[dataAttr];
  4611. }
  4612. });
  4613. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4614. if (typeof config.delay === 'number') {
  4615. config.delay = {
  4616. show: config.delay,
  4617. hide: config.delay
  4618. };
  4619. }
  4620. if (typeof config.title === 'number') {
  4621. config.title = config.title.toString();
  4622. }
  4623. if (typeof config.content === 'number') {
  4624. config.content = config.content.toString();
  4625. }
  4626. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4627. if (config.sanitize) {
  4628. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4629. }
  4630. return config;
  4631. };
  4632. _proto._getDelegateConfig = function _getDelegateConfig() {
  4633. var config = {};
  4634. if (this.config) {
  4635. for (var key in this.config) {
  4636. if (this.constructor.Default[key] !== this.config[key]) {
  4637. config[key] = this.config[key];
  4638. }
  4639. }
  4640. }
  4641. return config;
  4642. };
  4643. _proto._cleanTipClass = function _cleanTipClass() {
  4644. var $tip = $(this.getTipElement());
  4645. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4646. if (tabClass !== null && tabClass.length) {
  4647. $tip.removeClass(tabClass.join(''));
  4648. }
  4649. };
  4650. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4651. var popperInstance = popperData.instance;
  4652. this.tip = popperInstance.popper;
  4653. this._cleanTipClass();
  4654. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4655. };
  4656. _proto._fixTransition = function _fixTransition() {
  4657. var tip = this.getTipElement();
  4658. var initConfigAnimation = this.config.animation;
  4659. if (tip.getAttribute('x-placement') !== null) {
  4660. return;
  4661. }
  4662. $(tip).removeClass(ClassName$6.FADE);
  4663. this.config.animation = false;
  4664. this.hide();
  4665. this.show();
  4666. this.config.animation = initConfigAnimation;
  4667. } // Static
  4668. ;
  4669. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4670. return this.each(function () {
  4671. var data = $(this).data(DATA_KEY$6);
  4672. var _config = typeof config === 'object' && config;
  4673. if (!data && /dispose|hide/.test(config)) {
  4674. return;
  4675. }
  4676. if (!data) {
  4677. data = new Tooltip(this, _config);
  4678. $(this).data(DATA_KEY$6, data);
  4679. }
  4680. if (typeof config === 'string') {
  4681. if (typeof data[config] === 'undefined') {
  4682. throw new TypeError("No method named \"" + config + "\"");
  4683. }
  4684. data[config]();
  4685. }
  4686. });
  4687. };
  4688. _createClass(Tooltip, null, [{
  4689. key: "VERSION",
  4690. get: function get() {
  4691. return VERSION$6;
  4692. }
  4693. }, {
  4694. key: "Default",
  4695. get: function get() {
  4696. return Default$4;
  4697. }
  4698. }, {
  4699. key: "NAME",
  4700. get: function get() {
  4701. return NAME$6;
  4702. }
  4703. }, {
  4704. key: "DATA_KEY",
  4705. get: function get() {
  4706. return DATA_KEY$6;
  4707. }
  4708. }, {
  4709. key: "Event",
  4710. get: function get() {
  4711. return Event$6;
  4712. }
  4713. }, {
  4714. key: "EVENT_KEY",
  4715. get: function get() {
  4716. return EVENT_KEY$6;
  4717. }
  4718. }, {
  4719. key: "DefaultType",
  4720. get: function get() {
  4721. return DefaultType$4;
  4722. }
  4723. }]);
  4724. return Tooltip;
  4725. }();
  4726. /**
  4727. * ------------------------------------------------------------------------
  4728. * jQuery
  4729. * ------------------------------------------------------------------------
  4730. */
  4731. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4732. $.fn[NAME$6].Constructor = Tooltip;
  4733. $.fn[NAME$6].noConflict = function () {
  4734. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4735. return Tooltip._jQueryInterface;
  4736. };
  4737. /**
  4738. * ------------------------------------------------------------------------
  4739. * Constants
  4740. * ------------------------------------------------------------------------
  4741. */
  4742. var NAME$7 = 'popover';
  4743. var VERSION$7 = '4.4.1';
  4744. var DATA_KEY$7 = 'bs.popover';
  4745. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4746. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4747. var CLASS_PREFIX$1 = 'bs-popover';
  4748. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4749. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4750. placement: 'right',
  4751. trigger: 'click',
  4752. content: '',
  4753. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4754. });
  4755. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4756. content: '(string|element|function)'
  4757. });
  4758. var ClassName$7 = {
  4759. FADE: 'fade',
  4760. SHOW: 'show'
  4761. };
  4762. var Selector$7 = {
  4763. TITLE: '.popover-header',
  4764. CONTENT: '.popover-body'
  4765. };
  4766. var Event$7 = {
  4767. HIDE: "hide" + EVENT_KEY$7,
  4768. HIDDEN: "hidden" + EVENT_KEY$7,
  4769. SHOW: "show" + EVENT_KEY$7,
  4770. SHOWN: "shown" + EVENT_KEY$7,
  4771. INSERTED: "inserted" + EVENT_KEY$7,
  4772. CLICK: "click" + EVENT_KEY$7,
  4773. FOCUSIN: "focusin" + EVENT_KEY$7,
  4774. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4775. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4776. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4777. };
  4778. /**
  4779. * ------------------------------------------------------------------------
  4780. * Class Definition
  4781. * ------------------------------------------------------------------------
  4782. */
  4783. var Popover =
  4784. /*#__PURE__*/
  4785. function (_Tooltip) {
  4786. _inheritsLoose(Popover, _Tooltip);
  4787. function Popover() {
  4788. return _Tooltip.apply(this, arguments) || this;
  4789. }
  4790. var _proto = Popover.prototype;
  4791. // Overrides
  4792. _proto.isWithContent = function isWithContent() {
  4793. return this.getTitle() || this._getContent();
  4794. };
  4795. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4796. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4797. };
  4798. _proto.getTipElement = function getTipElement() {
  4799. this.tip = this.tip || $(this.config.template)[0];
  4800. return this.tip;
  4801. };
  4802. _proto.setContent = function setContent() {
  4803. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4804. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4805. var content = this._getContent();
  4806. if (typeof content === 'function') {
  4807. content = content.call(this.element);
  4808. }
  4809. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4810. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4811. } // Private
  4812. ;
  4813. _proto._getContent = function _getContent() {
  4814. return this.element.getAttribute('data-content') || this.config.content;
  4815. };
  4816. _proto._cleanTipClass = function _cleanTipClass() {
  4817. var $tip = $(this.getTipElement());
  4818. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4819. if (tabClass !== null && tabClass.length > 0) {
  4820. $tip.removeClass(tabClass.join(''));
  4821. }
  4822. } // Static
  4823. ;
  4824. Popover._jQueryInterface = function _jQueryInterface(config) {
  4825. return this.each(function () {
  4826. var data = $(this).data(DATA_KEY$7);
  4827. var _config = typeof config === 'object' ? config : null;
  4828. if (!data && /dispose|hide/.test(config)) {
  4829. return;
  4830. }
  4831. if (!data) {
  4832. data = new Popover(this, _config);
  4833. $(this).data(DATA_KEY$7, data);
  4834. }
  4835. if (typeof config === 'string') {
  4836. if (typeof data[config] === 'undefined') {
  4837. throw new TypeError("No method named \"" + config + "\"");
  4838. }
  4839. data[config]();
  4840. }
  4841. });
  4842. };
  4843. _createClass(Popover, null, [{
  4844. key: "VERSION",
  4845. // Getters
  4846. get: function get() {
  4847. return VERSION$7;
  4848. }
  4849. }, {
  4850. key: "Default",
  4851. get: function get() {
  4852. return Default$5;
  4853. }
  4854. }, {
  4855. key: "NAME",
  4856. get: function get() {
  4857. return NAME$7;
  4858. }
  4859. }, {
  4860. key: "DATA_KEY",
  4861. get: function get() {
  4862. return DATA_KEY$7;
  4863. }
  4864. }, {
  4865. key: "Event",
  4866. get: function get() {
  4867. return Event$7;
  4868. }
  4869. }, {
  4870. key: "EVENT_KEY",
  4871. get: function get() {
  4872. return EVENT_KEY$7;
  4873. }
  4874. }, {
  4875. key: "DefaultType",
  4876. get: function get() {
  4877. return DefaultType$5;
  4878. }
  4879. }]);
  4880. return Popover;
  4881. }(Tooltip);
  4882. /**
  4883. * ------------------------------------------------------------------------
  4884. * jQuery
  4885. * ------------------------------------------------------------------------
  4886. */
  4887. $.fn[NAME$7] = Popover._jQueryInterface;
  4888. $.fn[NAME$7].Constructor = Popover;
  4889. $.fn[NAME$7].noConflict = function () {
  4890. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4891. return Popover._jQueryInterface;
  4892. };
  4893. /**
  4894. * ------------------------------------------------------------------------
  4895. * Constants
  4896. * ------------------------------------------------------------------------
  4897. */
  4898. var NAME$8 = 'scrollspy';
  4899. var VERSION$8 = '4.4.1';
  4900. var DATA_KEY$8 = 'bs.scrollspy';
  4901. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4902. var DATA_API_KEY$6 = '.data-api';
  4903. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4904. var Default$6 = {
  4905. offset: 10,
  4906. method: 'auto',
  4907. target: ''
  4908. };
  4909. var DefaultType$6 = {
  4910. offset: 'number',
  4911. method: 'string',
  4912. target: '(string|element)'
  4913. };
  4914. var Event$8 = {
  4915. ACTIVATE: "activate" + EVENT_KEY$8,
  4916. SCROLL: "scroll" + EVENT_KEY$8,
  4917. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4918. };
  4919. var ClassName$8 = {
  4920. DROPDOWN_ITEM: 'dropdown-item',
  4921. DROPDOWN_MENU: 'dropdown-menu',
  4922. ACTIVE: 'active'
  4923. };
  4924. var Selector$8 = {
  4925. DATA_SPY: '[data-spy="scroll"]',
  4926. ACTIVE: '.active',
  4927. NAV_LIST_GROUP: '.nav, .list-group',
  4928. NAV_LINKS: '.nav-link',
  4929. NAV_ITEMS: '.nav-item',
  4930. LIST_ITEMS: '.list-group-item',
  4931. DROPDOWN: '.dropdown',
  4932. DROPDOWN_ITEMS: '.dropdown-item',
  4933. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4934. };
  4935. var OffsetMethod = {
  4936. OFFSET: 'offset',
  4937. POSITION: 'position'
  4938. };
  4939. /**
  4940. * ------------------------------------------------------------------------
  4941. * Class Definition
  4942. * ------------------------------------------------------------------------
  4943. */
  4944. var ScrollSpy =
  4945. /*#__PURE__*/
  4946. function () {
  4947. function ScrollSpy(element, config) {
  4948. var _this = this;
  4949. this._element = element;
  4950. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4951. this._config = this._getConfig(config);
  4952. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  4953. this._offsets = [];
  4954. this._targets = [];
  4955. this._activeTarget = null;
  4956. this._scrollHeight = 0;
  4957. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  4958. return _this._process(event);
  4959. });
  4960. this.refresh();
  4961. this._process();
  4962. } // Getters
  4963. var _proto = ScrollSpy.prototype;
  4964. // Public
  4965. _proto.refresh = function refresh() {
  4966. var _this2 = this;
  4967. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  4968. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4969. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  4970. this._offsets = [];
  4971. this._targets = [];
  4972. this._scrollHeight = this._getScrollHeight();
  4973. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4974. targets.map(function (element) {
  4975. var target;
  4976. var targetSelector = Util.getSelectorFromElement(element);
  4977. if (targetSelector) {
  4978. target = document.querySelector(targetSelector);
  4979. }
  4980. if (target) {
  4981. var targetBCR = target.getBoundingClientRect();
  4982. if (targetBCR.width || targetBCR.height) {
  4983. // TODO (fat): remove sketch reliance on jQuery position/offset
  4984. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4985. }
  4986. }
  4987. return null;
  4988. }).filter(function (item) {
  4989. return item;
  4990. }).sort(function (a, b) {
  4991. return a[0] - b[0];
  4992. }).forEach(function (item) {
  4993. _this2._offsets.push(item[0]);
  4994. _this2._targets.push(item[1]);
  4995. });
  4996. };
  4997. _proto.dispose = function dispose() {
  4998. $.removeData(this._element, DATA_KEY$8);
  4999. $(this._scrollElement).off(EVENT_KEY$8);
  5000. this._element = null;
  5001. this._scrollElement = null;
  5002. this._config = null;
  5003. this._selector = null;
  5004. this._offsets = null;
  5005. this._targets = null;
  5006. this._activeTarget = null;
  5007. this._scrollHeight = null;
  5008. } // Private
  5009. ;
  5010. _proto._getConfig = function _getConfig(config) {
  5011. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  5012. if (typeof config.target !== 'string') {
  5013. var id = $(config.target).attr('id');
  5014. if (!id) {
  5015. id = Util.getUID(NAME$8);
  5016. $(config.target).attr('id', id);
  5017. }
  5018. config.target = "#" + id;
  5019. }
  5020. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  5021. return config;
  5022. };
  5023. _proto._getScrollTop = function _getScrollTop() {
  5024. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  5025. };
  5026. _proto._getScrollHeight = function _getScrollHeight() {
  5027. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  5028. };
  5029. _proto._getOffsetHeight = function _getOffsetHeight() {
  5030. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  5031. };
  5032. _proto._process = function _process() {
  5033. var scrollTop = this._getScrollTop() + this._config.offset;
  5034. var scrollHeight = this._getScrollHeight();
  5035. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5036. if (this._scrollHeight !== scrollHeight) {
  5037. this.refresh();
  5038. }
  5039. if (scrollTop >= maxScroll) {
  5040. var target = this._targets[this._targets.length - 1];
  5041. if (this._activeTarget !== target) {
  5042. this._activate(target);
  5043. }
  5044. return;
  5045. }
  5046. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5047. this._activeTarget = null;
  5048. this._clear();
  5049. return;
  5050. }
  5051. var offsetLength = this._offsets.length;
  5052. for (var i = offsetLength; i--;) {
  5053. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5054. if (isActiveTarget) {
  5055. this._activate(this._targets[i]);
  5056. }
  5057. }
  5058. };
  5059. _proto._activate = function _activate(target) {
  5060. this._activeTarget = target;
  5061. this._clear();
  5062. var queries = this._selector.split(',').map(function (selector) {
  5063. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5064. });
  5065. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5066. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5067. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5068. $link.addClass(ClassName$8.ACTIVE);
  5069. } else {
  5070. // Set triggered link as active
  5071. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5072. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5073. $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
  5074. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5075. }
  5076. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5077. relatedTarget: target
  5078. });
  5079. };
  5080. _proto._clear = function _clear() {
  5081. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5082. return node.classList.contains(ClassName$8.ACTIVE);
  5083. }).forEach(function (node) {
  5084. return node.classList.remove(ClassName$8.ACTIVE);
  5085. });
  5086. } // Static
  5087. ;
  5088. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5089. return this.each(function () {
  5090. var data = $(this).data(DATA_KEY$8);
  5091. var _config = typeof config === 'object' && config;
  5092. if (!data) {
  5093. data = new ScrollSpy(this, _config);
  5094. $(this).data(DATA_KEY$8, data);
  5095. }
  5096. if (typeof config === 'string') {
  5097. if (typeof data[config] === 'undefined') {
  5098. throw new TypeError("No method named \"" + config + "\"");
  5099. }
  5100. data[config]();
  5101. }
  5102. });
  5103. };
  5104. _createClass(ScrollSpy, null, [{
  5105. key: "VERSION",
  5106. get: function get() {
  5107. return VERSION$8;
  5108. }
  5109. }, {
  5110. key: "Default",
  5111. get: function get() {
  5112. return Default$6;
  5113. }
  5114. }]);
  5115. return ScrollSpy;
  5116. }();
  5117. /**
  5118. * ------------------------------------------------------------------------
  5119. * Data Api implementation
  5120. * ------------------------------------------------------------------------
  5121. */
  5122. $(window).on(Event$8.LOAD_DATA_API, function () {
  5123. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5124. var scrollSpysLength = scrollSpys.length;
  5125. for (var i = scrollSpysLength; i--;) {
  5126. var $spy = $(scrollSpys[i]);
  5127. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5128. }
  5129. });
  5130. /**
  5131. * ------------------------------------------------------------------------
  5132. * jQuery
  5133. * ------------------------------------------------------------------------
  5134. */
  5135. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5136. $.fn[NAME$8].Constructor = ScrollSpy;
  5137. $.fn[NAME$8].noConflict = function () {
  5138. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5139. return ScrollSpy._jQueryInterface;
  5140. };
  5141. /**
  5142. * ------------------------------------------------------------------------
  5143. * Constants
  5144. * ------------------------------------------------------------------------
  5145. */
  5146. var NAME$9 = 'tab';
  5147. var VERSION$9 = '4.4.1';
  5148. var DATA_KEY$9 = 'bs.tab';
  5149. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5150. var DATA_API_KEY$7 = '.data-api';
  5151. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5152. var Event$9 = {
  5153. HIDE: "hide" + EVENT_KEY$9,
  5154. HIDDEN: "hidden" + EVENT_KEY$9,
  5155. SHOW: "show" + EVENT_KEY$9,
  5156. SHOWN: "shown" + EVENT_KEY$9,
  5157. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5158. };
  5159. var ClassName$9 = {
  5160. DROPDOWN_MENU: 'dropdown-menu',
  5161. ACTIVE: 'active',
  5162. DISABLED: 'disabled',
  5163. FADE: 'fade',
  5164. SHOW: 'show'
  5165. };
  5166. var Selector$9 = {
  5167. DROPDOWN: '.dropdown',
  5168. NAV_LIST_GROUP: '.nav, .list-group',
  5169. ACTIVE: '.active',
  5170. ACTIVE_UL: '> li > .active',
  5171. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5172. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5173. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5174. };
  5175. /**
  5176. * ------------------------------------------------------------------------
  5177. * Class Definition
  5178. * ------------------------------------------------------------------------
  5179. */
  5180. var Tab =
  5181. /*#__PURE__*/
  5182. function () {
  5183. function Tab(element) {
  5184. this._element = element;
  5185. } // Getters
  5186. var _proto = Tab.prototype;
  5187. // Public
  5188. _proto.show = function show() {
  5189. var _this = this;
  5190. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5191. return;
  5192. }
  5193. var target;
  5194. var previous;
  5195. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5196. var selector = Util.getSelectorFromElement(this._element);
  5197. if (listElement) {
  5198. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5199. previous = $.makeArray($(listElement).find(itemSelector));
  5200. previous = previous[previous.length - 1];
  5201. }
  5202. var hideEvent = $.Event(Event$9.HIDE, {
  5203. relatedTarget: this._element
  5204. });
  5205. var showEvent = $.Event(Event$9.SHOW, {
  5206. relatedTarget: previous
  5207. });
  5208. if (previous) {
  5209. $(previous).trigger(hideEvent);
  5210. }
  5211. $(this._element).trigger(showEvent);
  5212. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5213. return;
  5214. }
  5215. if (selector) {
  5216. target = document.querySelector(selector);
  5217. }
  5218. this._activate(this._element, listElement);
  5219. var complete = function complete() {
  5220. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5221. relatedTarget: _this._element
  5222. });
  5223. var shownEvent = $.Event(Event$9.SHOWN, {
  5224. relatedTarget: previous
  5225. });
  5226. $(previous).trigger(hiddenEvent);
  5227. $(_this._element).trigger(shownEvent);
  5228. };
  5229. if (target) {
  5230. this._activate(target, target.parentNode, complete);
  5231. } else {
  5232. complete();
  5233. }
  5234. };
  5235. _proto.dispose = function dispose() {
  5236. $.removeData(this._element, DATA_KEY$9);
  5237. this._element = null;
  5238. } // Private
  5239. ;
  5240. _proto._activate = function _activate(element, container, callback) {
  5241. var _this2 = this;
  5242. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5243. var active = activeElements[0];
  5244. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5245. var complete = function complete() {
  5246. return _this2._transitionComplete(element, active, callback);
  5247. };
  5248. if (active && isTransitioning) {
  5249. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5250. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5251. } else {
  5252. complete();
  5253. }
  5254. };
  5255. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5256. if (active) {
  5257. $(active).removeClass(ClassName$9.ACTIVE);
  5258. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5259. if (dropdownChild) {
  5260. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5261. }
  5262. if (active.getAttribute('role') === 'tab') {
  5263. active.setAttribute('aria-selected', false);
  5264. }
  5265. }
  5266. $(element).addClass(ClassName$9.ACTIVE);
  5267. if (element.getAttribute('role') === 'tab') {
  5268. element.setAttribute('aria-selected', true);
  5269. }
  5270. Util.reflow(element);
  5271. if (element.classList.contains(ClassName$9.FADE)) {
  5272. element.classList.add(ClassName$9.SHOW);
  5273. }
  5274. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5275. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5276. if (dropdownElement) {
  5277. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5278. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5279. }
  5280. element.setAttribute('aria-expanded', true);
  5281. }
  5282. if (callback) {
  5283. callback();
  5284. }
  5285. } // Static
  5286. ;
  5287. Tab._jQueryInterface = function _jQueryInterface(config) {
  5288. return this.each(function () {
  5289. var $this = $(this);
  5290. var data = $this.data(DATA_KEY$9);
  5291. if (!data) {
  5292. data = new Tab(this);
  5293. $this.data(DATA_KEY$9, data);
  5294. }
  5295. if (typeof config === 'string') {
  5296. if (typeof data[config] === 'undefined') {
  5297. throw new TypeError("No method named \"" + config + "\"");
  5298. }
  5299. data[config]();
  5300. }
  5301. });
  5302. };
  5303. _createClass(Tab, null, [{
  5304. key: "VERSION",
  5305. get: function get() {
  5306. return VERSION$9;
  5307. }
  5308. }]);
  5309. return Tab;
  5310. }();
  5311. /**
  5312. * ------------------------------------------------------------------------
  5313. * Data Api implementation
  5314. * ------------------------------------------------------------------------
  5315. */
  5316. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5317. event.preventDefault();
  5318. Tab._jQueryInterface.call($(this), 'show');
  5319. });
  5320. /**
  5321. * ------------------------------------------------------------------------
  5322. * jQuery
  5323. * ------------------------------------------------------------------------
  5324. */
  5325. $.fn[NAME$9] = Tab._jQueryInterface;
  5326. $.fn[NAME$9].Constructor = Tab;
  5327. $.fn[NAME$9].noConflict = function () {
  5328. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5329. return Tab._jQueryInterface;
  5330. };
  5331. /**
  5332. * ------------------------------------------------------------------------
  5333. * Constants
  5334. * ------------------------------------------------------------------------
  5335. */
  5336. var NAME$a = 'toast';
  5337. var VERSION$a = '4.4.1';
  5338. var DATA_KEY$a = 'bs.toast';
  5339. var EVENT_KEY$a = "." + DATA_KEY$a;
  5340. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5341. var Event$a = {
  5342. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5343. HIDE: "hide" + EVENT_KEY$a,
  5344. HIDDEN: "hidden" + EVENT_KEY$a,
  5345. SHOW: "show" + EVENT_KEY$a,
  5346. SHOWN: "shown" + EVENT_KEY$a
  5347. };
  5348. var ClassName$a = {
  5349. FADE: 'fade',
  5350. HIDE: 'hide',
  5351. SHOW: 'show',
  5352. SHOWING: 'showing'
  5353. };
  5354. var DefaultType$7 = {
  5355. animation: 'boolean',
  5356. autohide: 'boolean',
  5357. delay: 'number'
  5358. };
  5359. var Default$7 = {
  5360. animation: true,
  5361. autohide: true,
  5362. delay: 500
  5363. };
  5364. var Selector$a = {
  5365. DATA_DISMISS: '[data-dismiss="toast"]'
  5366. };
  5367. /**
  5368. * ------------------------------------------------------------------------
  5369. * Class Definition
  5370. * ------------------------------------------------------------------------
  5371. */
  5372. var Toast =
  5373. /*#__PURE__*/
  5374. function () {
  5375. function Toast(element, config) {
  5376. this._element = element;
  5377. this._config = this._getConfig(config);
  5378. this._timeout = null;
  5379. this._setListeners();
  5380. } // Getters
  5381. var _proto = Toast.prototype;
  5382. // Public
  5383. _proto.show = function show() {
  5384. var _this = this;
  5385. var showEvent = $.Event(Event$a.SHOW);
  5386. $(this._element).trigger(showEvent);
  5387. if (showEvent.isDefaultPrevented()) {
  5388. return;
  5389. }
  5390. if (this._config.animation) {
  5391. this._element.classList.add(ClassName$a.FADE);
  5392. }
  5393. var complete = function complete() {
  5394. _this._element.classList.remove(ClassName$a.SHOWING);
  5395. _this._element.classList.add(ClassName$a.SHOW);
  5396. $(_this._element).trigger(Event$a.SHOWN);
  5397. if (_this._config.autohide) {
  5398. _this._timeout = setTimeout(function () {
  5399. _this.hide();
  5400. }, _this._config.delay);
  5401. }
  5402. };
  5403. this._element.classList.remove(ClassName$a.HIDE);
  5404. Util.reflow(this._element);
  5405. this._element.classList.add(ClassName$a.SHOWING);
  5406. if (this._config.animation) {
  5407. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5408. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5409. } else {
  5410. complete();
  5411. }
  5412. };
  5413. _proto.hide = function hide() {
  5414. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5415. return;
  5416. }
  5417. var hideEvent = $.Event(Event$a.HIDE);
  5418. $(this._element).trigger(hideEvent);
  5419. if (hideEvent.isDefaultPrevented()) {
  5420. return;
  5421. }
  5422. this._close();
  5423. };
  5424. _proto.dispose = function dispose() {
  5425. clearTimeout(this._timeout);
  5426. this._timeout = null;
  5427. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5428. this._element.classList.remove(ClassName$a.SHOW);
  5429. }
  5430. $(this._element).off(Event$a.CLICK_DISMISS);
  5431. $.removeData(this._element, DATA_KEY$a);
  5432. this._element = null;
  5433. this._config = null;
  5434. } // Private
  5435. ;
  5436. _proto._getConfig = function _getConfig(config) {
  5437. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5438. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5439. return config;
  5440. };
  5441. _proto._setListeners = function _setListeners() {
  5442. var _this2 = this;
  5443. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5444. return _this2.hide();
  5445. });
  5446. };
  5447. _proto._close = function _close() {
  5448. var _this3 = this;
  5449. var complete = function complete() {
  5450. _this3._element.classList.add(ClassName$a.HIDE);
  5451. $(_this3._element).trigger(Event$a.HIDDEN);
  5452. };
  5453. this._element.classList.remove(ClassName$a.SHOW);
  5454. if (this._config.animation) {
  5455. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5456. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5457. } else {
  5458. complete();
  5459. }
  5460. } // Static
  5461. ;
  5462. Toast._jQueryInterface = function _jQueryInterface(config) {
  5463. return this.each(function () {
  5464. var $element = $(this);
  5465. var data = $element.data(DATA_KEY$a);
  5466. var _config = typeof config === 'object' && config;
  5467. if (!data) {
  5468. data = new Toast(this, _config);
  5469. $element.data(DATA_KEY$a, data);
  5470. }
  5471. if (typeof config === 'string') {
  5472. if (typeof data[config] === 'undefined') {
  5473. throw new TypeError("No method named \"" + config + "\"");
  5474. }
  5475. data[config](this);
  5476. }
  5477. });
  5478. };
  5479. _createClass(Toast, null, [{
  5480. key: "VERSION",
  5481. get: function get() {
  5482. return VERSION$a;
  5483. }
  5484. }, {
  5485. key: "DefaultType",
  5486. get: function get() {
  5487. return DefaultType$7;
  5488. }
  5489. }, {
  5490. key: "Default",
  5491. get: function get() {
  5492. return Default$7;
  5493. }
  5494. }]);
  5495. return Toast;
  5496. }();
  5497. /**
  5498. * ------------------------------------------------------------------------
  5499. * jQuery
  5500. * ------------------------------------------------------------------------
  5501. */
  5502. $.fn[NAME$a] = Toast._jQueryInterface;
  5503. $.fn[NAME$a].Constructor = Toast;
  5504. $.fn[NAME$a].noConflict = function () {
  5505. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5506. return Toast._jQueryInterface;
  5507. };
  5508. exports.Alert = Alert;
  5509. exports.Button = Button;
  5510. exports.Carousel = Carousel;
  5511. exports.Collapse = Collapse;
  5512. exports.Dropdown = Dropdown;
  5513. exports.Modal = Modal;
  5514. exports.Popover = Popover;
  5515. exports.Scrollspy = ScrollSpy;
  5516. exports.Tab = Tab;
  5517. exports.Toast = Toast;
  5518. exports.Tooltip = Tooltip;
  5519. exports.Util = Util;
  5520. Object.defineProperty(exports, '__esModule', { value: true });
  5521. })));
  5522. //# sourceMappingURL=bootstrap.js.map
  5523. /***/ }),
  5524. /***/ "./node_modules/buffer/index.js":
  5525. /*!**************************************!*\
  5526. !*** ./node_modules/buffer/index.js ***!
  5527. \**************************************/
  5528. /*! no static exports found */
  5529. /***/ (function(module, exports, __webpack_require__) {
  5530. "use strict";
  5531. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5532. * The buffer module from node.js, for the browser.
  5533. *
  5534. * @author Feross Aboukhadijeh <http://feross.org>
  5535. * @license MIT
  5536. */
  5537. /* eslint-disable no-proto */
  5538. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5539. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5540. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5541. exports.Buffer = Buffer
  5542. exports.SlowBuffer = SlowBuffer
  5543. exports.INSPECT_MAX_BYTES = 50
  5544. /**
  5545. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5546. * === true Use Uint8Array implementation (fastest)
  5547. * === false Use Object implementation (most compatible, even IE6)
  5548. *
  5549. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5550. * Opera 11.6+, iOS 4.2+.
  5551. *
  5552. * Due to various browser bugs, sometimes the Object implementation will be used even
  5553. * when the browser supports typed arrays.
  5554. *
  5555. * Note:
  5556. *
  5557. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5558. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5559. *
  5560. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5561. *
  5562. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5563. * incorrect length in some situations.
  5564. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5565. * get the Object implementation, which is slower but behaves correctly.
  5566. */
  5567. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5568. ? global.TYPED_ARRAY_SUPPORT
  5569. : typedArraySupport()
  5570. /*
  5571. * Export kMaxLength after typed array support is determined.
  5572. */
  5573. exports.kMaxLength = kMaxLength()
  5574. function typedArraySupport () {
  5575. try {
  5576. var arr = new Uint8Array(1)
  5577. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5578. return arr.foo() === 42 && // typed array instances can be augmented
  5579. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5580. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5581. } catch (e) {
  5582. return false
  5583. }
  5584. }
  5585. function kMaxLength () {
  5586. return Buffer.TYPED_ARRAY_SUPPORT
  5587. ? 0x7fffffff
  5588. : 0x3fffffff
  5589. }
  5590. function createBuffer (that, length) {
  5591. if (kMaxLength() < length) {
  5592. throw new RangeError('Invalid typed array length')
  5593. }
  5594. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5595. // Return an augmented `Uint8Array` instance, for best performance
  5596. that = new Uint8Array(length)
  5597. that.__proto__ = Buffer.prototype
  5598. } else {
  5599. // Fallback: Return an object instance of the Buffer class
  5600. if (that === null) {
  5601. that = new Buffer(length)
  5602. }
  5603. that.length = length
  5604. }
  5605. return that
  5606. }
  5607. /**
  5608. * The Buffer constructor returns instances of `Uint8Array` that have their
  5609. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5610. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5611. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5612. * returns a single octet.
  5613. *
  5614. * The `Uint8Array` prototype remains unmodified.
  5615. */
  5616. function Buffer (arg, encodingOrOffset, length) {
  5617. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5618. return new Buffer(arg, encodingOrOffset, length)
  5619. }
  5620. // Common case.
  5621. if (typeof arg === 'number') {
  5622. if (typeof encodingOrOffset === 'string') {
  5623. throw new Error(
  5624. 'If encoding is specified then the first argument must be a string'
  5625. )
  5626. }
  5627. return allocUnsafe(this, arg)
  5628. }
  5629. return from(this, arg, encodingOrOffset, length)
  5630. }
  5631. Buffer.poolSize = 8192 // not used by this implementation
  5632. // TODO: Legacy, not needed anymore. Remove in next major version.
  5633. Buffer._augment = function (arr) {
  5634. arr.__proto__ = Buffer.prototype
  5635. return arr
  5636. }
  5637. function from (that, value, encodingOrOffset, length) {
  5638. if (typeof value === 'number') {
  5639. throw new TypeError('"value" argument must not be a number')
  5640. }
  5641. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5642. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5643. }
  5644. if (typeof value === 'string') {
  5645. return fromString(that, value, encodingOrOffset)
  5646. }
  5647. return fromObject(that, value)
  5648. }
  5649. /**
  5650. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5651. * if value is a number.
  5652. * Buffer.from(str[, encoding])
  5653. * Buffer.from(array)
  5654. * Buffer.from(buffer)
  5655. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5656. **/
  5657. Buffer.from = function (value, encodingOrOffset, length) {
  5658. return from(null, value, encodingOrOffset, length)
  5659. }
  5660. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5661. Buffer.prototype.__proto__ = Uint8Array.prototype
  5662. Buffer.__proto__ = Uint8Array
  5663. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5664. Buffer[Symbol.species] === Buffer) {
  5665. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5666. Object.defineProperty(Buffer, Symbol.species, {
  5667. value: null,
  5668. configurable: true
  5669. })
  5670. }
  5671. }
  5672. function assertSize (size) {
  5673. if (typeof size !== 'number') {
  5674. throw new TypeError('"size" argument must be a number')
  5675. } else if (size < 0) {
  5676. throw new RangeError('"size" argument must not be negative')
  5677. }
  5678. }
  5679. function alloc (that, size, fill, encoding) {
  5680. assertSize(size)
  5681. if (size <= 0) {
  5682. return createBuffer(that, size)
  5683. }
  5684. if (fill !== undefined) {
  5685. // Only pay attention to encoding if it's a string. This
  5686. // prevents accidentally sending in a number that would
  5687. // be interpretted as a start offset.
  5688. return typeof encoding === 'string'
  5689. ? createBuffer(that, size).fill(fill, encoding)
  5690. : createBuffer(that, size).fill(fill)
  5691. }
  5692. return createBuffer(that, size)
  5693. }
  5694. /**
  5695. * Creates a new filled Buffer instance.
  5696. * alloc(size[, fill[, encoding]])
  5697. **/
  5698. Buffer.alloc = function (size, fill, encoding) {
  5699. return alloc(null, size, fill, encoding)
  5700. }
  5701. function allocUnsafe (that, size) {
  5702. assertSize(size)
  5703. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5704. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5705. for (var i = 0; i < size; ++i) {
  5706. that[i] = 0
  5707. }
  5708. }
  5709. return that
  5710. }
  5711. /**
  5712. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5713. * */
  5714. Buffer.allocUnsafe = function (size) {
  5715. return allocUnsafe(null, size)
  5716. }
  5717. /**
  5718. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5719. */
  5720. Buffer.allocUnsafeSlow = function (size) {
  5721. return allocUnsafe(null, size)
  5722. }
  5723. function fromString (that, string, encoding) {
  5724. if (typeof encoding !== 'string' || encoding === '') {
  5725. encoding = 'utf8'
  5726. }
  5727. if (!Buffer.isEncoding(encoding)) {
  5728. throw new TypeError('"encoding" must be a valid string encoding')
  5729. }
  5730. var length = byteLength(string, encoding) | 0
  5731. that = createBuffer(that, length)
  5732. var actual = that.write(string, encoding)
  5733. if (actual !== length) {
  5734. // Writing a hex string, for example, that contains invalid characters will
  5735. // cause everything after the first invalid character to be ignored. (e.g.
  5736. // 'abxxcd' will be treated as 'ab')
  5737. that = that.slice(0, actual)
  5738. }
  5739. return that
  5740. }
  5741. function fromArrayLike (that, array) {
  5742. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5743. that = createBuffer(that, length)
  5744. for (var i = 0; i < length; i += 1) {
  5745. that[i] = array[i] & 255
  5746. }
  5747. return that
  5748. }
  5749. function fromArrayBuffer (that, array, byteOffset, length) {
  5750. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5751. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5752. throw new RangeError('\'offset\' is out of bounds')
  5753. }
  5754. if (array.byteLength < byteOffset + (length || 0)) {
  5755. throw new RangeError('\'length\' is out of bounds')
  5756. }
  5757. if (byteOffset === undefined && length === undefined) {
  5758. array = new Uint8Array(array)
  5759. } else if (length === undefined) {
  5760. array = new Uint8Array(array, byteOffset)
  5761. } else {
  5762. array = new Uint8Array(array, byteOffset, length)
  5763. }
  5764. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5765. // Return an augmented `Uint8Array` instance, for best performance
  5766. that = array
  5767. that.__proto__ = Buffer.prototype
  5768. } else {
  5769. // Fallback: Return an object instance of the Buffer class
  5770. that = fromArrayLike(that, array)
  5771. }
  5772. return that
  5773. }
  5774. function fromObject (that, obj) {
  5775. if (Buffer.isBuffer(obj)) {
  5776. var len = checked(obj.length) | 0
  5777. that = createBuffer(that, len)
  5778. if (that.length === 0) {
  5779. return that
  5780. }
  5781. obj.copy(that, 0, 0, len)
  5782. return that
  5783. }
  5784. if (obj) {
  5785. if ((typeof ArrayBuffer !== 'undefined' &&
  5786. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5787. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5788. return createBuffer(that, 0)
  5789. }
  5790. return fromArrayLike(that, obj)
  5791. }
  5792. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5793. return fromArrayLike(that, obj.data)
  5794. }
  5795. }
  5796. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5797. }
  5798. function checked (length) {
  5799. // Note: cannot use `length < kMaxLength()` here because that fails when
  5800. // length is NaN (which is otherwise coerced to zero.)
  5801. if (length >= kMaxLength()) {
  5802. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5803. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5804. }
  5805. return length | 0
  5806. }
  5807. function SlowBuffer (length) {
  5808. if (+length != length) { // eslint-disable-line eqeqeq
  5809. length = 0
  5810. }
  5811. return Buffer.alloc(+length)
  5812. }
  5813. Buffer.isBuffer = function isBuffer (b) {
  5814. return !!(b != null && b._isBuffer)
  5815. }
  5816. Buffer.compare = function compare (a, b) {
  5817. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5818. throw new TypeError('Arguments must be Buffers')
  5819. }
  5820. if (a === b) return 0
  5821. var x = a.length
  5822. var y = b.length
  5823. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5824. if (a[i] !== b[i]) {
  5825. x = a[i]
  5826. y = b[i]
  5827. break
  5828. }
  5829. }
  5830. if (x < y) return -1
  5831. if (y < x) return 1
  5832. return 0
  5833. }
  5834. Buffer.isEncoding = function isEncoding (encoding) {
  5835. switch (String(encoding).toLowerCase()) {
  5836. case 'hex':
  5837. case 'utf8':
  5838. case 'utf-8':
  5839. case 'ascii':
  5840. case 'latin1':
  5841. case 'binary':
  5842. case 'base64':
  5843. case 'ucs2':
  5844. case 'ucs-2':
  5845. case 'utf16le':
  5846. case 'utf-16le':
  5847. return true
  5848. default:
  5849. return false
  5850. }
  5851. }
  5852. Buffer.concat = function concat (list, length) {
  5853. if (!isArray(list)) {
  5854. throw new TypeError('"list" argument must be an Array of Buffers')
  5855. }
  5856. if (list.length === 0) {
  5857. return Buffer.alloc(0)
  5858. }
  5859. var i
  5860. if (length === undefined) {
  5861. length = 0
  5862. for (i = 0; i < list.length; ++i) {
  5863. length += list[i].length
  5864. }
  5865. }
  5866. var buffer = Buffer.allocUnsafe(length)
  5867. var pos = 0
  5868. for (i = 0; i < list.length; ++i) {
  5869. var buf = list[i]
  5870. if (!Buffer.isBuffer(buf)) {
  5871. throw new TypeError('"list" argument must be an Array of Buffers')
  5872. }
  5873. buf.copy(buffer, pos)
  5874. pos += buf.length
  5875. }
  5876. return buffer
  5877. }
  5878. function byteLength (string, encoding) {
  5879. if (Buffer.isBuffer(string)) {
  5880. return string.length
  5881. }
  5882. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5883. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5884. return string.byteLength
  5885. }
  5886. if (typeof string !== 'string') {
  5887. string = '' + string
  5888. }
  5889. var len = string.length
  5890. if (len === 0) return 0
  5891. // Use a for loop to avoid recursion
  5892. var loweredCase = false
  5893. for (;;) {
  5894. switch (encoding) {
  5895. case 'ascii':
  5896. case 'latin1':
  5897. case 'binary':
  5898. return len
  5899. case 'utf8':
  5900. case 'utf-8':
  5901. case undefined:
  5902. return utf8ToBytes(string).length
  5903. case 'ucs2':
  5904. case 'ucs-2':
  5905. case 'utf16le':
  5906. case 'utf-16le':
  5907. return len * 2
  5908. case 'hex':
  5909. return len >>> 1
  5910. case 'base64':
  5911. return base64ToBytes(string).length
  5912. default:
  5913. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5914. encoding = ('' + encoding).toLowerCase()
  5915. loweredCase = true
  5916. }
  5917. }
  5918. }
  5919. Buffer.byteLength = byteLength
  5920. function slowToString (encoding, start, end) {
  5921. var loweredCase = false
  5922. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5923. // property of a typed array.
  5924. // This behaves neither like String nor Uint8Array in that we set start/end
  5925. // to their upper/lower bounds if the value passed is out of range.
  5926. // undefined is handled specially as per ECMA-262 6th Edition,
  5927. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5928. if (start === undefined || start < 0) {
  5929. start = 0
  5930. }
  5931. // Return early if start > this.length. Done here to prevent potential uint32
  5932. // coercion fail below.
  5933. if (start > this.length) {
  5934. return ''
  5935. }
  5936. if (end === undefined || end > this.length) {
  5937. end = this.length
  5938. }
  5939. if (end <= 0) {
  5940. return ''
  5941. }
  5942. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5943. end >>>= 0
  5944. start >>>= 0
  5945. if (end <= start) {
  5946. return ''
  5947. }
  5948. if (!encoding) encoding = 'utf8'
  5949. while (true) {
  5950. switch (encoding) {
  5951. case 'hex':
  5952. return hexSlice(this, start, end)
  5953. case 'utf8':
  5954. case 'utf-8':
  5955. return utf8Slice(this, start, end)
  5956. case 'ascii':
  5957. return asciiSlice(this, start, end)
  5958. case 'latin1':
  5959. case 'binary':
  5960. return latin1Slice(this, start, end)
  5961. case 'base64':
  5962. return base64Slice(this, start, end)
  5963. case 'ucs2':
  5964. case 'ucs-2':
  5965. case 'utf16le':
  5966. case 'utf-16le':
  5967. return utf16leSlice(this, start, end)
  5968. default:
  5969. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5970. encoding = (encoding + '').toLowerCase()
  5971. loweredCase = true
  5972. }
  5973. }
  5974. }
  5975. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  5976. // Buffer instances.
  5977. Buffer.prototype._isBuffer = true
  5978. function swap (b, n, m) {
  5979. var i = b[n]
  5980. b[n] = b[m]
  5981. b[m] = i
  5982. }
  5983. Buffer.prototype.swap16 = function swap16 () {
  5984. var len = this.length
  5985. if (len % 2 !== 0) {
  5986. throw new RangeError('Buffer size must be a multiple of 16-bits')
  5987. }
  5988. for (var i = 0; i < len; i += 2) {
  5989. swap(this, i, i + 1)
  5990. }
  5991. return this
  5992. }
  5993. Buffer.prototype.swap32 = function swap32 () {
  5994. var len = this.length
  5995. if (len % 4 !== 0) {
  5996. throw new RangeError('Buffer size must be a multiple of 32-bits')
  5997. }
  5998. for (var i = 0; i < len; i += 4) {
  5999. swap(this, i, i + 3)
  6000. swap(this, i + 1, i + 2)
  6001. }
  6002. return this
  6003. }
  6004. Buffer.prototype.swap64 = function swap64 () {
  6005. var len = this.length
  6006. if (len % 8 !== 0) {
  6007. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6008. }
  6009. for (var i = 0; i < len; i += 8) {
  6010. swap(this, i, i + 7)
  6011. swap(this, i + 1, i + 6)
  6012. swap(this, i + 2, i + 5)
  6013. swap(this, i + 3, i + 4)
  6014. }
  6015. return this
  6016. }
  6017. Buffer.prototype.toString = function toString () {
  6018. var length = this.length | 0
  6019. if (length === 0) return ''
  6020. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6021. return slowToString.apply(this, arguments)
  6022. }
  6023. Buffer.prototype.equals = function equals (b) {
  6024. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6025. if (this === b) return true
  6026. return Buffer.compare(this, b) === 0
  6027. }
  6028. Buffer.prototype.inspect = function inspect () {
  6029. var str = ''
  6030. var max = exports.INSPECT_MAX_BYTES
  6031. if (this.length > 0) {
  6032. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  6033. if (this.length > max) str += ' ... '
  6034. }
  6035. return '<Buffer ' + str + '>'
  6036. }
  6037. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6038. if (!Buffer.isBuffer(target)) {
  6039. throw new TypeError('Argument must be a Buffer')
  6040. }
  6041. if (start === undefined) {
  6042. start = 0
  6043. }
  6044. if (end === undefined) {
  6045. end = target ? target.length : 0
  6046. }
  6047. if (thisStart === undefined) {
  6048. thisStart = 0
  6049. }
  6050. if (thisEnd === undefined) {
  6051. thisEnd = this.length
  6052. }
  6053. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6054. throw new RangeError('out of range index')
  6055. }
  6056. if (thisStart >= thisEnd && start >= end) {
  6057. return 0
  6058. }
  6059. if (thisStart >= thisEnd) {
  6060. return -1
  6061. }
  6062. if (start >= end) {
  6063. return 1
  6064. }
  6065. start >>>= 0
  6066. end >>>= 0
  6067. thisStart >>>= 0
  6068. thisEnd >>>= 0
  6069. if (this === target) return 0
  6070. var x = thisEnd - thisStart
  6071. var y = end - start
  6072. var len = Math.min(x, y)
  6073. var thisCopy = this.slice(thisStart, thisEnd)
  6074. var targetCopy = target.slice(start, end)
  6075. for (var i = 0; i < len; ++i) {
  6076. if (thisCopy[i] !== targetCopy[i]) {
  6077. x = thisCopy[i]
  6078. y = targetCopy[i]
  6079. break
  6080. }
  6081. }
  6082. if (x < y) return -1
  6083. if (y < x) return 1
  6084. return 0
  6085. }
  6086. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6087. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6088. //
  6089. // Arguments:
  6090. // - buffer - a Buffer to search
  6091. // - val - a string, Buffer, or number
  6092. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6093. // - encoding - an optional encoding, relevant is val is a string
  6094. // - dir - true for indexOf, false for lastIndexOf
  6095. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6096. // Empty buffer means no match
  6097. if (buffer.length === 0) return -1
  6098. // Normalize byteOffset
  6099. if (typeof byteOffset === 'string') {
  6100. encoding = byteOffset
  6101. byteOffset = 0
  6102. } else if (byteOffset > 0x7fffffff) {
  6103. byteOffset = 0x7fffffff
  6104. } else if (byteOffset < -0x80000000) {
  6105. byteOffset = -0x80000000
  6106. }
  6107. byteOffset = +byteOffset // Coerce to Number.
  6108. if (isNaN(byteOffset)) {
  6109. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6110. byteOffset = dir ? 0 : (buffer.length - 1)
  6111. }
  6112. // Normalize byteOffset: negative offsets start from the end of the buffer
  6113. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6114. if (byteOffset >= buffer.length) {
  6115. if (dir) return -1
  6116. else byteOffset = buffer.length - 1
  6117. } else if (byteOffset < 0) {
  6118. if (dir) byteOffset = 0
  6119. else return -1
  6120. }
  6121. // Normalize val
  6122. if (typeof val === 'string') {
  6123. val = Buffer.from(val, encoding)
  6124. }
  6125. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6126. if (Buffer.isBuffer(val)) {
  6127. // Special case: looking for empty string/buffer always fails
  6128. if (val.length === 0) {
  6129. return -1
  6130. }
  6131. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6132. } else if (typeof val === 'number') {
  6133. val = val & 0xFF // Search for a byte value [0-255]
  6134. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6135. typeof Uint8Array.prototype.indexOf === 'function') {
  6136. if (dir) {
  6137. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6138. } else {
  6139. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6140. }
  6141. }
  6142. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6143. }
  6144. throw new TypeError('val must be string, number or Buffer')
  6145. }
  6146. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6147. var indexSize = 1
  6148. var arrLength = arr.length
  6149. var valLength = val.length
  6150. if (encoding !== undefined) {
  6151. encoding = String(encoding).toLowerCase()
  6152. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6153. encoding === 'utf16le' || encoding === 'utf-16le') {
  6154. if (arr.length < 2 || val.length < 2) {
  6155. return -1
  6156. }
  6157. indexSize = 2
  6158. arrLength /= 2
  6159. valLength /= 2
  6160. byteOffset /= 2
  6161. }
  6162. }
  6163. function read (buf, i) {
  6164. if (indexSize === 1) {
  6165. return buf[i]
  6166. } else {
  6167. return buf.readUInt16BE(i * indexSize)
  6168. }
  6169. }
  6170. var i
  6171. if (dir) {
  6172. var foundIndex = -1
  6173. for (i = byteOffset; i < arrLength; i++) {
  6174. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6175. if (foundIndex === -1) foundIndex = i
  6176. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6177. } else {
  6178. if (foundIndex !== -1) i -= i - foundIndex
  6179. foundIndex = -1
  6180. }
  6181. }
  6182. } else {
  6183. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6184. for (i = byteOffset; i >= 0; i--) {
  6185. var found = true
  6186. for (var j = 0; j < valLength; j++) {
  6187. if (read(arr, i + j) !== read(val, j)) {
  6188. found = false
  6189. break
  6190. }
  6191. }
  6192. if (found) return i
  6193. }
  6194. }
  6195. return -1
  6196. }
  6197. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6198. return this.indexOf(val, byteOffset, encoding) !== -1
  6199. }
  6200. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6201. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6202. }
  6203. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6204. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6205. }
  6206. function hexWrite (buf, string, offset, length) {
  6207. offset = Number(offset) || 0
  6208. var remaining = buf.length - offset
  6209. if (!length) {
  6210. length = remaining
  6211. } else {
  6212. length = Number(length)
  6213. if (length > remaining) {
  6214. length = remaining
  6215. }
  6216. }
  6217. // must be an even number of digits
  6218. var strLen = string.length
  6219. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6220. if (length > strLen / 2) {
  6221. length = strLen / 2
  6222. }
  6223. for (var i = 0; i < length; ++i) {
  6224. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6225. if (isNaN(parsed)) return i
  6226. buf[offset + i] = parsed
  6227. }
  6228. return i
  6229. }
  6230. function utf8Write (buf, string, offset, length) {
  6231. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6232. }
  6233. function asciiWrite (buf, string, offset, length) {
  6234. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6235. }
  6236. function latin1Write (buf, string, offset, length) {
  6237. return asciiWrite(buf, string, offset, length)
  6238. }
  6239. function base64Write (buf, string, offset, length) {
  6240. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6241. }
  6242. function ucs2Write (buf, string, offset, length) {
  6243. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6244. }
  6245. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6246. // Buffer#write(string)
  6247. if (offset === undefined) {
  6248. encoding = 'utf8'
  6249. length = this.length
  6250. offset = 0
  6251. // Buffer#write(string, encoding)
  6252. } else if (length === undefined && typeof offset === 'string') {
  6253. encoding = offset
  6254. length = this.length
  6255. offset = 0
  6256. // Buffer#write(string, offset[, length][, encoding])
  6257. } else if (isFinite(offset)) {
  6258. offset = offset | 0
  6259. if (isFinite(length)) {
  6260. length = length | 0
  6261. if (encoding === undefined) encoding = 'utf8'
  6262. } else {
  6263. encoding = length
  6264. length = undefined
  6265. }
  6266. // legacy write(string, encoding, offset, length) - remove in v0.13
  6267. } else {
  6268. throw new Error(
  6269. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6270. )
  6271. }
  6272. var remaining = this.length - offset
  6273. if (length === undefined || length > remaining) length = remaining
  6274. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6275. throw new RangeError('Attempt to write outside buffer bounds')
  6276. }
  6277. if (!encoding) encoding = 'utf8'
  6278. var loweredCase = false
  6279. for (;;) {
  6280. switch (encoding) {
  6281. case 'hex':
  6282. return hexWrite(this, string, offset, length)
  6283. case 'utf8':
  6284. case 'utf-8':
  6285. return utf8Write(this, string, offset, length)
  6286. case 'ascii':
  6287. return asciiWrite(this, string, offset, length)
  6288. case 'latin1':
  6289. case 'binary':
  6290. return latin1Write(this, string, offset, length)
  6291. case 'base64':
  6292. // Warning: maxLength not taken into account in base64Write
  6293. return base64Write(this, string, offset, length)
  6294. case 'ucs2':
  6295. case 'ucs-2':
  6296. case 'utf16le':
  6297. case 'utf-16le':
  6298. return ucs2Write(this, string, offset, length)
  6299. default:
  6300. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6301. encoding = ('' + encoding).toLowerCase()
  6302. loweredCase = true
  6303. }
  6304. }
  6305. }
  6306. Buffer.prototype.toJSON = function toJSON () {
  6307. return {
  6308. type: 'Buffer',
  6309. data: Array.prototype.slice.call(this._arr || this, 0)
  6310. }
  6311. }
  6312. function base64Slice (buf, start, end) {
  6313. if (start === 0 && end === buf.length) {
  6314. return base64.fromByteArray(buf)
  6315. } else {
  6316. return base64.fromByteArray(buf.slice(start, end))
  6317. }
  6318. }
  6319. function utf8Slice (buf, start, end) {
  6320. end = Math.min(buf.length, end)
  6321. var res = []
  6322. var i = start
  6323. while (i < end) {
  6324. var firstByte = buf[i]
  6325. var codePoint = null
  6326. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6327. : (firstByte > 0xDF) ? 3
  6328. : (firstByte > 0xBF) ? 2
  6329. : 1
  6330. if (i + bytesPerSequence <= end) {
  6331. var secondByte, thirdByte, fourthByte, tempCodePoint
  6332. switch (bytesPerSequence) {
  6333. case 1:
  6334. if (firstByte < 0x80) {
  6335. codePoint = firstByte
  6336. }
  6337. break
  6338. case 2:
  6339. secondByte = buf[i + 1]
  6340. if ((secondByte & 0xC0) === 0x80) {
  6341. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6342. if (tempCodePoint > 0x7F) {
  6343. codePoint = tempCodePoint
  6344. }
  6345. }
  6346. break
  6347. case 3:
  6348. secondByte = buf[i + 1]
  6349. thirdByte = buf[i + 2]
  6350. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6351. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6352. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6353. codePoint = tempCodePoint
  6354. }
  6355. }
  6356. break
  6357. case 4:
  6358. secondByte = buf[i + 1]
  6359. thirdByte = buf[i + 2]
  6360. fourthByte = buf[i + 3]
  6361. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6362. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6363. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6364. codePoint = tempCodePoint
  6365. }
  6366. }
  6367. }
  6368. }
  6369. if (codePoint === null) {
  6370. // we did not generate a valid codePoint so insert a
  6371. // replacement char (U+FFFD) and advance only 1 byte
  6372. codePoint = 0xFFFD
  6373. bytesPerSequence = 1
  6374. } else if (codePoint > 0xFFFF) {
  6375. // encode to utf16 (surrogate pair dance)
  6376. codePoint -= 0x10000
  6377. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6378. codePoint = 0xDC00 | codePoint & 0x3FF
  6379. }
  6380. res.push(codePoint)
  6381. i += bytesPerSequence
  6382. }
  6383. return decodeCodePointsArray(res)
  6384. }
  6385. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6386. // the lowest limit is Chrome, with 0x10000 args.
  6387. // We go 1 magnitude less, for safety
  6388. var MAX_ARGUMENTS_LENGTH = 0x1000
  6389. function decodeCodePointsArray (codePoints) {
  6390. var len = codePoints.length
  6391. if (len <= MAX_ARGUMENTS_LENGTH) {
  6392. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6393. }
  6394. // Decode in chunks to avoid "call stack size exceeded".
  6395. var res = ''
  6396. var i = 0
  6397. while (i < len) {
  6398. res += String.fromCharCode.apply(
  6399. String,
  6400. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6401. )
  6402. }
  6403. return res
  6404. }
  6405. function asciiSlice (buf, start, end) {
  6406. var ret = ''
  6407. end = Math.min(buf.length, end)
  6408. for (var i = start; i < end; ++i) {
  6409. ret += String.fromCharCode(buf[i] & 0x7F)
  6410. }
  6411. return ret
  6412. }
  6413. function latin1Slice (buf, start, end) {
  6414. var ret = ''
  6415. end = Math.min(buf.length, end)
  6416. for (var i = start; i < end; ++i) {
  6417. ret += String.fromCharCode(buf[i])
  6418. }
  6419. return ret
  6420. }
  6421. function hexSlice (buf, start, end) {
  6422. var len = buf.length
  6423. if (!start || start < 0) start = 0
  6424. if (!end || end < 0 || end > len) end = len
  6425. var out = ''
  6426. for (var i = start; i < end; ++i) {
  6427. out += toHex(buf[i])
  6428. }
  6429. return out
  6430. }
  6431. function utf16leSlice (buf, start, end) {
  6432. var bytes = buf.slice(start, end)
  6433. var res = ''
  6434. for (var i = 0; i < bytes.length; i += 2) {
  6435. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6436. }
  6437. return res
  6438. }
  6439. Buffer.prototype.slice = function slice (start, end) {
  6440. var len = this.length
  6441. start = ~~start
  6442. end = end === undefined ? len : ~~end
  6443. if (start < 0) {
  6444. start += len
  6445. if (start < 0) start = 0
  6446. } else if (start > len) {
  6447. start = len
  6448. }
  6449. if (end < 0) {
  6450. end += len
  6451. if (end < 0) end = 0
  6452. } else if (end > len) {
  6453. end = len
  6454. }
  6455. if (end < start) end = start
  6456. var newBuf
  6457. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6458. newBuf = this.subarray(start, end)
  6459. newBuf.__proto__ = Buffer.prototype
  6460. } else {
  6461. var sliceLen = end - start
  6462. newBuf = new Buffer(sliceLen, undefined)
  6463. for (var i = 0; i < sliceLen; ++i) {
  6464. newBuf[i] = this[i + start]
  6465. }
  6466. }
  6467. return newBuf
  6468. }
  6469. /*
  6470. * Need to make sure that buffer isn't trying to write out of bounds.
  6471. */
  6472. function checkOffset (offset, ext, length) {
  6473. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6474. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6475. }
  6476. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6477. offset = offset | 0
  6478. byteLength = byteLength | 0
  6479. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6480. var val = this[offset]
  6481. var mul = 1
  6482. var i = 0
  6483. while (++i < byteLength && (mul *= 0x100)) {
  6484. val += this[offset + i] * mul
  6485. }
  6486. return val
  6487. }
  6488. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6489. offset = offset | 0
  6490. byteLength = byteLength | 0
  6491. if (!noAssert) {
  6492. checkOffset(offset, byteLength, this.length)
  6493. }
  6494. var val = this[offset + --byteLength]
  6495. var mul = 1
  6496. while (byteLength > 0 && (mul *= 0x100)) {
  6497. val += this[offset + --byteLength] * mul
  6498. }
  6499. return val
  6500. }
  6501. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6502. if (!noAssert) checkOffset(offset, 1, this.length)
  6503. return this[offset]
  6504. }
  6505. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6506. if (!noAssert) checkOffset(offset, 2, this.length)
  6507. return this[offset] | (this[offset + 1] << 8)
  6508. }
  6509. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6510. if (!noAssert) checkOffset(offset, 2, this.length)
  6511. return (this[offset] << 8) | this[offset + 1]
  6512. }
  6513. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6514. if (!noAssert) checkOffset(offset, 4, this.length)
  6515. return ((this[offset]) |
  6516. (this[offset + 1] << 8) |
  6517. (this[offset + 2] << 16)) +
  6518. (this[offset + 3] * 0x1000000)
  6519. }
  6520. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6521. if (!noAssert) checkOffset(offset, 4, this.length)
  6522. return (this[offset] * 0x1000000) +
  6523. ((this[offset + 1] << 16) |
  6524. (this[offset + 2] << 8) |
  6525. this[offset + 3])
  6526. }
  6527. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6528. offset = offset | 0
  6529. byteLength = byteLength | 0
  6530. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6531. var val = this[offset]
  6532. var mul = 1
  6533. var i = 0
  6534. while (++i < byteLength && (mul *= 0x100)) {
  6535. val += this[offset + i] * mul
  6536. }
  6537. mul *= 0x80
  6538. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6539. return val
  6540. }
  6541. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6542. offset = offset | 0
  6543. byteLength = byteLength | 0
  6544. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6545. var i = byteLength
  6546. var mul = 1
  6547. var val = this[offset + --i]
  6548. while (i > 0 && (mul *= 0x100)) {
  6549. val += this[offset + --i] * mul
  6550. }
  6551. mul *= 0x80
  6552. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6553. return val
  6554. }
  6555. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6556. if (!noAssert) checkOffset(offset, 1, this.length)
  6557. if (!(this[offset] & 0x80)) return (this[offset])
  6558. return ((0xff - this[offset] + 1) * -1)
  6559. }
  6560. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6561. if (!noAssert) checkOffset(offset, 2, this.length)
  6562. var val = this[offset] | (this[offset + 1] << 8)
  6563. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6564. }
  6565. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6566. if (!noAssert) checkOffset(offset, 2, this.length)
  6567. var val = this[offset + 1] | (this[offset] << 8)
  6568. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6569. }
  6570. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6571. if (!noAssert) checkOffset(offset, 4, this.length)
  6572. return (this[offset]) |
  6573. (this[offset + 1] << 8) |
  6574. (this[offset + 2] << 16) |
  6575. (this[offset + 3] << 24)
  6576. }
  6577. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6578. if (!noAssert) checkOffset(offset, 4, this.length)
  6579. return (this[offset] << 24) |
  6580. (this[offset + 1] << 16) |
  6581. (this[offset + 2] << 8) |
  6582. (this[offset + 3])
  6583. }
  6584. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6585. if (!noAssert) checkOffset(offset, 4, this.length)
  6586. return ieee754.read(this, offset, true, 23, 4)
  6587. }
  6588. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6589. if (!noAssert) checkOffset(offset, 4, this.length)
  6590. return ieee754.read(this, offset, false, 23, 4)
  6591. }
  6592. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6593. if (!noAssert) checkOffset(offset, 8, this.length)
  6594. return ieee754.read(this, offset, true, 52, 8)
  6595. }
  6596. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6597. if (!noAssert) checkOffset(offset, 8, this.length)
  6598. return ieee754.read(this, offset, false, 52, 8)
  6599. }
  6600. function checkInt (buf, value, offset, ext, max, min) {
  6601. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6602. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6603. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6604. }
  6605. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6606. value = +value
  6607. offset = offset | 0
  6608. byteLength = byteLength | 0
  6609. if (!noAssert) {
  6610. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6611. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6612. }
  6613. var mul = 1
  6614. var i = 0
  6615. this[offset] = value & 0xFF
  6616. while (++i < byteLength && (mul *= 0x100)) {
  6617. this[offset + i] = (value / mul) & 0xFF
  6618. }
  6619. return offset + byteLength
  6620. }
  6621. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6622. value = +value
  6623. offset = offset | 0
  6624. byteLength = byteLength | 0
  6625. if (!noAssert) {
  6626. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6627. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6628. }
  6629. var i = byteLength - 1
  6630. var mul = 1
  6631. this[offset + i] = value & 0xFF
  6632. while (--i >= 0 && (mul *= 0x100)) {
  6633. this[offset + i] = (value / mul) & 0xFF
  6634. }
  6635. return offset + byteLength
  6636. }
  6637. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6638. value = +value
  6639. offset = offset | 0
  6640. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6641. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6642. this[offset] = (value & 0xff)
  6643. return offset + 1
  6644. }
  6645. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6646. if (value < 0) value = 0xffff + value + 1
  6647. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6648. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6649. (littleEndian ? i : 1 - i) * 8
  6650. }
  6651. }
  6652. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6653. value = +value
  6654. offset = offset | 0
  6655. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6656. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6657. this[offset] = (value & 0xff)
  6658. this[offset + 1] = (value >>> 8)
  6659. } else {
  6660. objectWriteUInt16(this, value, offset, true)
  6661. }
  6662. return offset + 2
  6663. }
  6664. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6665. value = +value
  6666. offset = offset | 0
  6667. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6668. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6669. this[offset] = (value >>> 8)
  6670. this[offset + 1] = (value & 0xff)
  6671. } else {
  6672. objectWriteUInt16(this, value, offset, false)
  6673. }
  6674. return offset + 2
  6675. }
  6676. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6677. if (value < 0) value = 0xffffffff + value + 1
  6678. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6679. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6680. }
  6681. }
  6682. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6683. value = +value
  6684. offset = offset | 0
  6685. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6686. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6687. this[offset + 3] = (value >>> 24)
  6688. this[offset + 2] = (value >>> 16)
  6689. this[offset + 1] = (value >>> 8)
  6690. this[offset] = (value & 0xff)
  6691. } else {
  6692. objectWriteUInt32(this, value, offset, true)
  6693. }
  6694. return offset + 4
  6695. }
  6696. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6697. value = +value
  6698. offset = offset | 0
  6699. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6700. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6701. this[offset] = (value >>> 24)
  6702. this[offset + 1] = (value >>> 16)
  6703. this[offset + 2] = (value >>> 8)
  6704. this[offset + 3] = (value & 0xff)
  6705. } else {
  6706. objectWriteUInt32(this, value, offset, false)
  6707. }
  6708. return offset + 4
  6709. }
  6710. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6711. value = +value
  6712. offset = offset | 0
  6713. if (!noAssert) {
  6714. var limit = Math.pow(2, 8 * byteLength - 1)
  6715. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6716. }
  6717. var i = 0
  6718. var mul = 1
  6719. var sub = 0
  6720. this[offset] = value & 0xFF
  6721. while (++i < byteLength && (mul *= 0x100)) {
  6722. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6723. sub = 1
  6724. }
  6725. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6726. }
  6727. return offset + byteLength
  6728. }
  6729. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6730. value = +value
  6731. offset = offset | 0
  6732. if (!noAssert) {
  6733. var limit = Math.pow(2, 8 * byteLength - 1)
  6734. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6735. }
  6736. var i = byteLength - 1
  6737. var mul = 1
  6738. var sub = 0
  6739. this[offset + i] = value & 0xFF
  6740. while (--i >= 0 && (mul *= 0x100)) {
  6741. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6742. sub = 1
  6743. }
  6744. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6745. }
  6746. return offset + byteLength
  6747. }
  6748. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6749. value = +value
  6750. offset = offset | 0
  6751. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6752. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6753. if (value < 0) value = 0xff + value + 1
  6754. this[offset] = (value & 0xff)
  6755. return offset + 1
  6756. }
  6757. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6758. value = +value
  6759. offset = offset | 0
  6760. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6761. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6762. this[offset] = (value & 0xff)
  6763. this[offset + 1] = (value >>> 8)
  6764. } else {
  6765. objectWriteUInt16(this, value, offset, true)
  6766. }
  6767. return offset + 2
  6768. }
  6769. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6770. value = +value
  6771. offset = offset | 0
  6772. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6773. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6774. this[offset] = (value >>> 8)
  6775. this[offset + 1] = (value & 0xff)
  6776. } else {
  6777. objectWriteUInt16(this, value, offset, false)
  6778. }
  6779. return offset + 2
  6780. }
  6781. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6782. value = +value
  6783. offset = offset | 0
  6784. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6785. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6786. this[offset] = (value & 0xff)
  6787. this[offset + 1] = (value >>> 8)
  6788. this[offset + 2] = (value >>> 16)
  6789. this[offset + 3] = (value >>> 24)
  6790. } else {
  6791. objectWriteUInt32(this, value, offset, true)
  6792. }
  6793. return offset + 4
  6794. }
  6795. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6796. value = +value
  6797. offset = offset | 0
  6798. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6799. if (value < 0) value = 0xffffffff + value + 1
  6800. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6801. this[offset] = (value >>> 24)
  6802. this[offset + 1] = (value >>> 16)
  6803. this[offset + 2] = (value >>> 8)
  6804. this[offset + 3] = (value & 0xff)
  6805. } else {
  6806. objectWriteUInt32(this, value, offset, false)
  6807. }
  6808. return offset + 4
  6809. }
  6810. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6811. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6812. if (offset < 0) throw new RangeError('Index out of range')
  6813. }
  6814. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6815. if (!noAssert) {
  6816. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6817. }
  6818. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6819. return offset + 4
  6820. }
  6821. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6822. return writeFloat(this, value, offset, true, noAssert)
  6823. }
  6824. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6825. return writeFloat(this, value, offset, false, noAssert)
  6826. }
  6827. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6828. if (!noAssert) {
  6829. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6830. }
  6831. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6832. return offset + 8
  6833. }
  6834. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6835. return writeDouble(this, value, offset, true, noAssert)
  6836. }
  6837. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6838. return writeDouble(this, value, offset, false, noAssert)
  6839. }
  6840. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6841. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6842. if (!start) start = 0
  6843. if (!end && end !== 0) end = this.length
  6844. if (targetStart >= target.length) targetStart = target.length
  6845. if (!targetStart) targetStart = 0
  6846. if (end > 0 && end < start) end = start
  6847. // Copy 0 bytes; we're done
  6848. if (end === start) return 0
  6849. if (target.length === 0 || this.length === 0) return 0
  6850. // Fatal error conditions
  6851. if (targetStart < 0) {
  6852. throw new RangeError('targetStart out of bounds')
  6853. }
  6854. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6855. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6856. // Are we oob?
  6857. if (end > this.length) end = this.length
  6858. if (target.length - targetStart < end - start) {
  6859. end = target.length - targetStart + start
  6860. }
  6861. var len = end - start
  6862. var i
  6863. if (this === target && start < targetStart && targetStart < end) {
  6864. // descending copy from end
  6865. for (i = len - 1; i >= 0; --i) {
  6866. target[i + targetStart] = this[i + start]
  6867. }
  6868. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6869. // ascending copy from start
  6870. for (i = 0; i < len; ++i) {
  6871. target[i + targetStart] = this[i + start]
  6872. }
  6873. } else {
  6874. Uint8Array.prototype.set.call(
  6875. target,
  6876. this.subarray(start, start + len),
  6877. targetStart
  6878. )
  6879. }
  6880. return len
  6881. }
  6882. // Usage:
  6883. // buffer.fill(number[, offset[, end]])
  6884. // buffer.fill(buffer[, offset[, end]])
  6885. // buffer.fill(string[, offset[, end]][, encoding])
  6886. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6887. // Handle string cases:
  6888. if (typeof val === 'string') {
  6889. if (typeof start === 'string') {
  6890. encoding = start
  6891. start = 0
  6892. end = this.length
  6893. } else if (typeof end === 'string') {
  6894. encoding = end
  6895. end = this.length
  6896. }
  6897. if (val.length === 1) {
  6898. var code = val.charCodeAt(0)
  6899. if (code < 256) {
  6900. val = code
  6901. }
  6902. }
  6903. if (encoding !== undefined && typeof encoding !== 'string') {
  6904. throw new TypeError('encoding must be a string')
  6905. }
  6906. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6907. throw new TypeError('Unknown encoding: ' + encoding)
  6908. }
  6909. } else if (typeof val === 'number') {
  6910. val = val & 255
  6911. }
  6912. // Invalid ranges are not set to a default, so can range check early.
  6913. if (start < 0 || this.length < start || this.length < end) {
  6914. throw new RangeError('Out of range index')
  6915. }
  6916. if (end <= start) {
  6917. return this
  6918. }
  6919. start = start >>> 0
  6920. end = end === undefined ? this.length : end >>> 0
  6921. if (!val) val = 0
  6922. var i
  6923. if (typeof val === 'number') {
  6924. for (i = start; i < end; ++i) {
  6925. this[i] = val
  6926. }
  6927. } else {
  6928. var bytes = Buffer.isBuffer(val)
  6929. ? val
  6930. : utf8ToBytes(new Buffer(val, encoding).toString())
  6931. var len = bytes.length
  6932. for (i = 0; i < end - start; ++i) {
  6933. this[i + start] = bytes[i % len]
  6934. }
  6935. }
  6936. return this
  6937. }
  6938. // HELPER FUNCTIONS
  6939. // ================
  6940. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6941. function base64clean (str) {
  6942. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6943. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6944. // Node converts strings with length < 2 to ''
  6945. if (str.length < 2) return ''
  6946. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6947. while (str.length % 4 !== 0) {
  6948. str = str + '='
  6949. }
  6950. return str
  6951. }
  6952. function stringtrim (str) {
  6953. if (str.trim) return str.trim()
  6954. return str.replace(/^\s+|\s+$/g, '')
  6955. }
  6956. function toHex (n) {
  6957. if (n < 16) return '0' + n.toString(16)
  6958. return n.toString(16)
  6959. }
  6960. function utf8ToBytes (string, units) {
  6961. units = units || Infinity
  6962. var codePoint
  6963. var length = string.length
  6964. var leadSurrogate = null
  6965. var bytes = []
  6966. for (var i = 0; i < length; ++i) {
  6967. codePoint = string.charCodeAt(i)
  6968. // is surrogate component
  6969. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  6970. // last char was a lead
  6971. if (!leadSurrogate) {
  6972. // no lead yet
  6973. if (codePoint > 0xDBFF) {
  6974. // unexpected trail
  6975. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6976. continue
  6977. } else if (i + 1 === length) {
  6978. // unpaired lead
  6979. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6980. continue
  6981. }
  6982. // valid lead
  6983. leadSurrogate = codePoint
  6984. continue
  6985. }
  6986. // 2 leads in a row
  6987. if (codePoint < 0xDC00) {
  6988. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6989. leadSurrogate = codePoint
  6990. continue
  6991. }
  6992. // valid surrogate pair
  6993. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  6994. } else if (leadSurrogate) {
  6995. // valid bmp char, but last char was a lead
  6996. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6997. }
  6998. leadSurrogate = null
  6999. // encode utf8
  7000. if (codePoint < 0x80) {
  7001. if ((units -= 1) < 0) break
  7002. bytes.push(codePoint)
  7003. } else if (codePoint < 0x800) {
  7004. if ((units -= 2) < 0) break
  7005. bytes.push(
  7006. codePoint >> 0x6 | 0xC0,
  7007. codePoint & 0x3F | 0x80
  7008. )
  7009. } else if (codePoint < 0x10000) {
  7010. if ((units -= 3) < 0) break
  7011. bytes.push(
  7012. codePoint >> 0xC | 0xE0,
  7013. codePoint >> 0x6 & 0x3F | 0x80,
  7014. codePoint & 0x3F | 0x80
  7015. )
  7016. } else if (codePoint < 0x110000) {
  7017. if ((units -= 4) < 0) break
  7018. bytes.push(
  7019. codePoint >> 0x12 | 0xF0,
  7020. codePoint >> 0xC & 0x3F | 0x80,
  7021. codePoint >> 0x6 & 0x3F | 0x80,
  7022. codePoint & 0x3F | 0x80
  7023. )
  7024. } else {
  7025. throw new Error('Invalid code point')
  7026. }
  7027. }
  7028. return bytes
  7029. }
  7030. function asciiToBytes (str) {
  7031. var byteArray = []
  7032. for (var i = 0; i < str.length; ++i) {
  7033. // Node's code seems to be doing this and not & 0x7F..
  7034. byteArray.push(str.charCodeAt(i) & 0xFF)
  7035. }
  7036. return byteArray
  7037. }
  7038. function utf16leToBytes (str, units) {
  7039. var c, hi, lo
  7040. var byteArray = []
  7041. for (var i = 0; i < str.length; ++i) {
  7042. if ((units -= 2) < 0) break
  7043. c = str.charCodeAt(i)
  7044. hi = c >> 8
  7045. lo = c % 256
  7046. byteArray.push(lo)
  7047. byteArray.push(hi)
  7048. }
  7049. return byteArray
  7050. }
  7051. function base64ToBytes (str) {
  7052. return base64.toByteArray(base64clean(str))
  7053. }
  7054. function blitBuffer (src, dst, offset, length) {
  7055. for (var i = 0; i < length; ++i) {
  7056. if ((i + offset >= dst.length) || (i >= src.length)) break
  7057. dst[i + offset] = src[i]
  7058. }
  7059. return i
  7060. }
  7061. function isnan (val) {
  7062. return val !== val // eslint-disable-line no-self-compare
  7063. }
  7064. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7065. /***/ }),
  7066. /***/ "./node_modules/clipboard/dist/clipboard.js":
  7067. /*!**************************************************!*\
  7068. !*** ./node_modules/clipboard/dist/clipboard.js ***!
  7069. \**************************************************/
  7070. /*! no static exports found */
  7071. /***/ (function(module, exports, __webpack_require__) {
  7072. /*!
  7073. * clipboard.js v2.0.4
  7074. * https://zenorocha.github.io/clipboard.js
  7075. *
  7076. * Licensed MIT © Zeno Rocha
  7077. */
  7078. (function webpackUniversalModuleDefinition(root, factory) {
  7079. if(true)
  7080. module.exports = factory();
  7081. else {}
  7082. })(this, function() {
  7083. return /******/ (function(modules) { // webpackBootstrap
  7084. /******/ // The module cache
  7085. /******/ var installedModules = {};
  7086. /******/
  7087. /******/ // The require function
  7088. /******/ function __webpack_require__(moduleId) {
  7089. /******/
  7090. /******/ // Check if module is in cache
  7091. /******/ if(installedModules[moduleId]) {
  7092. /******/ return installedModules[moduleId].exports;
  7093. /******/ }
  7094. /******/ // Create a new module (and put it into the cache)
  7095. /******/ var module = installedModules[moduleId] = {
  7096. /******/ i: moduleId,
  7097. /******/ l: false,
  7098. /******/ exports: {}
  7099. /******/ };
  7100. /******/
  7101. /******/ // Execute the module function
  7102. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  7103. /******/
  7104. /******/ // Flag the module as loaded
  7105. /******/ module.l = true;
  7106. /******/
  7107. /******/ // Return the exports of the module
  7108. /******/ return module.exports;
  7109. /******/ }
  7110. /******/
  7111. /******/
  7112. /******/ // expose the modules object (__webpack_modules__)
  7113. /******/ __webpack_require__.m = modules;
  7114. /******/
  7115. /******/ // expose the module cache
  7116. /******/ __webpack_require__.c = installedModules;
  7117. /******/
  7118. /******/ // define getter function for harmony exports
  7119. /******/ __webpack_require__.d = function(exports, name, getter) {
  7120. /******/ if(!__webpack_require__.o(exports, name)) {
  7121. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  7122. /******/ }
  7123. /******/ };
  7124. /******/
  7125. /******/ // define __esModule on exports
  7126. /******/ __webpack_require__.r = function(exports) {
  7127. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  7128. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  7129. /******/ }
  7130. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  7131. /******/ };
  7132. /******/
  7133. /******/ // create a fake namespace object
  7134. /******/ // mode & 1: value is a module id, require it
  7135. /******/ // mode & 2: merge all properties of value into the ns
  7136. /******/ // mode & 4: return value when already ns object
  7137. /******/ // mode & 8|1: behave like require
  7138. /******/ __webpack_require__.t = function(value, mode) {
  7139. /******/ if(mode & 1) value = __webpack_require__(value);
  7140. /******/ if(mode & 8) return value;
  7141. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  7142. /******/ var ns = Object.create(null);
  7143. /******/ __webpack_require__.r(ns);
  7144. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  7145. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  7146. /******/ return ns;
  7147. /******/ };
  7148. /******/
  7149. /******/ // getDefaultExport function for compatibility with non-harmony modules
  7150. /******/ __webpack_require__.n = function(module) {
  7151. /******/ var getter = module && module.__esModule ?
  7152. /******/ function getDefault() { return module['default']; } :
  7153. /******/ function getModuleExports() { return module; };
  7154. /******/ __webpack_require__.d(getter, 'a', getter);
  7155. /******/ return getter;
  7156. /******/ };
  7157. /******/
  7158. /******/ // Object.prototype.hasOwnProperty.call
  7159. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  7160. /******/
  7161. /******/ // __webpack_public_path__
  7162. /******/ __webpack_require__.p = "";
  7163. /******/
  7164. /******/
  7165. /******/ // Load entry module and return exports
  7166. /******/ return __webpack_require__(__webpack_require__.s = 0);
  7167. /******/ })
  7168. /************************************************************************/
  7169. /******/ ([
  7170. /* 0 */
  7171. /***/ (function(module, exports, __webpack_require__) {
  7172. "use strict";
  7173. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  7174. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  7175. var _clipboardAction = __webpack_require__(1);
  7176. var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
  7177. var _tinyEmitter = __webpack_require__(3);
  7178. var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
  7179. var _goodListener = __webpack_require__(4);
  7180. var _goodListener2 = _interopRequireDefault(_goodListener);
  7181. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7182. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7183. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  7184. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  7185. /**
  7186. * Base class which takes one or more elements, adds event listeners to them,
  7187. * and instantiates a new `ClipboardAction` on each click.
  7188. */
  7189. var Clipboard = function (_Emitter) {
  7190. _inherits(Clipboard, _Emitter);
  7191. /**
  7192. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7193. * @param {Object} options
  7194. */
  7195. function Clipboard(trigger, options) {
  7196. _classCallCheck(this, Clipboard);
  7197. var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
  7198. _this.resolveOptions(options);
  7199. _this.listenClick(trigger);
  7200. return _this;
  7201. }
  7202. /**
  7203. * Defines if attributes would be resolved using internal setter functions
  7204. * or custom functions that were passed in the constructor.
  7205. * @param {Object} options
  7206. */
  7207. _createClass(Clipboard, [{
  7208. key: 'resolveOptions',
  7209. value: function resolveOptions() {
  7210. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7211. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  7212. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  7213. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  7214. this.container = _typeof(options.container) === 'object' ? options.container : document.body;
  7215. }
  7216. /**
  7217. * Adds a click event listener to the passed trigger.
  7218. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7219. */
  7220. }, {
  7221. key: 'listenClick',
  7222. value: function listenClick(trigger) {
  7223. var _this2 = this;
  7224. this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
  7225. return _this2.onClick(e);
  7226. });
  7227. }
  7228. /**
  7229. * Defines a new `ClipboardAction` on each click event.
  7230. * @param {Event} e
  7231. */
  7232. }, {
  7233. key: 'onClick',
  7234. value: function onClick(e) {
  7235. var trigger = e.delegateTarget || e.currentTarget;
  7236. if (this.clipboardAction) {
  7237. this.clipboardAction = null;
  7238. }
  7239. this.clipboardAction = new _clipboardAction2.default({
  7240. action: this.action(trigger),
  7241. target: this.target(trigger),
  7242. text: this.text(trigger),
  7243. container: this.container,
  7244. trigger: trigger,
  7245. emitter: this
  7246. });
  7247. }
  7248. /**
  7249. * Default `action` lookup function.
  7250. * @param {Element} trigger
  7251. */
  7252. }, {
  7253. key: 'defaultAction',
  7254. value: function defaultAction(trigger) {
  7255. return getAttributeValue('action', trigger);
  7256. }
  7257. /**
  7258. * Default `target` lookup function.
  7259. * @param {Element} trigger
  7260. */
  7261. }, {
  7262. key: 'defaultTarget',
  7263. value: function defaultTarget(trigger) {
  7264. var selector = getAttributeValue('target', trigger);
  7265. if (selector) {
  7266. return document.querySelector(selector);
  7267. }
  7268. }
  7269. /**
  7270. * Returns the support of the given action, or all actions if no action is
  7271. * given.
  7272. * @param {String} [action]
  7273. */
  7274. }, {
  7275. key: 'defaultText',
  7276. /**
  7277. * Default `text` lookup function.
  7278. * @param {Element} trigger
  7279. */
  7280. value: function defaultText(trigger) {
  7281. return getAttributeValue('text', trigger);
  7282. }
  7283. /**
  7284. * Destroy lifecycle.
  7285. */
  7286. }, {
  7287. key: 'destroy',
  7288. value: function destroy() {
  7289. this.listener.destroy();
  7290. if (this.clipboardAction) {
  7291. this.clipboardAction.destroy();
  7292. this.clipboardAction = null;
  7293. }
  7294. }
  7295. }], [{
  7296. key: 'isSupported',
  7297. value: function isSupported() {
  7298. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  7299. var actions = typeof action === 'string' ? [action] : action;
  7300. var support = !!document.queryCommandSupported;
  7301. actions.forEach(function (action) {
  7302. support = support && !!document.queryCommandSupported(action);
  7303. });
  7304. return support;
  7305. }
  7306. }]);
  7307. return Clipboard;
  7308. }(_tinyEmitter2.default);
  7309. /**
  7310. * Helper function to retrieve attribute value.
  7311. * @param {String} suffix
  7312. * @param {Element} element
  7313. */
  7314. function getAttributeValue(suffix, element) {
  7315. var attribute = 'data-clipboard-' + suffix;
  7316. if (!element.hasAttribute(attribute)) {
  7317. return;
  7318. }
  7319. return element.getAttribute(attribute);
  7320. }
  7321. module.exports = Clipboard;
  7322. /***/ }),
  7323. /* 1 */
  7324. /***/ (function(module, exports, __webpack_require__) {
  7325. "use strict";
  7326. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  7327. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  7328. var _select = __webpack_require__(2);
  7329. var _select2 = _interopRequireDefault(_select);
  7330. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7331. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7332. /**
  7333. * Inner class which performs selection from either `text` or `target`
  7334. * properties and then executes copy or cut operations.
  7335. */
  7336. var ClipboardAction = function () {
  7337. /**
  7338. * @param {Object} options
  7339. */
  7340. function ClipboardAction(options) {
  7341. _classCallCheck(this, ClipboardAction);
  7342. this.resolveOptions(options);
  7343. this.initSelection();
  7344. }
  7345. /**
  7346. * Defines base properties passed from constructor.
  7347. * @param {Object} options
  7348. */
  7349. _createClass(ClipboardAction, [{
  7350. key: 'resolveOptions',
  7351. value: function resolveOptions() {
  7352. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7353. this.action = options.action;
  7354. this.container = options.container;
  7355. this.emitter = options.emitter;
  7356. this.target = options.target;
  7357. this.text = options.text;
  7358. this.trigger = options.trigger;
  7359. this.selectedText = '';
  7360. }
  7361. /**
  7362. * Decides which selection strategy is going to be applied based
  7363. * on the existence of `text` and `target` properties.
  7364. */
  7365. }, {
  7366. key: 'initSelection',
  7367. value: function initSelection() {
  7368. if (this.text) {
  7369. this.selectFake();
  7370. } else if (this.target) {
  7371. this.selectTarget();
  7372. }
  7373. }
  7374. /**
  7375. * Creates a fake textarea element, sets its value from `text` property,
  7376. * and makes a selection on it.
  7377. */
  7378. }, {
  7379. key: 'selectFake',
  7380. value: function selectFake() {
  7381. var _this = this;
  7382. var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
  7383. this.removeFake();
  7384. this.fakeHandlerCallback = function () {
  7385. return _this.removeFake();
  7386. };
  7387. this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
  7388. this.fakeElem = document.createElement('textarea');
  7389. // Prevent zooming on iOS
  7390. this.fakeElem.style.fontSize = '12pt';
  7391. // Reset box model
  7392. this.fakeElem.style.border = '0';
  7393. this.fakeElem.style.padding = '0';
  7394. this.fakeElem.style.margin = '0';
  7395. // Move element out of screen horizontally
  7396. this.fakeElem.style.position = 'absolute';
  7397. this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
  7398. // Move element to the same position vertically
  7399. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  7400. this.fakeElem.style.top = yPosition + 'px';
  7401. this.fakeElem.setAttribute('readonly', '');
  7402. this.fakeElem.value = this.text;
  7403. this.container.appendChild(this.fakeElem);
  7404. this.selectedText = (0, _select2.default)(this.fakeElem);
  7405. this.copyText();
  7406. }
  7407. /**
  7408. * Only removes the fake element after another click event, that way
  7409. * a user can hit `Ctrl+C` to copy because selection still exists.
  7410. */
  7411. }, {
  7412. key: 'removeFake',
  7413. value: function removeFake() {
  7414. if (this.fakeHandler) {
  7415. this.container.removeEventListener('click', this.fakeHandlerCallback);
  7416. this.fakeHandler = null;
  7417. this.fakeHandlerCallback = null;
  7418. }
  7419. if (this.fakeElem) {
  7420. this.container.removeChild(this.fakeElem);
  7421. this.fakeElem = null;
  7422. }
  7423. }
  7424. /**
  7425. * Selects the content from element passed on `target` property.
  7426. */
  7427. }, {
  7428. key: 'selectTarget',
  7429. value: function selectTarget() {
  7430. this.selectedText = (0, _select2.default)(this.target);
  7431. this.copyText();
  7432. }
  7433. /**
  7434. * Executes the copy operation based on the current selection.
  7435. */
  7436. }, {
  7437. key: 'copyText',
  7438. value: function copyText() {
  7439. var succeeded = void 0;
  7440. try {
  7441. succeeded = document.execCommand(this.action);
  7442. } catch (err) {
  7443. succeeded = false;
  7444. }
  7445. this.handleResult(succeeded);
  7446. }
  7447. /**
  7448. * Fires an event based on the copy operation result.
  7449. * @param {Boolean} succeeded
  7450. */
  7451. }, {
  7452. key: 'handleResult',
  7453. value: function handleResult(succeeded) {
  7454. this.emitter.emit(succeeded ? 'success' : 'error', {
  7455. action: this.action,
  7456. text: this.selectedText,
  7457. trigger: this.trigger,
  7458. clearSelection: this.clearSelection.bind(this)
  7459. });
  7460. }
  7461. /**
  7462. * Moves focus away from `target` and back to the trigger, removes current selection.
  7463. */
  7464. }, {
  7465. key: 'clearSelection',
  7466. value: function clearSelection() {
  7467. if (this.trigger) {
  7468. this.trigger.focus();
  7469. }
  7470. window.getSelection().removeAllRanges();
  7471. }
  7472. /**
  7473. * Sets the `action` to be performed which can be either 'copy' or 'cut'.
  7474. * @param {String} action
  7475. */
  7476. }, {
  7477. key: 'destroy',
  7478. /**
  7479. * Destroy lifecycle.
  7480. */
  7481. value: function destroy() {
  7482. this.removeFake();
  7483. }
  7484. }, {
  7485. key: 'action',
  7486. set: function set() {
  7487. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
  7488. this._action = action;
  7489. if (this._action !== 'copy' && this._action !== 'cut') {
  7490. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  7491. }
  7492. }
  7493. /**
  7494. * Gets the `action` property.
  7495. * @return {String}
  7496. */
  7497. ,
  7498. get: function get() {
  7499. return this._action;
  7500. }
  7501. /**
  7502. * Sets the `target` property using an element
  7503. * that will be have its content copied.
  7504. * @param {Element} target
  7505. */
  7506. }, {
  7507. key: 'target',
  7508. set: function set(target) {
  7509. if (target !== undefined) {
  7510. if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
  7511. if (this.action === 'copy' && target.hasAttribute('disabled')) {
  7512. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  7513. }
  7514. if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  7515. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  7516. }
  7517. this._target = target;
  7518. } else {
  7519. throw new Error('Invalid "target" value, use a valid Element');
  7520. }
  7521. }
  7522. }
  7523. /**
  7524. * Gets the `target` property.
  7525. * @return {String|HTMLElement}
  7526. */
  7527. ,
  7528. get: function get() {
  7529. return this._target;
  7530. }
  7531. }]);
  7532. return ClipboardAction;
  7533. }();
  7534. module.exports = ClipboardAction;
  7535. /***/ }),
  7536. /* 2 */
  7537. /***/ (function(module, exports) {
  7538. function select(element) {
  7539. var selectedText;
  7540. if (element.nodeName === 'SELECT') {
  7541. element.focus();
  7542. selectedText = element.value;
  7543. }
  7544. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  7545. var isReadOnly = element.hasAttribute('readonly');
  7546. if (!isReadOnly) {
  7547. element.setAttribute('readonly', '');
  7548. }
  7549. element.select();
  7550. element.setSelectionRange(0, element.value.length);
  7551. if (!isReadOnly) {
  7552. element.removeAttribute('readonly');
  7553. }
  7554. selectedText = element.value;
  7555. }
  7556. else {
  7557. if (element.hasAttribute('contenteditable')) {
  7558. element.focus();
  7559. }
  7560. var selection = window.getSelection();
  7561. var range = document.createRange();
  7562. range.selectNodeContents(element);
  7563. selection.removeAllRanges();
  7564. selection.addRange(range);
  7565. selectedText = selection.toString();
  7566. }
  7567. return selectedText;
  7568. }
  7569. module.exports = select;
  7570. /***/ }),
  7571. /* 3 */
  7572. /***/ (function(module, exports) {
  7573. function E () {
  7574. // Keep this empty so it's easier to inherit from
  7575. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  7576. }
  7577. E.prototype = {
  7578. on: function (name, callback, ctx) {
  7579. var e = this.e || (this.e = {});
  7580. (e[name] || (e[name] = [])).push({
  7581. fn: callback,
  7582. ctx: ctx
  7583. });
  7584. return this;
  7585. },
  7586. once: function (name, callback, ctx) {
  7587. var self = this;
  7588. function listener () {
  7589. self.off(name, listener);
  7590. callback.apply(ctx, arguments);
  7591. };
  7592. listener._ = callback
  7593. return this.on(name, listener, ctx);
  7594. },
  7595. emit: function (name) {
  7596. var data = [].slice.call(arguments, 1);
  7597. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  7598. var i = 0;
  7599. var len = evtArr.length;
  7600. for (i; i < len; i++) {
  7601. evtArr[i].fn.apply(evtArr[i].ctx, data);
  7602. }
  7603. return this;
  7604. },
  7605. off: function (name, callback) {
  7606. var e = this.e || (this.e = {});
  7607. var evts = e[name];
  7608. var liveEvents = [];
  7609. if (evts && callback) {
  7610. for (var i = 0, len = evts.length; i < len; i++) {
  7611. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  7612. liveEvents.push(evts[i]);
  7613. }
  7614. }
  7615. // Remove event from queue to prevent memory leak
  7616. // Suggested by https://github.com/lazd
  7617. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  7618. (liveEvents.length)
  7619. ? e[name] = liveEvents
  7620. : delete e[name];
  7621. return this;
  7622. }
  7623. };
  7624. module.exports = E;
  7625. /***/ }),
  7626. /* 4 */
  7627. /***/ (function(module, exports, __webpack_require__) {
  7628. var is = __webpack_require__(5);
  7629. var delegate = __webpack_require__(6);
  7630. /**
  7631. * Validates all params and calls the right
  7632. * listener function based on its target type.
  7633. *
  7634. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  7635. * @param {String} type
  7636. * @param {Function} callback
  7637. * @return {Object}
  7638. */
  7639. function listen(target, type, callback) {
  7640. if (!target && !type && !callback) {
  7641. throw new Error('Missing required arguments');
  7642. }
  7643. if (!is.string(type)) {
  7644. throw new TypeError('Second argument must be a String');
  7645. }
  7646. if (!is.fn(callback)) {
  7647. throw new TypeError('Third argument must be a Function');
  7648. }
  7649. if (is.node(target)) {
  7650. return listenNode(target, type, callback);
  7651. }
  7652. else if (is.nodeList(target)) {
  7653. return listenNodeList(target, type, callback);
  7654. }
  7655. else if (is.string(target)) {
  7656. return listenSelector(target, type, callback);
  7657. }
  7658. else {
  7659. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  7660. }
  7661. }
  7662. /**
  7663. * Adds an event listener to a HTML element
  7664. * and returns a remove listener function.
  7665. *
  7666. * @param {HTMLElement} node
  7667. * @param {String} type
  7668. * @param {Function} callback
  7669. * @return {Object}
  7670. */
  7671. function listenNode(node, type, callback) {
  7672. node.addEventListener(type, callback);
  7673. return {
  7674. destroy: function() {
  7675. node.removeEventListener(type, callback);
  7676. }
  7677. }
  7678. }
  7679. /**
  7680. * Add an event listener to a list of HTML elements
  7681. * and returns a remove listener function.
  7682. *
  7683. * @param {NodeList|HTMLCollection} nodeList
  7684. * @param {String} type
  7685. * @param {Function} callback
  7686. * @return {Object}
  7687. */
  7688. function listenNodeList(nodeList, type, callback) {
  7689. Array.prototype.forEach.call(nodeList, function(node) {
  7690. node.addEventListener(type, callback);
  7691. });
  7692. return {
  7693. destroy: function() {
  7694. Array.prototype.forEach.call(nodeList, function(node) {
  7695. node.removeEventListener(type, callback);
  7696. });
  7697. }
  7698. }
  7699. }
  7700. /**
  7701. * Add an event listener to a selector
  7702. * and returns a remove listener function.
  7703. *
  7704. * @param {String} selector
  7705. * @param {String} type
  7706. * @param {Function} callback
  7707. * @return {Object}
  7708. */
  7709. function listenSelector(selector, type, callback) {
  7710. return delegate(document.body, selector, type, callback);
  7711. }
  7712. module.exports = listen;
  7713. /***/ }),
  7714. /* 5 */
  7715. /***/ (function(module, exports) {
  7716. /**
  7717. * Check if argument is a HTML element.
  7718. *
  7719. * @param {Object} value
  7720. * @return {Boolean}
  7721. */
  7722. exports.node = function(value) {
  7723. return value !== undefined
  7724. && value instanceof HTMLElement
  7725. && value.nodeType === 1;
  7726. };
  7727. /**
  7728. * Check if argument is a list of HTML elements.
  7729. *
  7730. * @param {Object} value
  7731. * @return {Boolean}
  7732. */
  7733. exports.nodeList = function(value) {
  7734. var type = Object.prototype.toString.call(value);
  7735. return value !== undefined
  7736. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  7737. && ('length' in value)
  7738. && (value.length === 0 || exports.node(value[0]));
  7739. };
  7740. /**
  7741. * Check if argument is a string.
  7742. *
  7743. * @param {Object} value
  7744. * @return {Boolean}
  7745. */
  7746. exports.string = function(value) {
  7747. return typeof value === 'string'
  7748. || value instanceof String;
  7749. };
  7750. /**
  7751. * Check if argument is a function.
  7752. *
  7753. * @param {Object} value
  7754. * @return {Boolean}
  7755. */
  7756. exports.fn = function(value) {
  7757. var type = Object.prototype.toString.call(value);
  7758. return type === '[object Function]';
  7759. };
  7760. /***/ }),
  7761. /* 6 */
  7762. /***/ (function(module, exports, __webpack_require__) {
  7763. var closest = __webpack_require__(7);
  7764. /**
  7765. * Delegates event to a selector.
  7766. *
  7767. * @param {Element} element
  7768. * @param {String} selector
  7769. * @param {String} type
  7770. * @param {Function} callback
  7771. * @param {Boolean} useCapture
  7772. * @return {Object}
  7773. */
  7774. function _delegate(element, selector, type, callback, useCapture) {
  7775. var listenerFn = listener.apply(this, arguments);
  7776. element.addEventListener(type, listenerFn, useCapture);
  7777. return {
  7778. destroy: function() {
  7779. element.removeEventListener(type, listenerFn, useCapture);
  7780. }
  7781. }
  7782. }
  7783. /**
  7784. * Delegates event to a selector.
  7785. *
  7786. * @param {Element|String|Array} [elements]
  7787. * @param {String} selector
  7788. * @param {String} type
  7789. * @param {Function} callback
  7790. * @param {Boolean} useCapture
  7791. * @return {Object}
  7792. */
  7793. function delegate(elements, selector, type, callback, useCapture) {
  7794. // Handle the regular Element usage
  7795. if (typeof elements.addEventListener === 'function') {
  7796. return _delegate.apply(null, arguments);
  7797. }
  7798. // Handle Element-less usage, it defaults to global delegation
  7799. if (typeof type === 'function') {
  7800. // Use `document` as the first parameter, then apply arguments
  7801. // This is a short way to .unshift `arguments` without running into deoptimizations
  7802. return _delegate.bind(null, document).apply(null, arguments);
  7803. }
  7804. // Handle Selector-based usage
  7805. if (typeof elements === 'string') {
  7806. elements = document.querySelectorAll(elements);
  7807. }
  7808. // Handle Array-like based usage
  7809. return Array.prototype.map.call(elements, function (element) {
  7810. return _delegate(element, selector, type, callback, useCapture);
  7811. });
  7812. }
  7813. /**
  7814. * Finds closest match and invokes callback.
  7815. *
  7816. * @param {Element} element
  7817. * @param {String} selector
  7818. * @param {String} type
  7819. * @param {Function} callback
  7820. * @return {Function}
  7821. */
  7822. function listener(element, selector, type, callback) {
  7823. return function(e) {
  7824. e.delegateTarget = closest(e.target, selector);
  7825. if (e.delegateTarget) {
  7826. callback.call(element, e);
  7827. }
  7828. }
  7829. }
  7830. module.exports = delegate;
  7831. /***/ }),
  7832. /* 7 */
  7833. /***/ (function(module, exports) {
  7834. var DOCUMENT_NODE_TYPE = 9;
  7835. /**
  7836. * A polyfill for Element.matches()
  7837. */
  7838. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  7839. var proto = Element.prototype;
  7840. proto.matches = proto.matchesSelector ||
  7841. proto.mozMatchesSelector ||
  7842. proto.msMatchesSelector ||
  7843. proto.oMatchesSelector ||
  7844. proto.webkitMatchesSelector;
  7845. }
  7846. /**
  7847. * Finds the closest parent that matches a selector.
  7848. *
  7849. * @param {Element} element
  7850. * @param {String} selector
  7851. * @return {Function}
  7852. */
  7853. function closest (element, selector) {
  7854. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  7855. if (typeof element.matches === 'function' &&
  7856. element.matches(selector)) {
  7857. return element;
  7858. }
  7859. element = element.parentNode;
  7860. }
  7861. }
  7862. module.exports = closest;
  7863. /***/ })
  7864. /******/ ]);
  7865. });
  7866. /***/ }),
  7867. /***/ "./node_modules/css-loader/index.js?!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&":
  7868. /*!********************************************************************************************************************************************************************************************************************************************************************************************!*\
  7869. !*** ./node_modules/css-loader??ref--6-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--6-2!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& ***!
  7870. \********************************************************************************************************************************************************************************************************************************************************************************************/
  7871. /*! no static exports found */
  7872. /***/ (function(module, exports, __webpack_require__) {
  7873. exports = module.exports = __webpack_require__(/*! ../../../node_modules/css-loader/lib/css-base.js */ "./node_modules/css-loader/lib/css-base.js")(false);
  7874. // imports
  7875. // module
  7876. exports.push([module.i, "\n.full-height[data-v-1ae8ae93] {\n height: 100vh;\n}\n.flex-center[data-v-1ae8ae93] {\n align-items: center;\n display: flex;\n justify-content: center;\n}\n.position-ref[data-v-1ae8ae93] {\n position: relative;\n}\n.top-right[data-v-1ae8ae93] {\n position: absolute;\n right: 10px;\n top: 18px;\n}\n.content[data-v-1ae8ae93] {\n text-align: center;\n}\n.title[data-v-1ae8ae93] {\n font-size: 60px;\n}\n.links > a[data-v-1ae8ae93] {\n color: #636b6f;\n padding: 0 25px;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: .1rem;\n text-decoration: none;\n text-transform: uppercase;\n}\n.m-b-md[data-v-1ae8ae93] {\n margin-bottom: 30px;\n color: #000000;\n}\n", ""]);
  7877. // exports
  7878. /***/ }),
  7879. /***/ "./node_modules/css-loader/lib/css-base.js":
  7880. /*!*************************************************!*\
  7881. !*** ./node_modules/css-loader/lib/css-base.js ***!
  7882. \*************************************************/
  7883. /*! no static exports found */
  7884. /***/ (function(module, exports) {
  7885. /*
  7886. MIT License http://www.opensource.org/licenses/mit-license.php
  7887. Author Tobias Koppers @sokra
  7888. */
  7889. // css base code, injected by the css-loader
  7890. module.exports = function(useSourceMap) {
  7891. var list = [];
  7892. // return the list of modules as css string
  7893. list.toString = function toString() {
  7894. return this.map(function (item) {
  7895. var content = cssWithMappingToString(item, useSourceMap);
  7896. if(item[2]) {
  7897. return "@media " + item[2] + "{" + content + "}";
  7898. } else {
  7899. return content;
  7900. }
  7901. }).join("");
  7902. };
  7903. // import a list of modules into the list
  7904. list.i = function(modules, mediaQuery) {
  7905. if(typeof modules === "string")
  7906. modules = [[null, modules, ""]];
  7907. var alreadyImportedModules = {};
  7908. for(var i = 0; i < this.length; i++) {
  7909. var id = this[i][0];
  7910. if(typeof id === "number")
  7911. alreadyImportedModules[id] = true;
  7912. }
  7913. for(i = 0; i < modules.length; i++) {
  7914. var item = modules[i];
  7915. // skip already imported module
  7916. // this implementation is not 100% perfect for weird media query combinations
  7917. // when a module is imported multiple times with different media queries.
  7918. // I hope this will never occur (Hey this way we have smaller bundles)
  7919. if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
  7920. if(mediaQuery && !item[2]) {
  7921. item[2] = mediaQuery;
  7922. } else if(mediaQuery) {
  7923. item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
  7924. }
  7925. list.push(item);
  7926. }
  7927. }
  7928. };
  7929. return list;
  7930. };
  7931. function cssWithMappingToString(item, useSourceMap) {
  7932. var content = item[1] || '';
  7933. var cssMapping = item[3];
  7934. if (!cssMapping) {
  7935. return content;
  7936. }
  7937. if (useSourceMap && typeof btoa === 'function') {
  7938. var sourceMapping = toComment(cssMapping);
  7939. var sourceURLs = cssMapping.sources.map(function (source) {
  7940. return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
  7941. });
  7942. return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  7943. }
  7944. return [content].join('\n');
  7945. }
  7946. // Adapted from convert-source-map (MIT)
  7947. function toComment(sourceMap) {
  7948. // eslint-disable-next-line no-undef
  7949. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
  7950. var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
  7951. return '/*# ' + data + ' */';
  7952. }
  7953. /***/ }),
  7954. /***/ "./node_modules/ieee754/index.js":
  7955. /*!***************************************!*\
  7956. !*** ./node_modules/ieee754/index.js ***!
  7957. \***************************************/
  7958. /*! no static exports found */
  7959. /***/ (function(module, exports) {
  7960. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7961. var e, m
  7962. var eLen = (nBytes * 8) - mLen - 1
  7963. var eMax = (1 << eLen) - 1
  7964. var eBias = eMax >> 1
  7965. var nBits = -7
  7966. var i = isLE ? (nBytes - 1) : 0
  7967. var d = isLE ? -1 : 1
  7968. var s = buffer[offset + i]
  7969. i += d
  7970. e = s & ((1 << (-nBits)) - 1)
  7971. s >>= (-nBits)
  7972. nBits += eLen
  7973. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7974. m = e & ((1 << (-nBits)) - 1)
  7975. e >>= (-nBits)
  7976. nBits += mLen
  7977. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7978. if (e === 0) {
  7979. e = 1 - eBias
  7980. } else if (e === eMax) {
  7981. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7982. } else {
  7983. m = m + Math.pow(2, mLen)
  7984. e = e - eBias
  7985. }
  7986. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7987. }
  7988. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7989. var e, m, c
  7990. var eLen = (nBytes * 8) - mLen - 1
  7991. var eMax = (1 << eLen) - 1
  7992. var eBias = eMax >> 1
  7993. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7994. var i = isLE ? 0 : (nBytes - 1)
  7995. var d = isLE ? 1 : -1
  7996. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7997. value = Math.abs(value)
  7998. if (isNaN(value) || value === Infinity) {
  7999. m = isNaN(value) ? 1 : 0
  8000. e = eMax
  8001. } else {
  8002. e = Math.floor(Math.log(value) / Math.LN2)
  8003. if (value * (c = Math.pow(2, -e)) < 1) {
  8004. e--
  8005. c *= 2
  8006. }
  8007. if (e + eBias >= 1) {
  8008. value += rt / c
  8009. } else {
  8010. value += rt * Math.pow(2, 1 - eBias)
  8011. }
  8012. if (value * c >= 2) {
  8013. e++
  8014. c /= 2
  8015. }
  8016. if (e + eBias >= eMax) {
  8017. m = 0
  8018. e = eMax
  8019. } else if (e + eBias >= 1) {
  8020. m = ((value * c) - 1) * Math.pow(2, mLen)
  8021. e = e + eBias
  8022. } else {
  8023. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  8024. e = 0
  8025. }
  8026. }
  8027. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  8028. e = (e << mLen) | m
  8029. eLen += mLen
  8030. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  8031. buffer[offset + i - d] |= s * 128
  8032. }
  8033. /***/ }),
  8034. /***/ "./node_modules/isarray/index.js":
  8035. /*!***************************************!*\
  8036. !*** ./node_modules/isarray/index.js ***!
  8037. \***************************************/
  8038. /*! no static exports found */
  8039. /***/ (function(module, exports) {
  8040. var toString = {}.toString;
  8041. module.exports = Array.isArray || function (arr) {
  8042. return toString.call(arr) == '[object Array]';
  8043. };
  8044. /***/ }),
  8045. /***/ "./node_modules/jquery/dist/jquery.js":
  8046. /*!********************************************!*\
  8047. !*** ./node_modules/jquery/dist/jquery.js ***!
  8048. \********************************************/
  8049. /*! no static exports found */
  8050. /***/ (function(module, exports, __webpack_require__) {
  8051. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  8052. * jQuery JavaScript Library v3.4.1
  8053. * https://jquery.com/
  8054. *
  8055. * Includes Sizzle.js
  8056. * https://sizzlejs.com/
  8057. *
  8058. * Copyright JS Foundation and other contributors
  8059. * Released under the MIT license
  8060. * https://jquery.org/license
  8061. *
  8062. * Date: 2019-05-01T21:04Z
  8063. */
  8064. ( function( global, factory ) {
  8065. "use strict";
  8066. if ( true && typeof module.exports === "object" ) {
  8067. // For CommonJS and CommonJS-like environments where a proper `window`
  8068. // is present, execute the factory and get jQuery.
  8069. // For environments that do not have a `window` with a `document`
  8070. // (such as Node.js), expose a factory as module.exports.
  8071. // This accentuates the need for the creation of a real `window`.
  8072. // e.g. var jQuery = require("jquery")(window);
  8073. // See ticket #14549 for more info.
  8074. module.exports = global.document ?
  8075. factory( global, true ) :
  8076. function( w ) {
  8077. if ( !w.document ) {
  8078. throw new Error( "jQuery requires a window with a document" );
  8079. }
  8080. return factory( w );
  8081. };
  8082. } else {
  8083. factory( global );
  8084. }
  8085. // Pass this if window is not defined yet
  8086. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  8087. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  8088. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  8089. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  8090. // enough that all such attempts are guarded in a try block.
  8091. "use strict";
  8092. var arr = [];
  8093. var document = window.document;
  8094. var getProto = Object.getPrototypeOf;
  8095. var slice = arr.slice;
  8096. var concat = arr.concat;
  8097. var push = arr.push;
  8098. var indexOf = arr.indexOf;
  8099. var class2type = {};
  8100. var toString = class2type.toString;
  8101. var hasOwn = class2type.hasOwnProperty;
  8102. var fnToString = hasOwn.toString;
  8103. var ObjectFunctionString = fnToString.call( Object );
  8104. var support = {};
  8105. var isFunction = function isFunction( obj ) {
  8106. // Support: Chrome <=57, Firefox <=52
  8107. // In some browsers, typeof returns "function" for HTML <object> elements
  8108. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  8109. // We don't want to classify *any* DOM node as a function.
  8110. return typeof obj === "function" && typeof obj.nodeType !== "number";
  8111. };
  8112. var isWindow = function isWindow( obj ) {
  8113. return obj != null && obj === obj.window;
  8114. };
  8115. var preservedScriptAttributes = {
  8116. type: true,
  8117. src: true,
  8118. nonce: true,
  8119. noModule: true
  8120. };
  8121. function DOMEval( code, node, doc ) {
  8122. doc = doc || document;
  8123. var i, val,
  8124. script = doc.createElement( "script" );
  8125. script.text = code;
  8126. if ( node ) {
  8127. for ( i in preservedScriptAttributes ) {
  8128. // Support: Firefox 64+, Edge 18+
  8129. // Some browsers don't support the "nonce" property on scripts.
  8130. // On the other hand, just using `getAttribute` is not enough as
  8131. // the `nonce` attribute is reset to an empty string whenever it
  8132. // becomes browsing-context connected.
  8133. // See https://github.com/whatwg/html/issues/2369
  8134. // See https://html.spec.whatwg.org/#nonce-attributes
  8135. // The `node.getAttribute` check was added for the sake of
  8136. // `jQuery.globalEval` so that it can fake a nonce-containing node
  8137. // via an object.
  8138. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  8139. if ( val ) {
  8140. script.setAttribute( i, val );
  8141. }
  8142. }
  8143. }
  8144. doc.head.appendChild( script ).parentNode.removeChild( script );
  8145. }
  8146. function toType( obj ) {
  8147. if ( obj == null ) {
  8148. return obj + "";
  8149. }
  8150. // Support: Android <=2.3 only (functionish RegExp)
  8151. return typeof obj === "object" || typeof obj === "function" ?
  8152. class2type[ toString.call( obj ) ] || "object" :
  8153. typeof obj;
  8154. }
  8155. /* global Symbol */
  8156. // Defining this global in .eslintrc.json would create a danger of using the global
  8157. // unguarded in another place, it seems safer to define global only for this module
  8158. var
  8159. version = "3.4.1",
  8160. // Define a local copy of jQuery
  8161. jQuery = function( selector, context ) {
  8162. // The jQuery object is actually just the init constructor 'enhanced'
  8163. // Need init if jQuery is called (just allow error to be thrown if not included)
  8164. return new jQuery.fn.init( selector, context );
  8165. },
  8166. // Support: Android <=4.0 only
  8167. // Make sure we trim BOM and NBSP
  8168. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  8169. jQuery.fn = jQuery.prototype = {
  8170. // The current version of jQuery being used
  8171. jquery: version,
  8172. constructor: jQuery,
  8173. // The default length of a jQuery object is 0
  8174. length: 0,
  8175. toArray: function() {
  8176. return slice.call( this );
  8177. },
  8178. // Get the Nth element in the matched element set OR
  8179. // Get the whole matched element set as a clean array
  8180. get: function( num ) {
  8181. // Return all the elements in a clean array
  8182. if ( num == null ) {
  8183. return slice.call( this );
  8184. }
  8185. // Return just the one element from the set
  8186. return num < 0 ? this[ num + this.length ] : this[ num ];
  8187. },
  8188. // Take an array of elements and push it onto the stack
  8189. // (returning the new matched element set)
  8190. pushStack: function( elems ) {
  8191. // Build a new jQuery matched element set
  8192. var ret = jQuery.merge( this.constructor(), elems );
  8193. // Add the old object onto the stack (as a reference)
  8194. ret.prevObject = this;
  8195. // Return the newly-formed element set
  8196. return ret;
  8197. },
  8198. // Execute a callback for every element in the matched set.
  8199. each: function( callback ) {
  8200. return jQuery.each( this, callback );
  8201. },
  8202. map: function( callback ) {
  8203. return this.pushStack( jQuery.map( this, function( elem, i ) {
  8204. return callback.call( elem, i, elem );
  8205. } ) );
  8206. },
  8207. slice: function() {
  8208. return this.pushStack( slice.apply( this, arguments ) );
  8209. },
  8210. first: function() {
  8211. return this.eq( 0 );
  8212. },
  8213. last: function() {
  8214. return this.eq( -1 );
  8215. },
  8216. eq: function( i ) {
  8217. var len = this.length,
  8218. j = +i + ( i < 0 ? len : 0 );
  8219. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  8220. },
  8221. end: function() {
  8222. return this.prevObject || this.constructor();
  8223. },
  8224. // For internal use only.
  8225. // Behaves like an Array's method, not like a jQuery method.
  8226. push: push,
  8227. sort: arr.sort,
  8228. splice: arr.splice
  8229. };
  8230. jQuery.extend = jQuery.fn.extend = function() {
  8231. var options, name, src, copy, copyIsArray, clone,
  8232. target = arguments[ 0 ] || {},
  8233. i = 1,
  8234. length = arguments.length,
  8235. deep = false;
  8236. // Handle a deep copy situation
  8237. if ( typeof target === "boolean" ) {
  8238. deep = target;
  8239. // Skip the boolean and the target
  8240. target = arguments[ i ] || {};
  8241. i++;
  8242. }
  8243. // Handle case when target is a string or something (possible in deep copy)
  8244. if ( typeof target !== "object" && !isFunction( target ) ) {
  8245. target = {};
  8246. }
  8247. // Extend jQuery itself if only one argument is passed
  8248. if ( i === length ) {
  8249. target = this;
  8250. i--;
  8251. }
  8252. for ( ; i < length; i++ ) {
  8253. // Only deal with non-null/undefined values
  8254. if ( ( options = arguments[ i ] ) != null ) {
  8255. // Extend the base object
  8256. for ( name in options ) {
  8257. copy = options[ name ];
  8258. // Prevent Object.prototype pollution
  8259. // Prevent never-ending loop
  8260. if ( name === "__proto__" || target === copy ) {
  8261. continue;
  8262. }
  8263. // Recurse if we're merging plain objects or arrays
  8264. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  8265. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  8266. src = target[ name ];
  8267. // Ensure proper type for the source value
  8268. if ( copyIsArray && !Array.isArray( src ) ) {
  8269. clone = [];
  8270. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  8271. clone = {};
  8272. } else {
  8273. clone = src;
  8274. }
  8275. copyIsArray = false;
  8276. // Never move original objects, clone them
  8277. target[ name ] = jQuery.extend( deep, clone, copy );
  8278. // Don't bring in undefined values
  8279. } else if ( copy !== undefined ) {
  8280. target[ name ] = copy;
  8281. }
  8282. }
  8283. }
  8284. }
  8285. // Return the modified object
  8286. return target;
  8287. };
  8288. jQuery.extend( {
  8289. // Unique for each copy of jQuery on the page
  8290. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  8291. // Assume jQuery is ready without the ready module
  8292. isReady: true,
  8293. error: function( msg ) {
  8294. throw new Error( msg );
  8295. },
  8296. noop: function() {},
  8297. isPlainObject: function( obj ) {
  8298. var proto, Ctor;
  8299. // Detect obvious negatives
  8300. // Use toString instead of jQuery.type to catch host objects
  8301. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  8302. return false;
  8303. }
  8304. proto = getProto( obj );
  8305. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  8306. if ( !proto ) {
  8307. return true;
  8308. }
  8309. // Objects with prototype are plain iff they were constructed by a global Object function
  8310. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  8311. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  8312. },
  8313. isEmptyObject: function( obj ) {
  8314. var name;
  8315. for ( name in obj ) {
  8316. return false;
  8317. }
  8318. return true;
  8319. },
  8320. // Evaluates a script in a global context
  8321. globalEval: function( code, options ) {
  8322. DOMEval( code, { nonce: options && options.nonce } );
  8323. },
  8324. each: function( obj, callback ) {
  8325. var length, i = 0;
  8326. if ( isArrayLike( obj ) ) {
  8327. length = obj.length;
  8328. for ( ; i < length; i++ ) {
  8329. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8330. break;
  8331. }
  8332. }
  8333. } else {
  8334. for ( i in obj ) {
  8335. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8336. break;
  8337. }
  8338. }
  8339. }
  8340. return obj;
  8341. },
  8342. // Support: Android <=4.0 only
  8343. trim: function( text ) {
  8344. return text == null ?
  8345. "" :
  8346. ( text + "" ).replace( rtrim, "" );
  8347. },
  8348. // results is for internal usage only
  8349. makeArray: function( arr, results ) {
  8350. var ret = results || [];
  8351. if ( arr != null ) {
  8352. if ( isArrayLike( Object( arr ) ) ) {
  8353. jQuery.merge( ret,
  8354. typeof arr === "string" ?
  8355. [ arr ] : arr
  8356. );
  8357. } else {
  8358. push.call( ret, arr );
  8359. }
  8360. }
  8361. return ret;
  8362. },
  8363. inArray: function( elem, arr, i ) {
  8364. return arr == null ? -1 : indexOf.call( arr, elem, i );
  8365. },
  8366. // Support: Android <=4.0 only, PhantomJS 1 only
  8367. // push.apply(_, arraylike) throws on ancient WebKit
  8368. merge: function( first, second ) {
  8369. var len = +second.length,
  8370. j = 0,
  8371. i = first.length;
  8372. for ( ; j < len; j++ ) {
  8373. first[ i++ ] = second[ j ];
  8374. }
  8375. first.length = i;
  8376. return first;
  8377. },
  8378. grep: function( elems, callback, invert ) {
  8379. var callbackInverse,
  8380. matches = [],
  8381. i = 0,
  8382. length = elems.length,
  8383. callbackExpect = !invert;
  8384. // Go through the array, only saving the items
  8385. // that pass the validator function
  8386. for ( ; i < length; i++ ) {
  8387. callbackInverse = !callback( elems[ i ], i );
  8388. if ( callbackInverse !== callbackExpect ) {
  8389. matches.push( elems[ i ] );
  8390. }
  8391. }
  8392. return matches;
  8393. },
  8394. // arg is for internal usage only
  8395. map: function( elems, callback, arg ) {
  8396. var length, value,
  8397. i = 0,
  8398. ret = [];
  8399. // Go through the array, translating each of the items to their new values
  8400. if ( isArrayLike( elems ) ) {
  8401. length = elems.length;
  8402. for ( ; i < length; i++ ) {
  8403. value = callback( elems[ i ], i, arg );
  8404. if ( value != null ) {
  8405. ret.push( value );
  8406. }
  8407. }
  8408. // Go through every key on the object,
  8409. } else {
  8410. for ( i in elems ) {
  8411. value = callback( elems[ i ], i, arg );
  8412. if ( value != null ) {
  8413. ret.push( value );
  8414. }
  8415. }
  8416. }
  8417. // Flatten any nested arrays
  8418. return concat.apply( [], ret );
  8419. },
  8420. // A global GUID counter for objects
  8421. guid: 1,
  8422. // jQuery.support is not used in Core but other projects attach their
  8423. // properties to it so it needs to exist.
  8424. support: support
  8425. } );
  8426. if ( typeof Symbol === "function" ) {
  8427. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  8428. }
  8429. // Populate the class2type map
  8430. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  8431. function( i, name ) {
  8432. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  8433. } );
  8434. function isArrayLike( obj ) {
  8435. // Support: real iOS 8.2 only (not reproducible in simulator)
  8436. // `in` check used to prevent JIT error (gh-2145)
  8437. // hasOwn isn't used here due to false negatives
  8438. // regarding Nodelist length in IE
  8439. var length = !!obj && "length" in obj && obj.length,
  8440. type = toType( obj );
  8441. if ( isFunction( obj ) || isWindow( obj ) ) {
  8442. return false;
  8443. }
  8444. return type === "array" || length === 0 ||
  8445. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  8446. }
  8447. var Sizzle =
  8448. /*!
  8449. * Sizzle CSS Selector Engine v2.3.4
  8450. * https://sizzlejs.com/
  8451. *
  8452. * Copyright JS Foundation and other contributors
  8453. * Released under the MIT license
  8454. * https://js.foundation/
  8455. *
  8456. * Date: 2019-04-08
  8457. */
  8458. (function( window ) {
  8459. var i,
  8460. support,
  8461. Expr,
  8462. getText,
  8463. isXML,
  8464. tokenize,
  8465. compile,
  8466. select,
  8467. outermostContext,
  8468. sortInput,
  8469. hasDuplicate,
  8470. // Local document vars
  8471. setDocument,
  8472. document,
  8473. docElem,
  8474. documentIsHTML,
  8475. rbuggyQSA,
  8476. rbuggyMatches,
  8477. matches,
  8478. contains,
  8479. // Instance-specific data
  8480. expando = "sizzle" + 1 * new Date(),
  8481. preferredDoc = window.document,
  8482. dirruns = 0,
  8483. done = 0,
  8484. classCache = createCache(),
  8485. tokenCache = createCache(),
  8486. compilerCache = createCache(),
  8487. nonnativeSelectorCache = createCache(),
  8488. sortOrder = function( a, b ) {
  8489. if ( a === b ) {
  8490. hasDuplicate = true;
  8491. }
  8492. return 0;
  8493. },
  8494. // Instance methods
  8495. hasOwn = ({}).hasOwnProperty,
  8496. arr = [],
  8497. pop = arr.pop,
  8498. push_native = arr.push,
  8499. push = arr.push,
  8500. slice = arr.slice,
  8501. // Use a stripped-down indexOf as it's faster than native
  8502. // https://jsperf.com/thor-indexof-vs-for/5
  8503. indexOf = function( list, elem ) {
  8504. var i = 0,
  8505. len = list.length;
  8506. for ( ; i < len; i++ ) {
  8507. if ( list[i] === elem ) {
  8508. return i;
  8509. }
  8510. }
  8511. return -1;
  8512. },
  8513. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  8514. // Regular expressions
  8515. // http://www.w3.org/TR/css3-selectors/#whitespace
  8516. whitespace = "[\\x20\\t\\r\\n\\f]",
  8517. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  8518. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  8519. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  8520. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  8521. // Operator (capture 2)
  8522. "*([*^$|!~]?=)" + whitespace +
  8523. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  8524. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  8525. "*\\]",
  8526. pseudos = ":(" + identifier + ")(?:\\((" +
  8527. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  8528. // 1. quoted (capture 3; capture 4 or capture 5)
  8529. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  8530. // 2. simple (capture 6)
  8531. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  8532. // 3. anything else (capture 2)
  8533. ".*" +
  8534. ")\\)|)",
  8535. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  8536. rwhitespace = new RegExp( whitespace + "+", "g" ),
  8537. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  8538. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  8539. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  8540. rdescend = new RegExp( whitespace + "|>" ),
  8541. rpseudo = new RegExp( pseudos ),
  8542. ridentifier = new RegExp( "^" + identifier + "$" ),
  8543. matchExpr = {
  8544. "ID": new RegExp( "^#(" + identifier + ")" ),
  8545. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  8546. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  8547. "ATTR": new RegExp( "^" + attributes ),
  8548. "PSEUDO": new RegExp( "^" + pseudos ),
  8549. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  8550. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  8551. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  8552. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  8553. // For use in libraries implementing .is()
  8554. // We use this for POS matching in `select`
  8555. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  8556. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  8557. },
  8558. rhtml = /HTML$/i,
  8559. rinputs = /^(?:input|select|textarea|button)$/i,
  8560. rheader = /^h\d$/i,
  8561. rnative = /^[^{]+\{\s*\[native \w/,
  8562. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  8563. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  8564. rsibling = /[+~]/,
  8565. // CSS escapes
  8566. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  8567. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  8568. funescape = function( _, escaped, escapedWhitespace ) {
  8569. var high = "0x" + escaped - 0x10000;
  8570. // NaN means non-codepoint
  8571. // Support: Firefox<24
  8572. // Workaround erroneous numeric interpretation of +"0x"
  8573. return high !== high || escapedWhitespace ?
  8574. escaped :
  8575. high < 0 ?
  8576. // BMP codepoint
  8577. String.fromCharCode( high + 0x10000 ) :
  8578. // Supplemental Plane codepoint (surrogate pair)
  8579. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  8580. },
  8581. // CSS string/identifier serialization
  8582. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  8583. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  8584. fcssescape = function( ch, asCodePoint ) {
  8585. if ( asCodePoint ) {
  8586. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  8587. if ( ch === "\0" ) {
  8588. return "\uFFFD";
  8589. }
  8590. // Control characters and (dependent upon position) numbers get escaped as code points
  8591. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  8592. }
  8593. // Other potentially-special ASCII characters get backslash-escaped
  8594. return "\\" + ch;
  8595. },
  8596. // Used for iframes
  8597. // See setDocument()
  8598. // Removing the function wrapper causes a "Permission Denied"
  8599. // error in IE
  8600. unloadHandler = function() {
  8601. setDocument();
  8602. },
  8603. inDisabledFieldset = addCombinator(
  8604. function( elem ) {
  8605. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  8606. },
  8607. { dir: "parentNode", next: "legend" }
  8608. );
  8609. // Optimize for push.apply( _, NodeList )
  8610. try {
  8611. push.apply(
  8612. (arr = slice.call( preferredDoc.childNodes )),
  8613. preferredDoc.childNodes
  8614. );
  8615. // Support: Android<4.0
  8616. // Detect silently failing push.apply
  8617. arr[ preferredDoc.childNodes.length ].nodeType;
  8618. } catch ( e ) {
  8619. push = { apply: arr.length ?
  8620. // Leverage slice if possible
  8621. function( target, els ) {
  8622. push_native.apply( target, slice.call(els) );
  8623. } :
  8624. // Support: IE<9
  8625. // Otherwise append directly
  8626. function( target, els ) {
  8627. var j = target.length,
  8628. i = 0;
  8629. // Can't trust NodeList.length
  8630. while ( (target[j++] = els[i++]) ) {}
  8631. target.length = j - 1;
  8632. }
  8633. };
  8634. }
  8635. function Sizzle( selector, context, results, seed ) {
  8636. var m, i, elem, nid, match, groups, newSelector,
  8637. newContext = context && context.ownerDocument,
  8638. // nodeType defaults to 9, since context defaults to document
  8639. nodeType = context ? context.nodeType : 9;
  8640. results = results || [];
  8641. // Return early from calls with invalid selector or context
  8642. if ( typeof selector !== "string" || !selector ||
  8643. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  8644. return results;
  8645. }
  8646. // Try to shortcut find operations (as opposed to filters) in HTML documents
  8647. if ( !seed ) {
  8648. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  8649. setDocument( context );
  8650. }
  8651. context = context || document;
  8652. if ( documentIsHTML ) {
  8653. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  8654. // (excepting DocumentFragment context, where the methods don't exist)
  8655. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  8656. // ID selector
  8657. if ( (m = match[1]) ) {
  8658. // Document context
  8659. if ( nodeType === 9 ) {
  8660. if ( (elem = context.getElementById( m )) ) {
  8661. // Support: IE, Opera, Webkit
  8662. // TODO: identify versions
  8663. // getElementById can match elements by name instead of ID
  8664. if ( elem.id === m ) {
  8665. results.push( elem );
  8666. return results;
  8667. }
  8668. } else {
  8669. return results;
  8670. }
  8671. // Element context
  8672. } else {
  8673. // Support: IE, Opera, Webkit
  8674. // TODO: identify versions
  8675. // getElementById can match elements by name instead of ID
  8676. if ( newContext && (elem = newContext.getElementById( m )) &&
  8677. contains( context, elem ) &&
  8678. elem.id === m ) {
  8679. results.push( elem );
  8680. return results;
  8681. }
  8682. }
  8683. // Type selector
  8684. } else if ( match[2] ) {
  8685. push.apply( results, context.getElementsByTagName( selector ) );
  8686. return results;
  8687. // Class selector
  8688. } else if ( (m = match[3]) && support.getElementsByClassName &&
  8689. context.getElementsByClassName ) {
  8690. push.apply( results, context.getElementsByClassName( m ) );
  8691. return results;
  8692. }
  8693. }
  8694. // Take advantage of querySelectorAll
  8695. if ( support.qsa &&
  8696. !nonnativeSelectorCache[ selector + " " ] &&
  8697. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  8698. // Support: IE 8 only
  8699. // Exclude object elements
  8700. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  8701. newSelector = selector;
  8702. newContext = context;
  8703. // qSA considers elements outside a scoping root when evaluating child or
  8704. // descendant combinators, which is not what we want.
  8705. // In such cases, we work around the behavior by prefixing every selector in the
  8706. // list with an ID selector referencing the scope context.
  8707. // Thanks to Andrew Dupont for this technique.
  8708. if ( nodeType === 1 && rdescend.test( selector ) ) {
  8709. // Capture the context ID, setting it first if necessary
  8710. if ( (nid = context.getAttribute( "id" )) ) {
  8711. nid = nid.replace( rcssescape, fcssescape );
  8712. } else {
  8713. context.setAttribute( "id", (nid = expando) );
  8714. }
  8715. // Prefix every selector in the list
  8716. groups = tokenize( selector );
  8717. i = groups.length;
  8718. while ( i-- ) {
  8719. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  8720. }
  8721. newSelector = groups.join( "," );
  8722. // Expand context for sibling selectors
  8723. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  8724. context;
  8725. }
  8726. try {
  8727. push.apply( results,
  8728. newContext.querySelectorAll( newSelector )
  8729. );
  8730. return results;
  8731. } catch ( qsaError ) {
  8732. nonnativeSelectorCache( selector, true );
  8733. } finally {
  8734. if ( nid === expando ) {
  8735. context.removeAttribute( "id" );
  8736. }
  8737. }
  8738. }
  8739. }
  8740. }
  8741. // All others
  8742. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  8743. }
  8744. /**
  8745. * Create key-value caches of limited size
  8746. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  8747. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  8748. * deleting the oldest entry
  8749. */
  8750. function createCache() {
  8751. var keys = [];
  8752. function cache( key, value ) {
  8753. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  8754. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  8755. // Only keep the most recent entries
  8756. delete cache[ keys.shift() ];
  8757. }
  8758. return (cache[ key + " " ] = value);
  8759. }
  8760. return cache;
  8761. }
  8762. /**
  8763. * Mark a function for special use by Sizzle
  8764. * @param {Function} fn The function to mark
  8765. */
  8766. function markFunction( fn ) {
  8767. fn[ expando ] = true;
  8768. return fn;
  8769. }
  8770. /**
  8771. * Support testing using an element
  8772. * @param {Function} fn Passed the created element and returns a boolean result
  8773. */
  8774. function assert( fn ) {
  8775. var el = document.createElement("fieldset");
  8776. try {
  8777. return !!fn( el );
  8778. } catch (e) {
  8779. return false;
  8780. } finally {
  8781. // Remove from its parent by default
  8782. if ( el.parentNode ) {
  8783. el.parentNode.removeChild( el );
  8784. }
  8785. // release memory in IE
  8786. el = null;
  8787. }
  8788. }
  8789. /**
  8790. * Adds the same handler for all of the specified attrs
  8791. * @param {String} attrs Pipe-separated list of attributes
  8792. * @param {Function} handler The method that will be applied
  8793. */
  8794. function addHandle( attrs, handler ) {
  8795. var arr = attrs.split("|"),
  8796. i = arr.length;
  8797. while ( i-- ) {
  8798. Expr.attrHandle[ arr[i] ] = handler;
  8799. }
  8800. }
  8801. /**
  8802. * Checks document order of two siblings
  8803. * @param {Element} a
  8804. * @param {Element} b
  8805. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  8806. */
  8807. function siblingCheck( a, b ) {
  8808. var cur = b && a,
  8809. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  8810. a.sourceIndex - b.sourceIndex;
  8811. // Use IE sourceIndex if available on both nodes
  8812. if ( diff ) {
  8813. return diff;
  8814. }
  8815. // Check if b follows a
  8816. if ( cur ) {
  8817. while ( (cur = cur.nextSibling) ) {
  8818. if ( cur === b ) {
  8819. return -1;
  8820. }
  8821. }
  8822. }
  8823. return a ? 1 : -1;
  8824. }
  8825. /**
  8826. * Returns a function to use in pseudos for input types
  8827. * @param {String} type
  8828. */
  8829. function createInputPseudo( type ) {
  8830. return function( elem ) {
  8831. var name = elem.nodeName.toLowerCase();
  8832. return name === "input" && elem.type === type;
  8833. };
  8834. }
  8835. /**
  8836. * Returns a function to use in pseudos for buttons
  8837. * @param {String} type
  8838. */
  8839. function createButtonPseudo( type ) {
  8840. return function( elem ) {
  8841. var name = elem.nodeName.toLowerCase();
  8842. return (name === "input" || name === "button") && elem.type === type;
  8843. };
  8844. }
  8845. /**
  8846. * Returns a function to use in pseudos for :enabled/:disabled
  8847. * @param {Boolean} disabled true for :disabled; false for :enabled
  8848. */
  8849. function createDisabledPseudo( disabled ) {
  8850. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  8851. return function( elem ) {
  8852. // Only certain elements can match :enabled or :disabled
  8853. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  8854. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  8855. if ( "form" in elem ) {
  8856. // Check for inherited disabledness on relevant non-disabled elements:
  8857. // * listed form-associated elements in a disabled fieldset
  8858. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  8859. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  8860. // * option elements in a disabled optgroup
  8861. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  8862. // All such elements have a "form" property.
  8863. if ( elem.parentNode && elem.disabled === false ) {
  8864. // Option elements defer to a parent optgroup if present
  8865. if ( "label" in elem ) {
  8866. if ( "label" in elem.parentNode ) {
  8867. return elem.parentNode.disabled === disabled;
  8868. } else {
  8869. return elem.disabled === disabled;
  8870. }
  8871. }
  8872. // Support: IE 6 - 11
  8873. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  8874. return elem.isDisabled === disabled ||
  8875. // Where there is no isDisabled, check manually
  8876. /* jshint -W018 */
  8877. elem.isDisabled !== !disabled &&
  8878. inDisabledFieldset( elem ) === disabled;
  8879. }
  8880. return elem.disabled === disabled;
  8881. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  8882. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  8883. // even exist on them, let alone have a boolean value.
  8884. } else if ( "label" in elem ) {
  8885. return elem.disabled === disabled;
  8886. }
  8887. // Remaining elements are neither :enabled nor :disabled
  8888. return false;
  8889. };
  8890. }
  8891. /**
  8892. * Returns a function to use in pseudos for positionals
  8893. * @param {Function} fn
  8894. */
  8895. function createPositionalPseudo( fn ) {
  8896. return markFunction(function( argument ) {
  8897. argument = +argument;
  8898. return markFunction(function( seed, matches ) {
  8899. var j,
  8900. matchIndexes = fn( [], seed.length, argument ),
  8901. i = matchIndexes.length;
  8902. // Match elements found at the specified indexes
  8903. while ( i-- ) {
  8904. if ( seed[ (j = matchIndexes[i]) ] ) {
  8905. seed[j] = !(matches[j] = seed[j]);
  8906. }
  8907. }
  8908. });
  8909. });
  8910. }
  8911. /**
  8912. * Checks a node for validity as a Sizzle context
  8913. * @param {Element|Object=} context
  8914. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  8915. */
  8916. function testContext( context ) {
  8917. return context && typeof context.getElementsByTagName !== "undefined" && context;
  8918. }
  8919. // Expose support vars for convenience
  8920. support = Sizzle.support = {};
  8921. /**
  8922. * Detects XML nodes
  8923. * @param {Element|Object} elem An element or a document
  8924. * @returns {Boolean} True iff elem is a non-HTML XML node
  8925. */
  8926. isXML = Sizzle.isXML = function( elem ) {
  8927. var namespace = elem.namespaceURI,
  8928. docElem = (elem.ownerDocument || elem).documentElement;
  8929. // Support: IE <=8
  8930. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  8931. // https://bugs.jquery.com/ticket/4833
  8932. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  8933. };
  8934. /**
  8935. * Sets document-related variables once based on the current document
  8936. * @param {Element|Object} [doc] An element or document object to use to set the document
  8937. * @returns {Object} Returns the current document
  8938. */
  8939. setDocument = Sizzle.setDocument = function( node ) {
  8940. var hasCompare, subWindow,
  8941. doc = node ? node.ownerDocument || node : preferredDoc;
  8942. // Return early if doc is invalid or already selected
  8943. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  8944. return document;
  8945. }
  8946. // Update global variables
  8947. document = doc;
  8948. docElem = document.documentElement;
  8949. documentIsHTML = !isXML( document );
  8950. // Support: IE 9-11, Edge
  8951. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  8952. if ( preferredDoc !== document &&
  8953. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  8954. // Support: IE 11, Edge
  8955. if ( subWindow.addEventListener ) {
  8956. subWindow.addEventListener( "unload", unloadHandler, false );
  8957. // Support: IE 9 - 10 only
  8958. } else if ( subWindow.attachEvent ) {
  8959. subWindow.attachEvent( "onunload", unloadHandler );
  8960. }
  8961. }
  8962. /* Attributes
  8963. ---------------------------------------------------------------------- */
  8964. // Support: IE<8
  8965. // Verify that getAttribute really returns attributes and not properties
  8966. // (excepting IE8 booleans)
  8967. support.attributes = assert(function( el ) {
  8968. el.className = "i";
  8969. return !el.getAttribute("className");
  8970. });
  8971. /* getElement(s)By*
  8972. ---------------------------------------------------------------------- */
  8973. // Check if getElementsByTagName("*") returns only elements
  8974. support.getElementsByTagName = assert(function( el ) {
  8975. el.appendChild( document.createComment("") );
  8976. return !el.getElementsByTagName("*").length;
  8977. });
  8978. // Support: IE<9
  8979. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  8980. // Support: IE<10
  8981. // Check if getElementById returns elements by name
  8982. // The broken getElementById methods don't pick up programmatically-set names,
  8983. // so use a roundabout getElementsByName test
  8984. support.getById = assert(function( el ) {
  8985. docElem.appendChild( el ).id = expando;
  8986. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  8987. });
  8988. // ID filter and find
  8989. if ( support.getById ) {
  8990. Expr.filter["ID"] = function( id ) {
  8991. var attrId = id.replace( runescape, funescape );
  8992. return function( elem ) {
  8993. return elem.getAttribute("id") === attrId;
  8994. };
  8995. };
  8996. Expr.find["ID"] = function( id, context ) {
  8997. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8998. var elem = context.getElementById( id );
  8999. return elem ? [ elem ] : [];
  9000. }
  9001. };
  9002. } else {
  9003. Expr.filter["ID"] = function( id ) {
  9004. var attrId = id.replace( runescape, funescape );
  9005. return function( elem ) {
  9006. var node = typeof elem.getAttributeNode !== "undefined" &&
  9007. elem.getAttributeNode("id");
  9008. return node && node.value === attrId;
  9009. };
  9010. };
  9011. // Support: IE 6 - 7 only
  9012. // getElementById is not reliable as a find shortcut
  9013. Expr.find["ID"] = function( id, context ) {
  9014. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  9015. var node, i, elems,
  9016. elem = context.getElementById( id );
  9017. if ( elem ) {
  9018. // Verify the id attribute
  9019. node = elem.getAttributeNode("id");
  9020. if ( node && node.value === id ) {
  9021. return [ elem ];
  9022. }
  9023. // Fall back on getElementsByName
  9024. elems = context.getElementsByName( id );
  9025. i = 0;
  9026. while ( (elem = elems[i++]) ) {
  9027. node = elem.getAttributeNode("id");
  9028. if ( node && node.value === id ) {
  9029. return [ elem ];
  9030. }
  9031. }
  9032. }
  9033. return [];
  9034. }
  9035. };
  9036. }
  9037. // Tag
  9038. Expr.find["TAG"] = support.getElementsByTagName ?
  9039. function( tag, context ) {
  9040. if ( typeof context.getElementsByTagName !== "undefined" ) {
  9041. return context.getElementsByTagName( tag );
  9042. // DocumentFragment nodes don't have gEBTN
  9043. } else if ( support.qsa ) {
  9044. return context.querySelectorAll( tag );
  9045. }
  9046. } :
  9047. function( tag, context ) {
  9048. var elem,
  9049. tmp = [],
  9050. i = 0,
  9051. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  9052. results = context.getElementsByTagName( tag );
  9053. // Filter out possible comments
  9054. if ( tag === "*" ) {
  9055. while ( (elem = results[i++]) ) {
  9056. if ( elem.nodeType === 1 ) {
  9057. tmp.push( elem );
  9058. }
  9059. }
  9060. return tmp;
  9061. }
  9062. return results;
  9063. };
  9064. // Class
  9065. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  9066. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  9067. return context.getElementsByClassName( className );
  9068. }
  9069. };
  9070. /* QSA/matchesSelector
  9071. ---------------------------------------------------------------------- */
  9072. // QSA and matchesSelector support
  9073. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  9074. rbuggyMatches = [];
  9075. // qSa(:focus) reports false when true (Chrome 21)
  9076. // We allow this because of a bug in IE8/9 that throws an error
  9077. // whenever `document.activeElement` is accessed on an iframe
  9078. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  9079. // See https://bugs.jquery.com/ticket/13378
  9080. rbuggyQSA = [];
  9081. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  9082. // Build QSA regex
  9083. // Regex strategy adopted from Diego Perini
  9084. assert(function( el ) {
  9085. // Select is set to empty string on purpose
  9086. // This is to test IE's treatment of not explicitly
  9087. // setting a boolean content attribute,
  9088. // since its presence should be enough
  9089. // https://bugs.jquery.com/ticket/12359
  9090. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  9091. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  9092. "<option selected=''></option></select>";
  9093. // Support: IE8, Opera 11-12.16
  9094. // Nothing should be selected when empty strings follow ^= or $= or *=
  9095. // The test attribute must be unknown in Opera but "safe" for WinRT
  9096. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  9097. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  9098. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  9099. }
  9100. // Support: IE8
  9101. // Boolean attributes and "value" are not treated correctly
  9102. if ( !el.querySelectorAll("[selected]").length ) {
  9103. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  9104. }
  9105. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  9106. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  9107. rbuggyQSA.push("~=");
  9108. }
  9109. // Webkit/Opera - :checked should return selected option elements
  9110. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9111. // IE8 throws error here and will not see later tests
  9112. if ( !el.querySelectorAll(":checked").length ) {
  9113. rbuggyQSA.push(":checked");
  9114. }
  9115. // Support: Safari 8+, iOS 8+
  9116. // https://bugs.webkit.org/show_bug.cgi?id=136851
  9117. // In-page `selector#id sibling-combinator selector` fails
  9118. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  9119. rbuggyQSA.push(".#.+[+~]");
  9120. }
  9121. });
  9122. assert(function( el ) {
  9123. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  9124. "<select disabled='disabled'><option/></select>";
  9125. // Support: Windows 8 Native Apps
  9126. // The type and name attributes are restricted during .innerHTML assignment
  9127. var input = document.createElement("input");
  9128. input.setAttribute( "type", "hidden" );
  9129. el.appendChild( input ).setAttribute( "name", "D" );
  9130. // Support: IE8
  9131. // Enforce case-sensitivity of name attribute
  9132. if ( el.querySelectorAll("[name=d]").length ) {
  9133. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  9134. }
  9135. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  9136. // IE8 throws error here and will not see later tests
  9137. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  9138. rbuggyQSA.push( ":enabled", ":disabled" );
  9139. }
  9140. // Support: IE9-11+
  9141. // IE's :disabled selector does not pick up the children of disabled fieldsets
  9142. docElem.appendChild( el ).disabled = true;
  9143. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  9144. rbuggyQSA.push( ":enabled", ":disabled" );
  9145. }
  9146. // Opera 10-11 does not throw on post-comma invalid pseudos
  9147. el.querySelectorAll("*,:x");
  9148. rbuggyQSA.push(",.*:");
  9149. });
  9150. }
  9151. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  9152. docElem.webkitMatchesSelector ||
  9153. docElem.mozMatchesSelector ||
  9154. docElem.oMatchesSelector ||
  9155. docElem.msMatchesSelector) )) ) {
  9156. assert(function( el ) {
  9157. // Check to see if it's possible to do matchesSelector
  9158. // on a disconnected node (IE 9)
  9159. support.disconnectedMatch = matches.call( el, "*" );
  9160. // This should fail with an exception
  9161. // Gecko does not error, returns false instead
  9162. matches.call( el, "[s!='']:x" );
  9163. rbuggyMatches.push( "!=", pseudos );
  9164. });
  9165. }
  9166. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  9167. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  9168. /* Contains
  9169. ---------------------------------------------------------------------- */
  9170. hasCompare = rnative.test( docElem.compareDocumentPosition );
  9171. // Element contains another
  9172. // Purposefully self-exclusive
  9173. // As in, an element does not contain itself
  9174. contains = hasCompare || rnative.test( docElem.contains ) ?
  9175. function( a, b ) {
  9176. var adown = a.nodeType === 9 ? a.documentElement : a,
  9177. bup = b && b.parentNode;
  9178. return a === bup || !!( bup && bup.nodeType === 1 && (
  9179. adown.contains ?
  9180. adown.contains( bup ) :
  9181. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  9182. ));
  9183. } :
  9184. function( a, b ) {
  9185. if ( b ) {
  9186. while ( (b = b.parentNode) ) {
  9187. if ( b === a ) {
  9188. return true;
  9189. }
  9190. }
  9191. }
  9192. return false;
  9193. };
  9194. /* Sorting
  9195. ---------------------------------------------------------------------- */
  9196. // Document order sorting
  9197. sortOrder = hasCompare ?
  9198. function( a, b ) {
  9199. // Flag for duplicate removal
  9200. if ( a === b ) {
  9201. hasDuplicate = true;
  9202. return 0;
  9203. }
  9204. // Sort on method existence if only one input has compareDocumentPosition
  9205. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  9206. if ( compare ) {
  9207. return compare;
  9208. }
  9209. // Calculate position if both inputs belong to the same document
  9210. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  9211. a.compareDocumentPosition( b ) :
  9212. // Otherwise we know they are disconnected
  9213. 1;
  9214. // Disconnected nodes
  9215. if ( compare & 1 ||
  9216. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  9217. // Choose the first element that is related to our preferred document
  9218. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  9219. return -1;
  9220. }
  9221. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  9222. return 1;
  9223. }
  9224. // Maintain original order
  9225. return sortInput ?
  9226. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9227. 0;
  9228. }
  9229. return compare & 4 ? -1 : 1;
  9230. } :
  9231. function( a, b ) {
  9232. // Exit early if the nodes are identical
  9233. if ( a === b ) {
  9234. hasDuplicate = true;
  9235. return 0;
  9236. }
  9237. var cur,
  9238. i = 0,
  9239. aup = a.parentNode,
  9240. bup = b.parentNode,
  9241. ap = [ a ],
  9242. bp = [ b ];
  9243. // Parentless nodes are either documents or disconnected
  9244. if ( !aup || !bup ) {
  9245. return a === document ? -1 :
  9246. b === document ? 1 :
  9247. aup ? -1 :
  9248. bup ? 1 :
  9249. sortInput ?
  9250. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9251. 0;
  9252. // If the nodes are siblings, we can do a quick check
  9253. } else if ( aup === bup ) {
  9254. return siblingCheck( a, b );
  9255. }
  9256. // Otherwise we need full lists of their ancestors for comparison
  9257. cur = a;
  9258. while ( (cur = cur.parentNode) ) {
  9259. ap.unshift( cur );
  9260. }
  9261. cur = b;
  9262. while ( (cur = cur.parentNode) ) {
  9263. bp.unshift( cur );
  9264. }
  9265. // Walk down the tree looking for a discrepancy
  9266. while ( ap[i] === bp[i] ) {
  9267. i++;
  9268. }
  9269. return i ?
  9270. // Do a sibling check if the nodes have a common ancestor
  9271. siblingCheck( ap[i], bp[i] ) :
  9272. // Otherwise nodes in our document sort first
  9273. ap[i] === preferredDoc ? -1 :
  9274. bp[i] === preferredDoc ? 1 :
  9275. 0;
  9276. };
  9277. return document;
  9278. };
  9279. Sizzle.matches = function( expr, elements ) {
  9280. return Sizzle( expr, null, null, elements );
  9281. };
  9282. Sizzle.matchesSelector = function( elem, expr ) {
  9283. // Set document vars if needed
  9284. if ( ( elem.ownerDocument || elem ) !== document ) {
  9285. setDocument( elem );
  9286. }
  9287. if ( support.matchesSelector && documentIsHTML &&
  9288. !nonnativeSelectorCache[ expr + " " ] &&
  9289. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  9290. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  9291. try {
  9292. var ret = matches.call( elem, expr );
  9293. // IE 9's matchesSelector returns false on disconnected nodes
  9294. if ( ret || support.disconnectedMatch ||
  9295. // As well, disconnected nodes are said to be in a document
  9296. // fragment in IE 9
  9297. elem.document && elem.document.nodeType !== 11 ) {
  9298. return ret;
  9299. }
  9300. } catch (e) {
  9301. nonnativeSelectorCache( expr, true );
  9302. }
  9303. }
  9304. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  9305. };
  9306. Sizzle.contains = function( context, elem ) {
  9307. // Set document vars if needed
  9308. if ( ( context.ownerDocument || context ) !== document ) {
  9309. setDocument( context );
  9310. }
  9311. return contains( context, elem );
  9312. };
  9313. Sizzle.attr = function( elem, name ) {
  9314. // Set document vars if needed
  9315. if ( ( elem.ownerDocument || elem ) !== document ) {
  9316. setDocument( elem );
  9317. }
  9318. var fn = Expr.attrHandle[ name.toLowerCase() ],
  9319. // Don't get fooled by Object.prototype properties (jQuery #13807)
  9320. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  9321. fn( elem, name, !documentIsHTML ) :
  9322. undefined;
  9323. return val !== undefined ?
  9324. val :
  9325. support.attributes || !documentIsHTML ?
  9326. elem.getAttribute( name ) :
  9327. (val = elem.getAttributeNode(name)) && val.specified ?
  9328. val.value :
  9329. null;
  9330. };
  9331. Sizzle.escape = function( sel ) {
  9332. return (sel + "").replace( rcssescape, fcssescape );
  9333. };
  9334. Sizzle.error = function( msg ) {
  9335. throw new Error( "Syntax error, unrecognized expression: " + msg );
  9336. };
  9337. /**
  9338. * Document sorting and removing duplicates
  9339. * @param {ArrayLike} results
  9340. */
  9341. Sizzle.uniqueSort = function( results ) {
  9342. var elem,
  9343. duplicates = [],
  9344. j = 0,
  9345. i = 0;
  9346. // Unless we *know* we can detect duplicates, assume their presence
  9347. hasDuplicate = !support.detectDuplicates;
  9348. sortInput = !support.sortStable && results.slice( 0 );
  9349. results.sort( sortOrder );
  9350. if ( hasDuplicate ) {
  9351. while ( (elem = results[i++]) ) {
  9352. if ( elem === results[ i ] ) {
  9353. j = duplicates.push( i );
  9354. }
  9355. }
  9356. while ( j-- ) {
  9357. results.splice( duplicates[ j ], 1 );
  9358. }
  9359. }
  9360. // Clear input after sorting to release objects
  9361. // See https://github.com/jquery/sizzle/pull/225
  9362. sortInput = null;
  9363. return results;
  9364. };
  9365. /**
  9366. * Utility function for retrieving the text value of an array of DOM nodes
  9367. * @param {Array|Element} elem
  9368. */
  9369. getText = Sizzle.getText = function( elem ) {
  9370. var node,
  9371. ret = "",
  9372. i = 0,
  9373. nodeType = elem.nodeType;
  9374. if ( !nodeType ) {
  9375. // If no nodeType, this is expected to be an array
  9376. while ( (node = elem[i++]) ) {
  9377. // Do not traverse comment nodes
  9378. ret += getText( node );
  9379. }
  9380. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  9381. // Use textContent for elements
  9382. // innerText usage removed for consistency of new lines (jQuery #11153)
  9383. if ( typeof elem.textContent === "string" ) {
  9384. return elem.textContent;
  9385. } else {
  9386. // Traverse its children
  9387. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9388. ret += getText( elem );
  9389. }
  9390. }
  9391. } else if ( nodeType === 3 || nodeType === 4 ) {
  9392. return elem.nodeValue;
  9393. }
  9394. // Do not include comment or processing instruction nodes
  9395. return ret;
  9396. };
  9397. Expr = Sizzle.selectors = {
  9398. // Can be adjusted by the user
  9399. cacheLength: 50,
  9400. createPseudo: markFunction,
  9401. match: matchExpr,
  9402. attrHandle: {},
  9403. find: {},
  9404. relative: {
  9405. ">": { dir: "parentNode", first: true },
  9406. " ": { dir: "parentNode" },
  9407. "+": { dir: "previousSibling", first: true },
  9408. "~": { dir: "previousSibling" }
  9409. },
  9410. preFilter: {
  9411. "ATTR": function( match ) {
  9412. match[1] = match[1].replace( runescape, funescape );
  9413. // Move the given value to match[3] whether quoted or unquoted
  9414. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  9415. if ( match[2] === "~=" ) {
  9416. match[3] = " " + match[3] + " ";
  9417. }
  9418. return match.slice( 0, 4 );
  9419. },
  9420. "CHILD": function( match ) {
  9421. /* matches from matchExpr["CHILD"]
  9422. 1 type (only|nth|...)
  9423. 2 what (child|of-type)
  9424. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  9425. 4 xn-component of xn+y argument ([+-]?\d*n|)
  9426. 5 sign of xn-component
  9427. 6 x of xn-component
  9428. 7 sign of y-component
  9429. 8 y of y-component
  9430. */
  9431. match[1] = match[1].toLowerCase();
  9432. if ( match[1].slice( 0, 3 ) === "nth" ) {
  9433. // nth-* requires argument
  9434. if ( !match[3] ) {
  9435. Sizzle.error( match[0] );
  9436. }
  9437. // numeric x and y parameters for Expr.filter.CHILD
  9438. // remember that false/true cast respectively to 0/1
  9439. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  9440. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  9441. // other types prohibit arguments
  9442. } else if ( match[3] ) {
  9443. Sizzle.error( match[0] );
  9444. }
  9445. return match;
  9446. },
  9447. "PSEUDO": function( match ) {
  9448. var excess,
  9449. unquoted = !match[6] && match[2];
  9450. if ( matchExpr["CHILD"].test( match[0] ) ) {
  9451. return null;
  9452. }
  9453. // Accept quoted arguments as-is
  9454. if ( match[3] ) {
  9455. match[2] = match[4] || match[5] || "";
  9456. // Strip excess characters from unquoted arguments
  9457. } else if ( unquoted && rpseudo.test( unquoted ) &&
  9458. // Get excess from tokenize (recursively)
  9459. (excess = tokenize( unquoted, true )) &&
  9460. // advance to the next closing parenthesis
  9461. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  9462. // excess is a negative index
  9463. match[0] = match[0].slice( 0, excess );
  9464. match[2] = unquoted.slice( 0, excess );
  9465. }
  9466. // Return only captures needed by the pseudo filter method (type and argument)
  9467. return match.slice( 0, 3 );
  9468. }
  9469. },
  9470. filter: {
  9471. "TAG": function( nodeNameSelector ) {
  9472. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  9473. return nodeNameSelector === "*" ?
  9474. function() { return true; } :
  9475. function( elem ) {
  9476. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  9477. };
  9478. },
  9479. "CLASS": function( className ) {
  9480. var pattern = classCache[ className + " " ];
  9481. return pattern ||
  9482. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  9483. classCache( className, function( elem ) {
  9484. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  9485. });
  9486. },
  9487. "ATTR": function( name, operator, check ) {
  9488. return function( elem ) {
  9489. var result = Sizzle.attr( elem, name );
  9490. if ( result == null ) {
  9491. return operator === "!=";
  9492. }
  9493. if ( !operator ) {
  9494. return true;
  9495. }
  9496. result += "";
  9497. return operator === "=" ? result === check :
  9498. operator === "!=" ? result !== check :
  9499. operator === "^=" ? check && result.indexOf( check ) === 0 :
  9500. operator === "*=" ? check && result.indexOf( check ) > -1 :
  9501. operator === "$=" ? check && result.slice( -check.length ) === check :
  9502. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  9503. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  9504. false;
  9505. };
  9506. },
  9507. "CHILD": function( type, what, argument, first, last ) {
  9508. var simple = type.slice( 0, 3 ) !== "nth",
  9509. forward = type.slice( -4 ) !== "last",
  9510. ofType = what === "of-type";
  9511. return first === 1 && last === 0 ?
  9512. // Shortcut for :nth-*(n)
  9513. function( elem ) {
  9514. return !!elem.parentNode;
  9515. } :
  9516. function( elem, context, xml ) {
  9517. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  9518. dir = simple !== forward ? "nextSibling" : "previousSibling",
  9519. parent = elem.parentNode,
  9520. name = ofType && elem.nodeName.toLowerCase(),
  9521. useCache = !xml && !ofType,
  9522. diff = false;
  9523. if ( parent ) {
  9524. // :(first|last|only)-(child|of-type)
  9525. if ( simple ) {
  9526. while ( dir ) {
  9527. node = elem;
  9528. while ( (node = node[ dir ]) ) {
  9529. if ( ofType ?
  9530. node.nodeName.toLowerCase() === name :
  9531. node.nodeType === 1 ) {
  9532. return false;
  9533. }
  9534. }
  9535. // Reverse direction for :only-* (if we haven't yet done so)
  9536. start = dir = type === "only" && !start && "nextSibling";
  9537. }
  9538. return true;
  9539. }
  9540. start = [ forward ? parent.firstChild : parent.lastChild ];
  9541. // non-xml :nth-child(...) stores cache data on `parent`
  9542. if ( forward && useCache ) {
  9543. // Seek `elem` from a previously-cached index
  9544. // ...in a gzip-friendly way
  9545. node = parent;
  9546. outerCache = node[ expando ] || (node[ expando ] = {});
  9547. // Support: IE <9 only
  9548. // Defend against cloned attroperties (jQuery gh-1709)
  9549. uniqueCache = outerCache[ node.uniqueID ] ||
  9550. (outerCache[ node.uniqueID ] = {});
  9551. cache = uniqueCache[ type ] || [];
  9552. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9553. diff = nodeIndex && cache[ 2 ];
  9554. node = nodeIndex && parent.childNodes[ nodeIndex ];
  9555. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9556. // Fallback to seeking `elem` from the start
  9557. (diff = nodeIndex = 0) || start.pop()) ) {
  9558. // When found, cache indexes on `parent` and break
  9559. if ( node.nodeType === 1 && ++diff && node === elem ) {
  9560. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  9561. break;
  9562. }
  9563. }
  9564. } else {
  9565. // Use previously-cached element index if available
  9566. if ( useCache ) {
  9567. // ...in a gzip-friendly way
  9568. node = elem;
  9569. outerCache = node[ expando ] || (node[ expando ] = {});
  9570. // Support: IE <9 only
  9571. // Defend against cloned attroperties (jQuery gh-1709)
  9572. uniqueCache = outerCache[ node.uniqueID ] ||
  9573. (outerCache[ node.uniqueID ] = {});
  9574. cache = uniqueCache[ type ] || [];
  9575. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9576. diff = nodeIndex;
  9577. }
  9578. // xml :nth-child(...)
  9579. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  9580. if ( diff === false ) {
  9581. // Use the same loop as above to seek `elem` from the start
  9582. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9583. (diff = nodeIndex = 0) || start.pop()) ) {
  9584. if ( ( ofType ?
  9585. node.nodeName.toLowerCase() === name :
  9586. node.nodeType === 1 ) &&
  9587. ++diff ) {
  9588. // Cache the index of each encountered element
  9589. if ( useCache ) {
  9590. outerCache = node[ expando ] || (node[ expando ] = {});
  9591. // Support: IE <9 only
  9592. // Defend against cloned attroperties (jQuery gh-1709)
  9593. uniqueCache = outerCache[ node.uniqueID ] ||
  9594. (outerCache[ node.uniqueID ] = {});
  9595. uniqueCache[ type ] = [ dirruns, diff ];
  9596. }
  9597. if ( node === elem ) {
  9598. break;
  9599. }
  9600. }
  9601. }
  9602. }
  9603. }
  9604. // Incorporate the offset, then check against cycle size
  9605. diff -= last;
  9606. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  9607. }
  9608. };
  9609. },
  9610. "PSEUDO": function( pseudo, argument ) {
  9611. // pseudo-class names are case-insensitive
  9612. // http://www.w3.org/TR/selectors/#pseudo-classes
  9613. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  9614. // Remember that setFilters inherits from pseudos
  9615. var args,
  9616. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  9617. Sizzle.error( "unsupported pseudo: " + pseudo );
  9618. // The user may use createPseudo to indicate that
  9619. // arguments are needed to create the filter function
  9620. // just as Sizzle does
  9621. if ( fn[ expando ] ) {
  9622. return fn( argument );
  9623. }
  9624. // But maintain support for old signatures
  9625. if ( fn.length > 1 ) {
  9626. args = [ pseudo, pseudo, "", argument ];
  9627. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  9628. markFunction(function( seed, matches ) {
  9629. var idx,
  9630. matched = fn( seed, argument ),
  9631. i = matched.length;
  9632. while ( i-- ) {
  9633. idx = indexOf( seed, matched[i] );
  9634. seed[ idx ] = !( matches[ idx ] = matched[i] );
  9635. }
  9636. }) :
  9637. function( elem ) {
  9638. return fn( elem, 0, args );
  9639. };
  9640. }
  9641. return fn;
  9642. }
  9643. },
  9644. pseudos: {
  9645. // Potentially complex pseudos
  9646. "not": markFunction(function( selector ) {
  9647. // Trim the selector passed to compile
  9648. // to avoid treating leading and trailing
  9649. // spaces as combinators
  9650. var input = [],
  9651. results = [],
  9652. matcher = compile( selector.replace( rtrim, "$1" ) );
  9653. return matcher[ expando ] ?
  9654. markFunction(function( seed, matches, context, xml ) {
  9655. var elem,
  9656. unmatched = matcher( seed, null, xml, [] ),
  9657. i = seed.length;
  9658. // Match elements unmatched by `matcher`
  9659. while ( i-- ) {
  9660. if ( (elem = unmatched[i]) ) {
  9661. seed[i] = !(matches[i] = elem);
  9662. }
  9663. }
  9664. }) :
  9665. function( elem, context, xml ) {
  9666. input[0] = elem;
  9667. matcher( input, null, xml, results );
  9668. // Don't keep the element (issue #299)
  9669. input[0] = null;
  9670. return !results.pop();
  9671. };
  9672. }),
  9673. "has": markFunction(function( selector ) {
  9674. return function( elem ) {
  9675. return Sizzle( selector, elem ).length > 0;
  9676. };
  9677. }),
  9678. "contains": markFunction(function( text ) {
  9679. text = text.replace( runescape, funescape );
  9680. return function( elem ) {
  9681. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  9682. };
  9683. }),
  9684. // "Whether an element is represented by a :lang() selector
  9685. // is based solely on the element's language value
  9686. // being equal to the identifier C,
  9687. // or beginning with the identifier C immediately followed by "-".
  9688. // The matching of C against the element's language value is performed case-insensitively.
  9689. // The identifier C does not have to be a valid language name."
  9690. // http://www.w3.org/TR/selectors/#lang-pseudo
  9691. "lang": markFunction( function( lang ) {
  9692. // lang value must be a valid identifier
  9693. if ( !ridentifier.test(lang || "") ) {
  9694. Sizzle.error( "unsupported lang: " + lang );
  9695. }
  9696. lang = lang.replace( runescape, funescape ).toLowerCase();
  9697. return function( elem ) {
  9698. var elemLang;
  9699. do {
  9700. if ( (elemLang = documentIsHTML ?
  9701. elem.lang :
  9702. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  9703. elemLang = elemLang.toLowerCase();
  9704. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  9705. }
  9706. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  9707. return false;
  9708. };
  9709. }),
  9710. // Miscellaneous
  9711. "target": function( elem ) {
  9712. var hash = window.location && window.location.hash;
  9713. return hash && hash.slice( 1 ) === elem.id;
  9714. },
  9715. "root": function( elem ) {
  9716. return elem === docElem;
  9717. },
  9718. "focus": function( elem ) {
  9719. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  9720. },
  9721. // Boolean properties
  9722. "enabled": createDisabledPseudo( false ),
  9723. "disabled": createDisabledPseudo( true ),
  9724. "checked": function( elem ) {
  9725. // In CSS3, :checked should return both checked and selected elements
  9726. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9727. var nodeName = elem.nodeName.toLowerCase();
  9728. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  9729. },
  9730. "selected": function( elem ) {
  9731. // Accessing this property makes selected-by-default
  9732. // options in Safari work properly
  9733. if ( elem.parentNode ) {
  9734. elem.parentNode.selectedIndex;
  9735. }
  9736. return elem.selected === true;
  9737. },
  9738. // Contents
  9739. "empty": function( elem ) {
  9740. // http://www.w3.org/TR/selectors/#empty-pseudo
  9741. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  9742. // but not by others (comment: 8; processing instruction: 7; etc.)
  9743. // nodeType < 6 works because attributes (2) do not appear as children
  9744. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9745. if ( elem.nodeType < 6 ) {
  9746. return false;
  9747. }
  9748. }
  9749. return true;
  9750. },
  9751. "parent": function( elem ) {
  9752. return !Expr.pseudos["empty"]( elem );
  9753. },
  9754. // Element/input types
  9755. "header": function( elem ) {
  9756. return rheader.test( elem.nodeName );
  9757. },
  9758. "input": function( elem ) {
  9759. return rinputs.test( elem.nodeName );
  9760. },
  9761. "button": function( elem ) {
  9762. var name = elem.nodeName.toLowerCase();
  9763. return name === "input" && elem.type === "button" || name === "button";
  9764. },
  9765. "text": function( elem ) {
  9766. var attr;
  9767. return elem.nodeName.toLowerCase() === "input" &&
  9768. elem.type === "text" &&
  9769. // Support: IE<8
  9770. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  9771. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  9772. },
  9773. // Position-in-collection
  9774. "first": createPositionalPseudo(function() {
  9775. return [ 0 ];
  9776. }),
  9777. "last": createPositionalPseudo(function( matchIndexes, length ) {
  9778. return [ length - 1 ];
  9779. }),
  9780. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9781. return [ argument < 0 ? argument + length : argument ];
  9782. }),
  9783. "even": createPositionalPseudo(function( matchIndexes, length ) {
  9784. var i = 0;
  9785. for ( ; i < length; i += 2 ) {
  9786. matchIndexes.push( i );
  9787. }
  9788. return matchIndexes;
  9789. }),
  9790. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  9791. var i = 1;
  9792. for ( ; i < length; i += 2 ) {
  9793. matchIndexes.push( i );
  9794. }
  9795. return matchIndexes;
  9796. }),
  9797. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9798. var i = argument < 0 ?
  9799. argument + length :
  9800. argument > length ?
  9801. length :
  9802. argument;
  9803. for ( ; --i >= 0; ) {
  9804. matchIndexes.push( i );
  9805. }
  9806. return matchIndexes;
  9807. }),
  9808. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9809. var i = argument < 0 ? argument + length : argument;
  9810. for ( ; ++i < length; ) {
  9811. matchIndexes.push( i );
  9812. }
  9813. return matchIndexes;
  9814. })
  9815. }
  9816. };
  9817. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  9818. // Add button/input type pseudos
  9819. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  9820. Expr.pseudos[ i ] = createInputPseudo( i );
  9821. }
  9822. for ( i in { submit: true, reset: true } ) {
  9823. Expr.pseudos[ i ] = createButtonPseudo( i );
  9824. }
  9825. // Easy API for creating new setFilters
  9826. function setFilters() {}
  9827. setFilters.prototype = Expr.filters = Expr.pseudos;
  9828. Expr.setFilters = new setFilters();
  9829. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  9830. var matched, match, tokens, type,
  9831. soFar, groups, preFilters,
  9832. cached = tokenCache[ selector + " " ];
  9833. if ( cached ) {
  9834. return parseOnly ? 0 : cached.slice( 0 );
  9835. }
  9836. soFar = selector;
  9837. groups = [];
  9838. preFilters = Expr.preFilter;
  9839. while ( soFar ) {
  9840. // Comma and first run
  9841. if ( !matched || (match = rcomma.exec( soFar )) ) {
  9842. if ( match ) {
  9843. // Don't consume trailing commas as valid
  9844. soFar = soFar.slice( match[0].length ) || soFar;
  9845. }
  9846. groups.push( (tokens = []) );
  9847. }
  9848. matched = false;
  9849. // Combinators
  9850. if ( (match = rcombinators.exec( soFar )) ) {
  9851. matched = match.shift();
  9852. tokens.push({
  9853. value: matched,
  9854. // Cast descendant combinators to space
  9855. type: match[0].replace( rtrim, " " )
  9856. });
  9857. soFar = soFar.slice( matched.length );
  9858. }
  9859. // Filters
  9860. for ( type in Expr.filter ) {
  9861. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  9862. (match = preFilters[ type ]( match ))) ) {
  9863. matched = match.shift();
  9864. tokens.push({
  9865. value: matched,
  9866. type: type,
  9867. matches: match
  9868. });
  9869. soFar = soFar.slice( matched.length );
  9870. }
  9871. }
  9872. if ( !matched ) {
  9873. break;
  9874. }
  9875. }
  9876. // Return the length of the invalid excess
  9877. // if we're just parsing
  9878. // Otherwise, throw an error or return tokens
  9879. return parseOnly ?
  9880. soFar.length :
  9881. soFar ?
  9882. Sizzle.error( selector ) :
  9883. // Cache the tokens
  9884. tokenCache( selector, groups ).slice( 0 );
  9885. };
  9886. function toSelector( tokens ) {
  9887. var i = 0,
  9888. len = tokens.length,
  9889. selector = "";
  9890. for ( ; i < len; i++ ) {
  9891. selector += tokens[i].value;
  9892. }
  9893. return selector;
  9894. }
  9895. function addCombinator( matcher, combinator, base ) {
  9896. var dir = combinator.dir,
  9897. skip = combinator.next,
  9898. key = skip || dir,
  9899. checkNonElements = base && key === "parentNode",
  9900. doneName = done++;
  9901. return combinator.first ?
  9902. // Check against closest ancestor/preceding element
  9903. function( elem, context, xml ) {
  9904. while ( (elem = elem[ dir ]) ) {
  9905. if ( elem.nodeType === 1 || checkNonElements ) {
  9906. return matcher( elem, context, xml );
  9907. }
  9908. }
  9909. return false;
  9910. } :
  9911. // Check against all ancestor/preceding elements
  9912. function( elem, context, xml ) {
  9913. var oldCache, uniqueCache, outerCache,
  9914. newCache = [ dirruns, doneName ];
  9915. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  9916. if ( xml ) {
  9917. while ( (elem = elem[ dir ]) ) {
  9918. if ( elem.nodeType === 1 || checkNonElements ) {
  9919. if ( matcher( elem, context, xml ) ) {
  9920. return true;
  9921. }
  9922. }
  9923. }
  9924. } else {
  9925. while ( (elem = elem[ dir ]) ) {
  9926. if ( elem.nodeType === 1 || checkNonElements ) {
  9927. outerCache = elem[ expando ] || (elem[ expando ] = {});
  9928. // Support: IE <9 only
  9929. // Defend against cloned attroperties (jQuery gh-1709)
  9930. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  9931. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  9932. elem = elem[ dir ] || elem;
  9933. } else if ( (oldCache = uniqueCache[ key ]) &&
  9934. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  9935. // Assign to newCache so results back-propagate to previous elements
  9936. return (newCache[ 2 ] = oldCache[ 2 ]);
  9937. } else {
  9938. // Reuse newcache so results back-propagate to previous elements
  9939. uniqueCache[ key ] = newCache;
  9940. // A match means we're done; a fail means we have to keep checking
  9941. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  9942. return true;
  9943. }
  9944. }
  9945. }
  9946. }
  9947. }
  9948. return false;
  9949. };
  9950. }
  9951. function elementMatcher( matchers ) {
  9952. return matchers.length > 1 ?
  9953. function( elem, context, xml ) {
  9954. var i = matchers.length;
  9955. while ( i-- ) {
  9956. if ( !matchers[i]( elem, context, xml ) ) {
  9957. return false;
  9958. }
  9959. }
  9960. return true;
  9961. } :
  9962. matchers[0];
  9963. }
  9964. function multipleContexts( selector, contexts, results ) {
  9965. var i = 0,
  9966. len = contexts.length;
  9967. for ( ; i < len; i++ ) {
  9968. Sizzle( selector, contexts[i], results );
  9969. }
  9970. return results;
  9971. }
  9972. function condense( unmatched, map, filter, context, xml ) {
  9973. var elem,
  9974. newUnmatched = [],
  9975. i = 0,
  9976. len = unmatched.length,
  9977. mapped = map != null;
  9978. for ( ; i < len; i++ ) {
  9979. if ( (elem = unmatched[i]) ) {
  9980. if ( !filter || filter( elem, context, xml ) ) {
  9981. newUnmatched.push( elem );
  9982. if ( mapped ) {
  9983. map.push( i );
  9984. }
  9985. }
  9986. }
  9987. }
  9988. return newUnmatched;
  9989. }
  9990. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  9991. if ( postFilter && !postFilter[ expando ] ) {
  9992. postFilter = setMatcher( postFilter );
  9993. }
  9994. if ( postFinder && !postFinder[ expando ] ) {
  9995. postFinder = setMatcher( postFinder, postSelector );
  9996. }
  9997. return markFunction(function( seed, results, context, xml ) {
  9998. var temp, i, elem,
  9999. preMap = [],
  10000. postMap = [],
  10001. preexisting = results.length,
  10002. // Get initial elements from seed or context
  10003. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  10004. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  10005. matcherIn = preFilter && ( seed || !selector ) ?
  10006. condense( elems, preMap, preFilter, context, xml ) :
  10007. elems,
  10008. matcherOut = matcher ?
  10009. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  10010. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  10011. // ...intermediate processing is necessary
  10012. [] :
  10013. // ...otherwise use results directly
  10014. results :
  10015. matcherIn;
  10016. // Find primary matches
  10017. if ( matcher ) {
  10018. matcher( matcherIn, matcherOut, context, xml );
  10019. }
  10020. // Apply postFilter
  10021. if ( postFilter ) {
  10022. temp = condense( matcherOut, postMap );
  10023. postFilter( temp, [], context, xml );
  10024. // Un-match failing elements by moving them back to matcherIn
  10025. i = temp.length;
  10026. while ( i-- ) {
  10027. if ( (elem = temp[i]) ) {
  10028. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  10029. }
  10030. }
  10031. }
  10032. if ( seed ) {
  10033. if ( postFinder || preFilter ) {
  10034. if ( postFinder ) {
  10035. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  10036. temp = [];
  10037. i = matcherOut.length;
  10038. while ( i-- ) {
  10039. if ( (elem = matcherOut[i]) ) {
  10040. // Restore matcherIn since elem is not yet a final match
  10041. temp.push( (matcherIn[i] = elem) );
  10042. }
  10043. }
  10044. postFinder( null, (matcherOut = []), temp, xml );
  10045. }
  10046. // Move matched elements from seed to results to keep them synchronized
  10047. i = matcherOut.length;
  10048. while ( i-- ) {
  10049. if ( (elem = matcherOut[i]) &&
  10050. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  10051. seed[temp] = !(results[temp] = elem);
  10052. }
  10053. }
  10054. }
  10055. // Add elements to results, through postFinder if defined
  10056. } else {
  10057. matcherOut = condense(
  10058. matcherOut === results ?
  10059. matcherOut.splice( preexisting, matcherOut.length ) :
  10060. matcherOut
  10061. );
  10062. if ( postFinder ) {
  10063. postFinder( null, results, matcherOut, xml );
  10064. } else {
  10065. push.apply( results, matcherOut );
  10066. }
  10067. }
  10068. });
  10069. }
  10070. function matcherFromTokens( tokens ) {
  10071. var checkContext, matcher, j,
  10072. len = tokens.length,
  10073. leadingRelative = Expr.relative[ tokens[0].type ],
  10074. implicitRelative = leadingRelative || Expr.relative[" "],
  10075. i = leadingRelative ? 1 : 0,
  10076. // The foundational matcher ensures that elements are reachable from top-level context(s)
  10077. matchContext = addCombinator( function( elem ) {
  10078. return elem === checkContext;
  10079. }, implicitRelative, true ),
  10080. matchAnyContext = addCombinator( function( elem ) {
  10081. return indexOf( checkContext, elem ) > -1;
  10082. }, implicitRelative, true ),
  10083. matchers = [ function( elem, context, xml ) {
  10084. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  10085. (checkContext = context).nodeType ?
  10086. matchContext( elem, context, xml ) :
  10087. matchAnyContext( elem, context, xml ) );
  10088. // Avoid hanging onto element (issue #299)
  10089. checkContext = null;
  10090. return ret;
  10091. } ];
  10092. for ( ; i < len; i++ ) {
  10093. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  10094. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  10095. } else {
  10096. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  10097. // Return special upon seeing a positional matcher
  10098. if ( matcher[ expando ] ) {
  10099. // Find the next relative operator (if any) for proper handling
  10100. j = ++i;
  10101. for ( ; j < len; j++ ) {
  10102. if ( Expr.relative[ tokens[j].type ] ) {
  10103. break;
  10104. }
  10105. }
  10106. return setMatcher(
  10107. i > 1 && elementMatcher( matchers ),
  10108. i > 1 && toSelector(
  10109. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  10110. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  10111. ).replace( rtrim, "$1" ),
  10112. matcher,
  10113. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  10114. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  10115. j < len && toSelector( tokens )
  10116. );
  10117. }
  10118. matchers.push( matcher );
  10119. }
  10120. }
  10121. return elementMatcher( matchers );
  10122. }
  10123. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  10124. var bySet = setMatchers.length > 0,
  10125. byElement = elementMatchers.length > 0,
  10126. superMatcher = function( seed, context, xml, results, outermost ) {
  10127. var elem, j, matcher,
  10128. matchedCount = 0,
  10129. i = "0",
  10130. unmatched = seed && [],
  10131. setMatched = [],
  10132. contextBackup = outermostContext,
  10133. // We must always have either seed elements or outermost context
  10134. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  10135. // Use integer dirruns iff this is the outermost matcher
  10136. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  10137. len = elems.length;
  10138. if ( outermost ) {
  10139. outermostContext = context === document || context || outermost;
  10140. }
  10141. // Add elements passing elementMatchers directly to results
  10142. // Support: IE<9, Safari
  10143. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  10144. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  10145. if ( byElement && elem ) {
  10146. j = 0;
  10147. if ( !context && elem.ownerDocument !== document ) {
  10148. setDocument( elem );
  10149. xml = !documentIsHTML;
  10150. }
  10151. while ( (matcher = elementMatchers[j++]) ) {
  10152. if ( matcher( elem, context || document, xml) ) {
  10153. results.push( elem );
  10154. break;
  10155. }
  10156. }
  10157. if ( outermost ) {
  10158. dirruns = dirrunsUnique;
  10159. }
  10160. }
  10161. // Track unmatched elements for set filters
  10162. if ( bySet ) {
  10163. // They will have gone through all possible matchers
  10164. if ( (elem = !matcher && elem) ) {
  10165. matchedCount--;
  10166. }
  10167. // Lengthen the array for every element, matched or not
  10168. if ( seed ) {
  10169. unmatched.push( elem );
  10170. }
  10171. }
  10172. }
  10173. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  10174. // makes the latter nonnegative.
  10175. matchedCount += i;
  10176. // Apply set filters to unmatched elements
  10177. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  10178. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  10179. // no element matchers and no seed.
  10180. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  10181. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  10182. // numerically zero.
  10183. if ( bySet && i !== matchedCount ) {
  10184. j = 0;
  10185. while ( (matcher = setMatchers[j++]) ) {
  10186. matcher( unmatched, setMatched, context, xml );
  10187. }
  10188. if ( seed ) {
  10189. // Reintegrate element matches to eliminate the need for sorting
  10190. if ( matchedCount > 0 ) {
  10191. while ( i-- ) {
  10192. if ( !(unmatched[i] || setMatched[i]) ) {
  10193. setMatched[i] = pop.call( results );
  10194. }
  10195. }
  10196. }
  10197. // Discard index placeholder values to get only actual matches
  10198. setMatched = condense( setMatched );
  10199. }
  10200. // Add matches to results
  10201. push.apply( results, setMatched );
  10202. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  10203. if ( outermost && !seed && setMatched.length > 0 &&
  10204. ( matchedCount + setMatchers.length ) > 1 ) {
  10205. Sizzle.uniqueSort( results );
  10206. }
  10207. }
  10208. // Override manipulation of globals by nested matchers
  10209. if ( outermost ) {
  10210. dirruns = dirrunsUnique;
  10211. outermostContext = contextBackup;
  10212. }
  10213. return unmatched;
  10214. };
  10215. return bySet ?
  10216. markFunction( superMatcher ) :
  10217. superMatcher;
  10218. }
  10219. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  10220. var i,
  10221. setMatchers = [],
  10222. elementMatchers = [],
  10223. cached = compilerCache[ selector + " " ];
  10224. if ( !cached ) {
  10225. // Generate a function of recursive functions that can be used to check each element
  10226. if ( !match ) {
  10227. match = tokenize( selector );
  10228. }
  10229. i = match.length;
  10230. while ( i-- ) {
  10231. cached = matcherFromTokens( match[i] );
  10232. if ( cached[ expando ] ) {
  10233. setMatchers.push( cached );
  10234. } else {
  10235. elementMatchers.push( cached );
  10236. }
  10237. }
  10238. // Cache the compiled function
  10239. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  10240. // Save selector and tokenization
  10241. cached.selector = selector;
  10242. }
  10243. return cached;
  10244. };
  10245. /**
  10246. * A low-level selection function that works with Sizzle's compiled
  10247. * selector functions
  10248. * @param {String|Function} selector A selector or a pre-compiled
  10249. * selector function built with Sizzle.compile
  10250. * @param {Element} context
  10251. * @param {Array} [results]
  10252. * @param {Array} [seed] A set of elements to match against
  10253. */
  10254. select = Sizzle.select = function( selector, context, results, seed ) {
  10255. var i, tokens, token, type, find,
  10256. compiled = typeof selector === "function" && selector,
  10257. match = !seed && tokenize( (selector = compiled.selector || selector) );
  10258. results = results || [];
  10259. // Try to minimize operations if there is only one selector in the list and no seed
  10260. // (the latter of which guarantees us context)
  10261. if ( match.length === 1 ) {
  10262. // Reduce context if the leading compound selector is an ID
  10263. tokens = match[0] = match[0].slice( 0 );
  10264. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  10265. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  10266. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  10267. if ( !context ) {
  10268. return results;
  10269. // Precompiled matchers will still verify ancestry, so step up a level
  10270. } else if ( compiled ) {
  10271. context = context.parentNode;
  10272. }
  10273. selector = selector.slice( tokens.shift().value.length );
  10274. }
  10275. // Fetch a seed set for right-to-left matching
  10276. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  10277. while ( i-- ) {
  10278. token = tokens[i];
  10279. // Abort if we hit a combinator
  10280. if ( Expr.relative[ (type = token.type) ] ) {
  10281. break;
  10282. }
  10283. if ( (find = Expr.find[ type ]) ) {
  10284. // Search, expanding context for leading sibling combinators
  10285. if ( (seed = find(
  10286. token.matches[0].replace( runescape, funescape ),
  10287. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  10288. )) ) {
  10289. // If seed is empty or no tokens remain, we can return early
  10290. tokens.splice( i, 1 );
  10291. selector = seed.length && toSelector( tokens );
  10292. if ( !selector ) {
  10293. push.apply( results, seed );
  10294. return results;
  10295. }
  10296. break;
  10297. }
  10298. }
  10299. }
  10300. }
  10301. // Compile and execute a filtering function if one is not provided
  10302. // Provide `match` to avoid retokenization if we modified the selector above
  10303. ( compiled || compile( selector, match ) )(
  10304. seed,
  10305. context,
  10306. !documentIsHTML,
  10307. results,
  10308. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  10309. );
  10310. return results;
  10311. };
  10312. // One-time assignments
  10313. // Sort stability
  10314. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  10315. // Support: Chrome 14-35+
  10316. // Always assume duplicates if they aren't passed to the comparison function
  10317. support.detectDuplicates = !!hasDuplicate;
  10318. // Initialize against the default document
  10319. setDocument();
  10320. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  10321. // Detached nodes confoundingly follow *each other*
  10322. support.sortDetached = assert(function( el ) {
  10323. // Should return 1, but returns 4 (following)
  10324. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  10325. });
  10326. // Support: IE<8
  10327. // Prevent attribute/property "interpolation"
  10328. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  10329. if ( !assert(function( el ) {
  10330. el.innerHTML = "<a href='#'></a>";
  10331. return el.firstChild.getAttribute("href") === "#" ;
  10332. }) ) {
  10333. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  10334. if ( !isXML ) {
  10335. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  10336. }
  10337. });
  10338. }
  10339. // Support: IE<9
  10340. // Use defaultValue in place of getAttribute("value")
  10341. if ( !support.attributes || !assert(function( el ) {
  10342. el.innerHTML = "<input/>";
  10343. el.firstChild.setAttribute( "value", "" );
  10344. return el.firstChild.getAttribute( "value" ) === "";
  10345. }) ) {
  10346. addHandle( "value", function( elem, name, isXML ) {
  10347. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  10348. return elem.defaultValue;
  10349. }
  10350. });
  10351. }
  10352. // Support: IE<9
  10353. // Use getAttributeNode to fetch booleans when getAttribute lies
  10354. if ( !assert(function( el ) {
  10355. return el.getAttribute("disabled") == null;
  10356. }) ) {
  10357. addHandle( booleans, function( elem, name, isXML ) {
  10358. var val;
  10359. if ( !isXML ) {
  10360. return elem[ name ] === true ? name.toLowerCase() :
  10361. (val = elem.getAttributeNode( name )) && val.specified ?
  10362. val.value :
  10363. null;
  10364. }
  10365. });
  10366. }
  10367. return Sizzle;
  10368. })( window );
  10369. jQuery.find = Sizzle;
  10370. jQuery.expr = Sizzle.selectors;
  10371. // Deprecated
  10372. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  10373. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  10374. jQuery.text = Sizzle.getText;
  10375. jQuery.isXMLDoc = Sizzle.isXML;
  10376. jQuery.contains = Sizzle.contains;
  10377. jQuery.escapeSelector = Sizzle.escape;
  10378. var dir = function( elem, dir, until ) {
  10379. var matched = [],
  10380. truncate = until !== undefined;
  10381. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  10382. if ( elem.nodeType === 1 ) {
  10383. if ( truncate && jQuery( elem ).is( until ) ) {
  10384. break;
  10385. }
  10386. matched.push( elem );
  10387. }
  10388. }
  10389. return matched;
  10390. };
  10391. var siblings = function( n, elem ) {
  10392. var matched = [];
  10393. for ( ; n; n = n.nextSibling ) {
  10394. if ( n.nodeType === 1 && n !== elem ) {
  10395. matched.push( n );
  10396. }
  10397. }
  10398. return matched;
  10399. };
  10400. var rneedsContext = jQuery.expr.match.needsContext;
  10401. function nodeName( elem, name ) {
  10402. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  10403. };
  10404. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  10405. // Implement the identical functionality for filter and not
  10406. function winnow( elements, qualifier, not ) {
  10407. if ( isFunction( qualifier ) ) {
  10408. return jQuery.grep( elements, function( elem, i ) {
  10409. return !!qualifier.call( elem, i, elem ) !== not;
  10410. } );
  10411. }
  10412. // Single element
  10413. if ( qualifier.nodeType ) {
  10414. return jQuery.grep( elements, function( elem ) {
  10415. return ( elem === qualifier ) !== not;
  10416. } );
  10417. }
  10418. // Arraylike of elements (jQuery, arguments, Array)
  10419. if ( typeof qualifier !== "string" ) {
  10420. return jQuery.grep( elements, function( elem ) {
  10421. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  10422. } );
  10423. }
  10424. // Filtered directly for both simple and complex selectors
  10425. return jQuery.filter( qualifier, elements, not );
  10426. }
  10427. jQuery.filter = function( expr, elems, not ) {
  10428. var elem = elems[ 0 ];
  10429. if ( not ) {
  10430. expr = ":not(" + expr + ")";
  10431. }
  10432. if ( elems.length === 1 && elem.nodeType === 1 ) {
  10433. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  10434. }
  10435. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  10436. return elem.nodeType === 1;
  10437. } ) );
  10438. };
  10439. jQuery.fn.extend( {
  10440. find: function( selector ) {
  10441. var i, ret,
  10442. len = this.length,
  10443. self = this;
  10444. if ( typeof selector !== "string" ) {
  10445. return this.pushStack( jQuery( selector ).filter( function() {
  10446. for ( i = 0; i < len; i++ ) {
  10447. if ( jQuery.contains( self[ i ], this ) ) {
  10448. return true;
  10449. }
  10450. }
  10451. } ) );
  10452. }
  10453. ret = this.pushStack( [] );
  10454. for ( i = 0; i < len; i++ ) {
  10455. jQuery.find( selector, self[ i ], ret );
  10456. }
  10457. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  10458. },
  10459. filter: function( selector ) {
  10460. return this.pushStack( winnow( this, selector || [], false ) );
  10461. },
  10462. not: function( selector ) {
  10463. return this.pushStack( winnow( this, selector || [], true ) );
  10464. },
  10465. is: function( selector ) {
  10466. return !!winnow(
  10467. this,
  10468. // If this is a positional/relative selector, check membership in the returned set
  10469. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  10470. typeof selector === "string" && rneedsContext.test( selector ) ?
  10471. jQuery( selector ) :
  10472. selector || [],
  10473. false
  10474. ).length;
  10475. }
  10476. } );
  10477. // Initialize a jQuery object
  10478. // A central reference to the root jQuery(document)
  10479. var rootjQuery,
  10480. // A simple way to check for HTML strings
  10481. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  10482. // Strict HTML recognition (#11290: must start with <)
  10483. // Shortcut simple #id case for speed
  10484. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  10485. init = jQuery.fn.init = function( selector, context, root ) {
  10486. var match, elem;
  10487. // HANDLE: $(""), $(null), $(undefined), $(false)
  10488. if ( !selector ) {
  10489. return this;
  10490. }
  10491. // Method init() accepts an alternate rootjQuery
  10492. // so migrate can support jQuery.sub (gh-2101)
  10493. root = root || rootjQuery;
  10494. // Handle HTML strings
  10495. if ( typeof selector === "string" ) {
  10496. if ( selector[ 0 ] === "<" &&
  10497. selector[ selector.length - 1 ] === ">" &&
  10498. selector.length >= 3 ) {
  10499. // Assume that strings that start and end with <> are HTML and skip the regex check
  10500. match = [ null, selector, null ];
  10501. } else {
  10502. match = rquickExpr.exec( selector );
  10503. }
  10504. // Match html or make sure no context is specified for #id
  10505. if ( match && ( match[ 1 ] || !context ) ) {
  10506. // HANDLE: $(html) -> $(array)
  10507. if ( match[ 1 ] ) {
  10508. context = context instanceof jQuery ? context[ 0 ] : context;
  10509. // Option to run scripts is true for back-compat
  10510. // Intentionally let the error be thrown if parseHTML is not present
  10511. jQuery.merge( this, jQuery.parseHTML(
  10512. match[ 1 ],
  10513. context && context.nodeType ? context.ownerDocument || context : document,
  10514. true
  10515. ) );
  10516. // HANDLE: $(html, props)
  10517. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  10518. for ( match in context ) {
  10519. // Properties of context are called as methods if possible
  10520. if ( isFunction( this[ match ] ) ) {
  10521. this[ match ]( context[ match ] );
  10522. // ...and otherwise set as attributes
  10523. } else {
  10524. this.attr( match, context[ match ] );
  10525. }
  10526. }
  10527. }
  10528. return this;
  10529. // HANDLE: $(#id)
  10530. } else {
  10531. elem = document.getElementById( match[ 2 ] );
  10532. if ( elem ) {
  10533. // Inject the element directly into the jQuery object
  10534. this[ 0 ] = elem;
  10535. this.length = 1;
  10536. }
  10537. return this;
  10538. }
  10539. // HANDLE: $(expr, $(...))
  10540. } else if ( !context || context.jquery ) {
  10541. return ( context || root ).find( selector );
  10542. // HANDLE: $(expr, context)
  10543. // (which is just equivalent to: $(context).find(expr)
  10544. } else {
  10545. return this.constructor( context ).find( selector );
  10546. }
  10547. // HANDLE: $(DOMElement)
  10548. } else if ( selector.nodeType ) {
  10549. this[ 0 ] = selector;
  10550. this.length = 1;
  10551. return this;
  10552. // HANDLE: $(function)
  10553. // Shortcut for document ready
  10554. } else if ( isFunction( selector ) ) {
  10555. return root.ready !== undefined ?
  10556. root.ready( selector ) :
  10557. // Execute immediately if ready is not present
  10558. selector( jQuery );
  10559. }
  10560. return jQuery.makeArray( selector, this );
  10561. };
  10562. // Give the init function the jQuery prototype for later instantiation
  10563. init.prototype = jQuery.fn;
  10564. // Initialize central reference
  10565. rootjQuery = jQuery( document );
  10566. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  10567. // Methods guaranteed to produce a unique set when starting from a unique set
  10568. guaranteedUnique = {
  10569. children: true,
  10570. contents: true,
  10571. next: true,
  10572. prev: true
  10573. };
  10574. jQuery.fn.extend( {
  10575. has: function( target ) {
  10576. var targets = jQuery( target, this ),
  10577. l = targets.length;
  10578. return this.filter( function() {
  10579. var i = 0;
  10580. for ( ; i < l; i++ ) {
  10581. if ( jQuery.contains( this, targets[ i ] ) ) {
  10582. return true;
  10583. }
  10584. }
  10585. } );
  10586. },
  10587. closest: function( selectors, context ) {
  10588. var cur,
  10589. i = 0,
  10590. l = this.length,
  10591. matched = [],
  10592. targets = typeof selectors !== "string" && jQuery( selectors );
  10593. // Positional selectors never match, since there's no _selection_ context
  10594. if ( !rneedsContext.test( selectors ) ) {
  10595. for ( ; i < l; i++ ) {
  10596. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  10597. // Always skip document fragments
  10598. if ( cur.nodeType < 11 && ( targets ?
  10599. targets.index( cur ) > -1 :
  10600. // Don't pass non-elements to Sizzle
  10601. cur.nodeType === 1 &&
  10602. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  10603. matched.push( cur );
  10604. break;
  10605. }
  10606. }
  10607. }
  10608. }
  10609. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  10610. },
  10611. // Determine the position of an element within the set
  10612. index: function( elem ) {
  10613. // No argument, return index in parent
  10614. if ( !elem ) {
  10615. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  10616. }
  10617. // Index in selector
  10618. if ( typeof elem === "string" ) {
  10619. return indexOf.call( jQuery( elem ), this[ 0 ] );
  10620. }
  10621. // Locate the position of the desired element
  10622. return indexOf.call( this,
  10623. // If it receives a jQuery object, the first element is used
  10624. elem.jquery ? elem[ 0 ] : elem
  10625. );
  10626. },
  10627. add: function( selector, context ) {
  10628. return this.pushStack(
  10629. jQuery.uniqueSort(
  10630. jQuery.merge( this.get(), jQuery( selector, context ) )
  10631. )
  10632. );
  10633. },
  10634. addBack: function( selector ) {
  10635. return this.add( selector == null ?
  10636. this.prevObject : this.prevObject.filter( selector )
  10637. );
  10638. }
  10639. } );
  10640. function sibling( cur, dir ) {
  10641. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  10642. return cur;
  10643. }
  10644. jQuery.each( {
  10645. parent: function( elem ) {
  10646. var parent = elem.parentNode;
  10647. return parent && parent.nodeType !== 11 ? parent : null;
  10648. },
  10649. parents: function( elem ) {
  10650. return dir( elem, "parentNode" );
  10651. },
  10652. parentsUntil: function( elem, i, until ) {
  10653. return dir( elem, "parentNode", until );
  10654. },
  10655. next: function( elem ) {
  10656. return sibling( elem, "nextSibling" );
  10657. },
  10658. prev: function( elem ) {
  10659. return sibling( elem, "previousSibling" );
  10660. },
  10661. nextAll: function( elem ) {
  10662. return dir( elem, "nextSibling" );
  10663. },
  10664. prevAll: function( elem ) {
  10665. return dir( elem, "previousSibling" );
  10666. },
  10667. nextUntil: function( elem, i, until ) {
  10668. return dir( elem, "nextSibling", until );
  10669. },
  10670. prevUntil: function( elem, i, until ) {
  10671. return dir( elem, "previousSibling", until );
  10672. },
  10673. siblings: function( elem ) {
  10674. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  10675. },
  10676. children: function( elem ) {
  10677. return siblings( elem.firstChild );
  10678. },
  10679. contents: function( elem ) {
  10680. if ( typeof elem.contentDocument !== "undefined" ) {
  10681. return elem.contentDocument;
  10682. }
  10683. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  10684. // Treat the template element as a regular one in browsers that
  10685. // don't support it.
  10686. if ( nodeName( elem, "template" ) ) {
  10687. elem = elem.content || elem;
  10688. }
  10689. return jQuery.merge( [], elem.childNodes );
  10690. }
  10691. }, function( name, fn ) {
  10692. jQuery.fn[ name ] = function( until, selector ) {
  10693. var matched = jQuery.map( this, fn, until );
  10694. if ( name.slice( -5 ) !== "Until" ) {
  10695. selector = until;
  10696. }
  10697. if ( selector && typeof selector === "string" ) {
  10698. matched = jQuery.filter( selector, matched );
  10699. }
  10700. if ( this.length > 1 ) {
  10701. // Remove duplicates
  10702. if ( !guaranteedUnique[ name ] ) {
  10703. jQuery.uniqueSort( matched );
  10704. }
  10705. // Reverse order for parents* and prev-derivatives
  10706. if ( rparentsprev.test( name ) ) {
  10707. matched.reverse();
  10708. }
  10709. }
  10710. return this.pushStack( matched );
  10711. };
  10712. } );
  10713. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  10714. // Convert String-formatted options into Object-formatted ones
  10715. function createOptions( options ) {
  10716. var object = {};
  10717. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  10718. object[ flag ] = true;
  10719. } );
  10720. return object;
  10721. }
  10722. /*
  10723. * Create a callback list using the following parameters:
  10724. *
  10725. * options: an optional list of space-separated options that will change how
  10726. * the callback list behaves or a more traditional option object
  10727. *
  10728. * By default a callback list will act like an event callback list and can be
  10729. * "fired" multiple times.
  10730. *
  10731. * Possible options:
  10732. *
  10733. * once: will ensure the callback list can only be fired once (like a Deferred)
  10734. *
  10735. * memory: will keep track of previous values and will call any callback added
  10736. * after the list has been fired right away with the latest "memorized"
  10737. * values (like a Deferred)
  10738. *
  10739. * unique: will ensure a callback can only be added once (no duplicate in the list)
  10740. *
  10741. * stopOnFalse: interrupt callings when a callback returns false
  10742. *
  10743. */
  10744. jQuery.Callbacks = function( options ) {
  10745. // Convert options from String-formatted to Object-formatted if needed
  10746. // (we check in cache first)
  10747. options = typeof options === "string" ?
  10748. createOptions( options ) :
  10749. jQuery.extend( {}, options );
  10750. var // Flag to know if list is currently firing
  10751. firing,
  10752. // Last fire value for non-forgettable lists
  10753. memory,
  10754. // Flag to know if list was already fired
  10755. fired,
  10756. // Flag to prevent firing
  10757. locked,
  10758. // Actual callback list
  10759. list = [],
  10760. // Queue of execution data for repeatable lists
  10761. queue = [],
  10762. // Index of currently firing callback (modified by add/remove as needed)
  10763. firingIndex = -1,
  10764. // Fire callbacks
  10765. fire = function() {
  10766. // Enforce single-firing
  10767. locked = locked || options.once;
  10768. // Execute callbacks for all pending executions,
  10769. // respecting firingIndex overrides and runtime changes
  10770. fired = firing = true;
  10771. for ( ; queue.length; firingIndex = -1 ) {
  10772. memory = queue.shift();
  10773. while ( ++firingIndex < list.length ) {
  10774. // Run callback and check for early termination
  10775. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  10776. options.stopOnFalse ) {
  10777. // Jump to end and forget the data so .add doesn't re-fire
  10778. firingIndex = list.length;
  10779. memory = false;
  10780. }
  10781. }
  10782. }
  10783. // Forget the data if we're done with it
  10784. if ( !options.memory ) {
  10785. memory = false;
  10786. }
  10787. firing = false;
  10788. // Clean up if we're done firing for good
  10789. if ( locked ) {
  10790. // Keep an empty list if we have data for future add calls
  10791. if ( memory ) {
  10792. list = [];
  10793. // Otherwise, this object is spent
  10794. } else {
  10795. list = "";
  10796. }
  10797. }
  10798. },
  10799. // Actual Callbacks object
  10800. self = {
  10801. // Add a callback or a collection of callbacks to the list
  10802. add: function() {
  10803. if ( list ) {
  10804. // If we have memory from a past run, we should fire after adding
  10805. if ( memory && !firing ) {
  10806. firingIndex = list.length - 1;
  10807. queue.push( memory );
  10808. }
  10809. ( function add( args ) {
  10810. jQuery.each( args, function( _, arg ) {
  10811. if ( isFunction( arg ) ) {
  10812. if ( !options.unique || !self.has( arg ) ) {
  10813. list.push( arg );
  10814. }
  10815. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  10816. // Inspect recursively
  10817. add( arg );
  10818. }
  10819. } );
  10820. } )( arguments );
  10821. if ( memory && !firing ) {
  10822. fire();
  10823. }
  10824. }
  10825. return this;
  10826. },
  10827. // Remove a callback from the list
  10828. remove: function() {
  10829. jQuery.each( arguments, function( _, arg ) {
  10830. var index;
  10831. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  10832. list.splice( index, 1 );
  10833. // Handle firing indexes
  10834. if ( index <= firingIndex ) {
  10835. firingIndex--;
  10836. }
  10837. }
  10838. } );
  10839. return this;
  10840. },
  10841. // Check if a given callback is in the list.
  10842. // If no argument is given, return whether or not list has callbacks attached.
  10843. has: function( fn ) {
  10844. return fn ?
  10845. jQuery.inArray( fn, list ) > -1 :
  10846. list.length > 0;
  10847. },
  10848. // Remove all callbacks from the list
  10849. empty: function() {
  10850. if ( list ) {
  10851. list = [];
  10852. }
  10853. return this;
  10854. },
  10855. // Disable .fire and .add
  10856. // Abort any current/pending executions
  10857. // Clear all callbacks and values
  10858. disable: function() {
  10859. locked = queue = [];
  10860. list = memory = "";
  10861. return this;
  10862. },
  10863. disabled: function() {
  10864. return !list;
  10865. },
  10866. // Disable .fire
  10867. // Also disable .add unless we have memory (since it would have no effect)
  10868. // Abort any pending executions
  10869. lock: function() {
  10870. locked = queue = [];
  10871. if ( !memory && !firing ) {
  10872. list = memory = "";
  10873. }
  10874. return this;
  10875. },
  10876. locked: function() {
  10877. return !!locked;
  10878. },
  10879. // Call all callbacks with the given context and arguments
  10880. fireWith: function( context, args ) {
  10881. if ( !locked ) {
  10882. args = args || [];
  10883. args = [ context, args.slice ? args.slice() : args ];
  10884. queue.push( args );
  10885. if ( !firing ) {
  10886. fire();
  10887. }
  10888. }
  10889. return this;
  10890. },
  10891. // Call all the callbacks with the given arguments
  10892. fire: function() {
  10893. self.fireWith( this, arguments );
  10894. return this;
  10895. },
  10896. // To know if the callbacks have already been called at least once
  10897. fired: function() {
  10898. return !!fired;
  10899. }
  10900. };
  10901. return self;
  10902. };
  10903. function Identity( v ) {
  10904. return v;
  10905. }
  10906. function Thrower( ex ) {
  10907. throw ex;
  10908. }
  10909. function adoptValue( value, resolve, reject, noValue ) {
  10910. var method;
  10911. try {
  10912. // Check for promise aspect first to privilege synchronous behavior
  10913. if ( value && isFunction( ( method = value.promise ) ) ) {
  10914. method.call( value ).done( resolve ).fail( reject );
  10915. // Other thenables
  10916. } else if ( value && isFunction( ( method = value.then ) ) ) {
  10917. method.call( value, resolve, reject );
  10918. // Other non-thenables
  10919. } else {
  10920. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  10921. // * false: [ value ].slice( 0 ) => resolve( value )
  10922. // * true: [ value ].slice( 1 ) => resolve()
  10923. resolve.apply( undefined, [ value ].slice( noValue ) );
  10924. }
  10925. // For Promises/A+, convert exceptions into rejections
  10926. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  10927. // Deferred#then to conditionally suppress rejection.
  10928. } catch ( value ) {
  10929. // Support: Android 4.0 only
  10930. // Strict mode functions invoked without .call/.apply get global-object context
  10931. reject.apply( undefined, [ value ] );
  10932. }
  10933. }
  10934. jQuery.extend( {
  10935. Deferred: function( func ) {
  10936. var tuples = [
  10937. // action, add listener, callbacks,
  10938. // ... .then handlers, argument index, [final state]
  10939. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  10940. jQuery.Callbacks( "memory" ), 2 ],
  10941. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  10942. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  10943. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  10944. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  10945. ],
  10946. state = "pending",
  10947. promise = {
  10948. state: function() {
  10949. return state;
  10950. },
  10951. always: function() {
  10952. deferred.done( arguments ).fail( arguments );
  10953. return this;
  10954. },
  10955. "catch": function( fn ) {
  10956. return promise.then( null, fn );
  10957. },
  10958. // Keep pipe for back-compat
  10959. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  10960. var fns = arguments;
  10961. return jQuery.Deferred( function( newDefer ) {
  10962. jQuery.each( tuples, function( i, tuple ) {
  10963. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  10964. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  10965. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  10966. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  10967. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  10968. deferred[ tuple[ 1 ] ]( function() {
  10969. var returned = fn && fn.apply( this, arguments );
  10970. if ( returned && isFunction( returned.promise ) ) {
  10971. returned.promise()
  10972. .progress( newDefer.notify )
  10973. .done( newDefer.resolve )
  10974. .fail( newDefer.reject );
  10975. } else {
  10976. newDefer[ tuple[ 0 ] + "With" ](
  10977. this,
  10978. fn ? [ returned ] : arguments
  10979. );
  10980. }
  10981. } );
  10982. } );
  10983. fns = null;
  10984. } ).promise();
  10985. },
  10986. then: function( onFulfilled, onRejected, onProgress ) {
  10987. var maxDepth = 0;
  10988. function resolve( depth, deferred, handler, special ) {
  10989. return function() {
  10990. var that = this,
  10991. args = arguments,
  10992. mightThrow = function() {
  10993. var returned, then;
  10994. // Support: Promises/A+ section 2.3.3.3.3
  10995. // https://promisesaplus.com/#point-59
  10996. // Ignore double-resolution attempts
  10997. if ( depth < maxDepth ) {
  10998. return;
  10999. }
  11000. returned = handler.apply( that, args );
  11001. // Support: Promises/A+ section 2.3.1
  11002. // https://promisesaplus.com/#point-48
  11003. if ( returned === deferred.promise() ) {
  11004. throw new TypeError( "Thenable self-resolution" );
  11005. }
  11006. // Support: Promises/A+ sections 2.3.3.1, 3.5
  11007. // https://promisesaplus.com/#point-54
  11008. // https://promisesaplus.com/#point-75
  11009. // Retrieve `then` only once
  11010. then = returned &&
  11011. // Support: Promises/A+ section 2.3.4
  11012. // https://promisesaplus.com/#point-64
  11013. // Only check objects and functions for thenability
  11014. ( typeof returned === "object" ||
  11015. typeof returned === "function" ) &&
  11016. returned.then;
  11017. // Handle a returned thenable
  11018. if ( isFunction( then ) ) {
  11019. // Special processors (notify) just wait for resolution
  11020. if ( special ) {
  11021. then.call(
  11022. returned,
  11023. resolve( maxDepth, deferred, Identity, special ),
  11024. resolve( maxDepth, deferred, Thrower, special )
  11025. );
  11026. // Normal processors (resolve) also hook into progress
  11027. } else {
  11028. // ...and disregard older resolution values
  11029. maxDepth++;
  11030. then.call(
  11031. returned,
  11032. resolve( maxDepth, deferred, Identity, special ),
  11033. resolve( maxDepth, deferred, Thrower, special ),
  11034. resolve( maxDepth, deferred, Identity,
  11035. deferred.notifyWith )
  11036. );
  11037. }
  11038. // Handle all other returned values
  11039. } else {
  11040. // Only substitute handlers pass on context
  11041. // and multiple values (non-spec behavior)
  11042. if ( handler !== Identity ) {
  11043. that = undefined;
  11044. args = [ returned ];
  11045. }
  11046. // Process the value(s)
  11047. // Default process is resolve
  11048. ( special || deferred.resolveWith )( that, args );
  11049. }
  11050. },
  11051. // Only normal processors (resolve) catch and reject exceptions
  11052. process = special ?
  11053. mightThrow :
  11054. function() {
  11055. try {
  11056. mightThrow();
  11057. } catch ( e ) {
  11058. if ( jQuery.Deferred.exceptionHook ) {
  11059. jQuery.Deferred.exceptionHook( e,
  11060. process.stackTrace );
  11061. }
  11062. // Support: Promises/A+ section 2.3.3.3.4.1
  11063. // https://promisesaplus.com/#point-61
  11064. // Ignore post-resolution exceptions
  11065. if ( depth + 1 >= maxDepth ) {
  11066. // Only substitute handlers pass on context
  11067. // and multiple values (non-spec behavior)
  11068. if ( handler !== Thrower ) {
  11069. that = undefined;
  11070. args = [ e ];
  11071. }
  11072. deferred.rejectWith( that, args );
  11073. }
  11074. }
  11075. };
  11076. // Support: Promises/A+ section 2.3.3.3.1
  11077. // https://promisesaplus.com/#point-57
  11078. // Re-resolve promises immediately to dodge false rejection from
  11079. // subsequent errors
  11080. if ( depth ) {
  11081. process();
  11082. } else {
  11083. // Call an optional hook to record the stack, in case of exception
  11084. // since it's otherwise lost when execution goes async
  11085. if ( jQuery.Deferred.getStackHook ) {
  11086. process.stackTrace = jQuery.Deferred.getStackHook();
  11087. }
  11088. window.setTimeout( process );
  11089. }
  11090. };
  11091. }
  11092. return jQuery.Deferred( function( newDefer ) {
  11093. // progress_handlers.add( ... )
  11094. tuples[ 0 ][ 3 ].add(
  11095. resolve(
  11096. 0,
  11097. newDefer,
  11098. isFunction( onProgress ) ?
  11099. onProgress :
  11100. Identity,
  11101. newDefer.notifyWith
  11102. )
  11103. );
  11104. // fulfilled_handlers.add( ... )
  11105. tuples[ 1 ][ 3 ].add(
  11106. resolve(
  11107. 0,
  11108. newDefer,
  11109. isFunction( onFulfilled ) ?
  11110. onFulfilled :
  11111. Identity
  11112. )
  11113. );
  11114. // rejected_handlers.add( ... )
  11115. tuples[ 2 ][ 3 ].add(
  11116. resolve(
  11117. 0,
  11118. newDefer,
  11119. isFunction( onRejected ) ?
  11120. onRejected :
  11121. Thrower
  11122. )
  11123. );
  11124. } ).promise();
  11125. },
  11126. // Get a promise for this deferred
  11127. // If obj is provided, the promise aspect is added to the object
  11128. promise: function( obj ) {
  11129. return obj != null ? jQuery.extend( obj, promise ) : promise;
  11130. }
  11131. },
  11132. deferred = {};
  11133. // Add list-specific methods
  11134. jQuery.each( tuples, function( i, tuple ) {
  11135. var list = tuple[ 2 ],
  11136. stateString = tuple[ 5 ];
  11137. // promise.progress = list.add
  11138. // promise.done = list.add
  11139. // promise.fail = list.add
  11140. promise[ tuple[ 1 ] ] = list.add;
  11141. // Handle state
  11142. if ( stateString ) {
  11143. list.add(
  11144. function() {
  11145. // state = "resolved" (i.e., fulfilled)
  11146. // state = "rejected"
  11147. state = stateString;
  11148. },
  11149. // rejected_callbacks.disable
  11150. // fulfilled_callbacks.disable
  11151. tuples[ 3 - i ][ 2 ].disable,
  11152. // rejected_handlers.disable
  11153. // fulfilled_handlers.disable
  11154. tuples[ 3 - i ][ 3 ].disable,
  11155. // progress_callbacks.lock
  11156. tuples[ 0 ][ 2 ].lock,
  11157. // progress_handlers.lock
  11158. tuples[ 0 ][ 3 ].lock
  11159. );
  11160. }
  11161. // progress_handlers.fire
  11162. // fulfilled_handlers.fire
  11163. // rejected_handlers.fire
  11164. list.add( tuple[ 3 ].fire );
  11165. // deferred.notify = function() { deferred.notifyWith(...) }
  11166. // deferred.resolve = function() { deferred.resolveWith(...) }
  11167. // deferred.reject = function() { deferred.rejectWith(...) }
  11168. deferred[ tuple[ 0 ] ] = function() {
  11169. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  11170. return this;
  11171. };
  11172. // deferred.notifyWith = list.fireWith
  11173. // deferred.resolveWith = list.fireWith
  11174. // deferred.rejectWith = list.fireWith
  11175. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  11176. } );
  11177. // Make the deferred a promise
  11178. promise.promise( deferred );
  11179. // Call given func if any
  11180. if ( func ) {
  11181. func.call( deferred, deferred );
  11182. }
  11183. // All done!
  11184. return deferred;
  11185. },
  11186. // Deferred helper
  11187. when: function( singleValue ) {
  11188. var
  11189. // count of uncompleted subordinates
  11190. remaining = arguments.length,
  11191. // count of unprocessed arguments
  11192. i = remaining,
  11193. // subordinate fulfillment data
  11194. resolveContexts = Array( i ),
  11195. resolveValues = slice.call( arguments ),
  11196. // the master Deferred
  11197. master = jQuery.Deferred(),
  11198. // subordinate callback factory
  11199. updateFunc = function( i ) {
  11200. return function( value ) {
  11201. resolveContexts[ i ] = this;
  11202. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  11203. if ( !( --remaining ) ) {
  11204. master.resolveWith( resolveContexts, resolveValues );
  11205. }
  11206. };
  11207. };
  11208. // Single- and empty arguments are adopted like Promise.resolve
  11209. if ( remaining <= 1 ) {
  11210. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  11211. !remaining );
  11212. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  11213. if ( master.state() === "pending" ||
  11214. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  11215. return master.then();
  11216. }
  11217. }
  11218. // Multiple arguments are aggregated like Promise.all array elements
  11219. while ( i-- ) {
  11220. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  11221. }
  11222. return master.promise();
  11223. }
  11224. } );
  11225. // These usually indicate a programmer mistake during development,
  11226. // warn about them ASAP rather than swallowing them by default.
  11227. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  11228. jQuery.Deferred.exceptionHook = function( error, stack ) {
  11229. // Support: IE 8 - 9 only
  11230. // Console exists when dev tools are open, which can happen at any time
  11231. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  11232. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  11233. }
  11234. };
  11235. jQuery.readyException = function( error ) {
  11236. window.setTimeout( function() {
  11237. throw error;
  11238. } );
  11239. };
  11240. // The deferred used on DOM ready
  11241. var readyList = jQuery.Deferred();
  11242. jQuery.fn.ready = function( fn ) {
  11243. readyList
  11244. .then( fn )
  11245. // Wrap jQuery.readyException in a function so that the lookup
  11246. // happens at the time of error handling instead of callback
  11247. // registration.
  11248. .catch( function( error ) {
  11249. jQuery.readyException( error );
  11250. } );
  11251. return this;
  11252. };
  11253. jQuery.extend( {
  11254. // Is the DOM ready to be used? Set to true once it occurs.
  11255. isReady: false,
  11256. // A counter to track how many items to wait for before
  11257. // the ready event fires. See #6781
  11258. readyWait: 1,
  11259. // Handle when the DOM is ready
  11260. ready: function( wait ) {
  11261. // Abort if there are pending holds or we're already ready
  11262. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  11263. return;
  11264. }
  11265. // Remember that the DOM is ready
  11266. jQuery.isReady = true;
  11267. // If a normal DOM Ready event fired, decrement, and wait if need be
  11268. if ( wait !== true && --jQuery.readyWait > 0 ) {
  11269. return;
  11270. }
  11271. // If there are functions bound, to execute
  11272. readyList.resolveWith( document, [ jQuery ] );
  11273. }
  11274. } );
  11275. jQuery.ready.then = readyList.then;
  11276. // The ready event handler and self cleanup method
  11277. function completed() {
  11278. document.removeEventListener( "DOMContentLoaded", completed );
  11279. window.removeEventListener( "load", completed );
  11280. jQuery.ready();
  11281. }
  11282. // Catch cases where $(document).ready() is called
  11283. // after the browser event has already occurred.
  11284. // Support: IE <=9 - 10 only
  11285. // Older IE sometimes signals "interactive" too soon
  11286. if ( document.readyState === "complete" ||
  11287. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  11288. // Handle it asynchronously to allow scripts the opportunity to delay ready
  11289. window.setTimeout( jQuery.ready );
  11290. } else {
  11291. // Use the handy event callback
  11292. document.addEventListener( "DOMContentLoaded", completed );
  11293. // A fallback to window.onload, that will always work
  11294. window.addEventListener( "load", completed );
  11295. }
  11296. // Multifunctional method to get and set values of a collection
  11297. // The value/s can optionally be executed if it's a function
  11298. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  11299. var i = 0,
  11300. len = elems.length,
  11301. bulk = key == null;
  11302. // Sets many values
  11303. if ( toType( key ) === "object" ) {
  11304. chainable = true;
  11305. for ( i in key ) {
  11306. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  11307. }
  11308. // Sets one value
  11309. } else if ( value !== undefined ) {
  11310. chainable = true;
  11311. if ( !isFunction( value ) ) {
  11312. raw = true;
  11313. }
  11314. if ( bulk ) {
  11315. // Bulk operations run against the entire set
  11316. if ( raw ) {
  11317. fn.call( elems, value );
  11318. fn = null;
  11319. // ...except when executing function values
  11320. } else {
  11321. bulk = fn;
  11322. fn = function( elem, key, value ) {
  11323. return bulk.call( jQuery( elem ), value );
  11324. };
  11325. }
  11326. }
  11327. if ( fn ) {
  11328. for ( ; i < len; i++ ) {
  11329. fn(
  11330. elems[ i ], key, raw ?
  11331. value :
  11332. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  11333. );
  11334. }
  11335. }
  11336. }
  11337. if ( chainable ) {
  11338. return elems;
  11339. }
  11340. // Gets
  11341. if ( bulk ) {
  11342. return fn.call( elems );
  11343. }
  11344. return len ? fn( elems[ 0 ], key ) : emptyGet;
  11345. };
  11346. // Matches dashed string for camelizing
  11347. var rmsPrefix = /^-ms-/,
  11348. rdashAlpha = /-([a-z])/g;
  11349. // Used by camelCase as callback to replace()
  11350. function fcamelCase( all, letter ) {
  11351. return letter.toUpperCase();
  11352. }
  11353. // Convert dashed to camelCase; used by the css and data modules
  11354. // Support: IE <=9 - 11, Edge 12 - 15
  11355. // Microsoft forgot to hump their vendor prefix (#9572)
  11356. function camelCase( string ) {
  11357. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  11358. }
  11359. var acceptData = function( owner ) {
  11360. // Accepts only:
  11361. // - Node
  11362. // - Node.ELEMENT_NODE
  11363. // - Node.DOCUMENT_NODE
  11364. // - Object
  11365. // - Any
  11366. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  11367. };
  11368. function Data() {
  11369. this.expando = jQuery.expando + Data.uid++;
  11370. }
  11371. Data.uid = 1;
  11372. Data.prototype = {
  11373. cache: function( owner ) {
  11374. // Check if the owner object already has a cache
  11375. var value = owner[ this.expando ];
  11376. // If not, create one
  11377. if ( !value ) {
  11378. value = {};
  11379. // We can accept data for non-element nodes in modern browsers,
  11380. // but we should not, see #8335.
  11381. // Always return an empty object.
  11382. if ( acceptData( owner ) ) {
  11383. // If it is a node unlikely to be stringify-ed or looped over
  11384. // use plain assignment
  11385. if ( owner.nodeType ) {
  11386. owner[ this.expando ] = value;
  11387. // Otherwise secure it in a non-enumerable property
  11388. // configurable must be true to allow the property to be
  11389. // deleted when data is removed
  11390. } else {
  11391. Object.defineProperty( owner, this.expando, {
  11392. value: value,
  11393. configurable: true
  11394. } );
  11395. }
  11396. }
  11397. }
  11398. return value;
  11399. },
  11400. set: function( owner, data, value ) {
  11401. var prop,
  11402. cache = this.cache( owner );
  11403. // Handle: [ owner, key, value ] args
  11404. // Always use camelCase key (gh-2257)
  11405. if ( typeof data === "string" ) {
  11406. cache[ camelCase( data ) ] = value;
  11407. // Handle: [ owner, { properties } ] args
  11408. } else {
  11409. // Copy the properties one-by-one to the cache object
  11410. for ( prop in data ) {
  11411. cache[ camelCase( prop ) ] = data[ prop ];
  11412. }
  11413. }
  11414. return cache;
  11415. },
  11416. get: function( owner, key ) {
  11417. return key === undefined ?
  11418. this.cache( owner ) :
  11419. // Always use camelCase key (gh-2257)
  11420. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  11421. },
  11422. access: function( owner, key, value ) {
  11423. // In cases where either:
  11424. //
  11425. // 1. No key was specified
  11426. // 2. A string key was specified, but no value provided
  11427. //
  11428. // Take the "read" path and allow the get method to determine
  11429. // which value to return, respectively either:
  11430. //
  11431. // 1. The entire cache object
  11432. // 2. The data stored at the key
  11433. //
  11434. if ( key === undefined ||
  11435. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  11436. return this.get( owner, key );
  11437. }
  11438. // When the key is not a string, or both a key and value
  11439. // are specified, set or extend (existing objects) with either:
  11440. //
  11441. // 1. An object of properties
  11442. // 2. A key and value
  11443. //
  11444. this.set( owner, key, value );
  11445. // Since the "set" path can have two possible entry points
  11446. // return the expected data based on which path was taken[*]
  11447. return value !== undefined ? value : key;
  11448. },
  11449. remove: function( owner, key ) {
  11450. var i,
  11451. cache = owner[ this.expando ];
  11452. if ( cache === undefined ) {
  11453. return;
  11454. }
  11455. if ( key !== undefined ) {
  11456. // Support array or space separated string of keys
  11457. if ( Array.isArray( key ) ) {
  11458. // If key is an array of keys...
  11459. // We always set camelCase keys, so remove that.
  11460. key = key.map( camelCase );
  11461. } else {
  11462. key = camelCase( key );
  11463. // If a key with the spaces exists, use it.
  11464. // Otherwise, create an array by matching non-whitespace
  11465. key = key in cache ?
  11466. [ key ] :
  11467. ( key.match( rnothtmlwhite ) || [] );
  11468. }
  11469. i = key.length;
  11470. while ( i-- ) {
  11471. delete cache[ key[ i ] ];
  11472. }
  11473. }
  11474. // Remove the expando if there's no more data
  11475. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  11476. // Support: Chrome <=35 - 45
  11477. // Webkit & Blink performance suffers when deleting properties
  11478. // from DOM nodes, so set to undefined instead
  11479. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  11480. if ( owner.nodeType ) {
  11481. owner[ this.expando ] = undefined;
  11482. } else {
  11483. delete owner[ this.expando ];
  11484. }
  11485. }
  11486. },
  11487. hasData: function( owner ) {
  11488. var cache = owner[ this.expando ];
  11489. return cache !== undefined && !jQuery.isEmptyObject( cache );
  11490. }
  11491. };
  11492. var dataPriv = new Data();
  11493. var dataUser = new Data();
  11494. // Implementation Summary
  11495. //
  11496. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  11497. // 2. Improve the module's maintainability by reducing the storage
  11498. // paths to a single mechanism.
  11499. // 3. Use the same single mechanism to support "private" and "user" data.
  11500. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  11501. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  11502. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  11503. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  11504. rmultiDash = /[A-Z]/g;
  11505. function getData( data ) {
  11506. if ( data === "true" ) {
  11507. return true;
  11508. }
  11509. if ( data === "false" ) {
  11510. return false;
  11511. }
  11512. if ( data === "null" ) {
  11513. return null;
  11514. }
  11515. // Only convert to a number if it doesn't change the string
  11516. if ( data === +data + "" ) {
  11517. return +data;
  11518. }
  11519. if ( rbrace.test( data ) ) {
  11520. return JSON.parse( data );
  11521. }
  11522. return data;
  11523. }
  11524. function dataAttr( elem, key, data ) {
  11525. var name;
  11526. // If nothing was found internally, try to fetch any
  11527. // data from the HTML5 data-* attribute
  11528. if ( data === undefined && elem.nodeType === 1 ) {
  11529. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  11530. data = elem.getAttribute( name );
  11531. if ( typeof data === "string" ) {
  11532. try {
  11533. data = getData( data );
  11534. } catch ( e ) {}
  11535. // Make sure we set the data so it isn't changed later
  11536. dataUser.set( elem, key, data );
  11537. } else {
  11538. data = undefined;
  11539. }
  11540. }
  11541. return data;
  11542. }
  11543. jQuery.extend( {
  11544. hasData: function( elem ) {
  11545. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  11546. },
  11547. data: function( elem, name, data ) {
  11548. return dataUser.access( elem, name, data );
  11549. },
  11550. removeData: function( elem, name ) {
  11551. dataUser.remove( elem, name );
  11552. },
  11553. // TODO: Now that all calls to _data and _removeData have been replaced
  11554. // with direct calls to dataPriv methods, these can be deprecated.
  11555. _data: function( elem, name, data ) {
  11556. return dataPriv.access( elem, name, data );
  11557. },
  11558. _removeData: function( elem, name ) {
  11559. dataPriv.remove( elem, name );
  11560. }
  11561. } );
  11562. jQuery.fn.extend( {
  11563. data: function( key, value ) {
  11564. var i, name, data,
  11565. elem = this[ 0 ],
  11566. attrs = elem && elem.attributes;
  11567. // Gets all values
  11568. if ( key === undefined ) {
  11569. if ( this.length ) {
  11570. data = dataUser.get( elem );
  11571. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  11572. i = attrs.length;
  11573. while ( i-- ) {
  11574. // Support: IE 11 only
  11575. // The attrs elements can be null (#14894)
  11576. if ( attrs[ i ] ) {
  11577. name = attrs[ i ].name;
  11578. if ( name.indexOf( "data-" ) === 0 ) {
  11579. name = camelCase( name.slice( 5 ) );
  11580. dataAttr( elem, name, data[ name ] );
  11581. }
  11582. }
  11583. }
  11584. dataPriv.set( elem, "hasDataAttrs", true );
  11585. }
  11586. }
  11587. return data;
  11588. }
  11589. // Sets multiple values
  11590. if ( typeof key === "object" ) {
  11591. return this.each( function() {
  11592. dataUser.set( this, key );
  11593. } );
  11594. }
  11595. return access( this, function( value ) {
  11596. var data;
  11597. // The calling jQuery object (element matches) is not empty
  11598. // (and therefore has an element appears at this[ 0 ]) and the
  11599. // `value` parameter was not undefined. An empty jQuery object
  11600. // will result in `undefined` for elem = this[ 0 ] which will
  11601. // throw an exception if an attempt to read a data cache is made.
  11602. if ( elem && value === undefined ) {
  11603. // Attempt to get data from the cache
  11604. // The key will always be camelCased in Data
  11605. data = dataUser.get( elem, key );
  11606. if ( data !== undefined ) {
  11607. return data;
  11608. }
  11609. // Attempt to "discover" the data in
  11610. // HTML5 custom data-* attrs
  11611. data = dataAttr( elem, key );
  11612. if ( data !== undefined ) {
  11613. return data;
  11614. }
  11615. // We tried really hard, but the data doesn't exist.
  11616. return;
  11617. }
  11618. // Set the data...
  11619. this.each( function() {
  11620. // We always store the camelCased key
  11621. dataUser.set( this, key, value );
  11622. } );
  11623. }, null, value, arguments.length > 1, null, true );
  11624. },
  11625. removeData: function( key ) {
  11626. return this.each( function() {
  11627. dataUser.remove( this, key );
  11628. } );
  11629. }
  11630. } );
  11631. jQuery.extend( {
  11632. queue: function( elem, type, data ) {
  11633. var queue;
  11634. if ( elem ) {
  11635. type = ( type || "fx" ) + "queue";
  11636. queue = dataPriv.get( elem, type );
  11637. // Speed up dequeue by getting out quickly if this is just a lookup
  11638. if ( data ) {
  11639. if ( !queue || Array.isArray( data ) ) {
  11640. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  11641. } else {
  11642. queue.push( data );
  11643. }
  11644. }
  11645. return queue || [];
  11646. }
  11647. },
  11648. dequeue: function( elem, type ) {
  11649. type = type || "fx";
  11650. var queue = jQuery.queue( elem, type ),
  11651. startLength = queue.length,
  11652. fn = queue.shift(),
  11653. hooks = jQuery._queueHooks( elem, type ),
  11654. next = function() {
  11655. jQuery.dequeue( elem, type );
  11656. };
  11657. // If the fx queue is dequeued, always remove the progress sentinel
  11658. if ( fn === "inprogress" ) {
  11659. fn = queue.shift();
  11660. startLength--;
  11661. }
  11662. if ( fn ) {
  11663. // Add a progress sentinel to prevent the fx queue from being
  11664. // automatically dequeued
  11665. if ( type === "fx" ) {
  11666. queue.unshift( "inprogress" );
  11667. }
  11668. // Clear up the last queue stop function
  11669. delete hooks.stop;
  11670. fn.call( elem, next, hooks );
  11671. }
  11672. if ( !startLength && hooks ) {
  11673. hooks.empty.fire();
  11674. }
  11675. },
  11676. // Not public - generate a queueHooks object, or return the current one
  11677. _queueHooks: function( elem, type ) {
  11678. var key = type + "queueHooks";
  11679. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  11680. empty: jQuery.Callbacks( "once memory" ).add( function() {
  11681. dataPriv.remove( elem, [ type + "queue", key ] );
  11682. } )
  11683. } );
  11684. }
  11685. } );
  11686. jQuery.fn.extend( {
  11687. queue: function( type, data ) {
  11688. var setter = 2;
  11689. if ( typeof type !== "string" ) {
  11690. data = type;
  11691. type = "fx";
  11692. setter--;
  11693. }
  11694. if ( arguments.length < setter ) {
  11695. return jQuery.queue( this[ 0 ], type );
  11696. }
  11697. return data === undefined ?
  11698. this :
  11699. this.each( function() {
  11700. var queue = jQuery.queue( this, type, data );
  11701. // Ensure a hooks for this queue
  11702. jQuery._queueHooks( this, type );
  11703. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  11704. jQuery.dequeue( this, type );
  11705. }
  11706. } );
  11707. },
  11708. dequeue: function( type ) {
  11709. return this.each( function() {
  11710. jQuery.dequeue( this, type );
  11711. } );
  11712. },
  11713. clearQueue: function( type ) {
  11714. return this.queue( type || "fx", [] );
  11715. },
  11716. // Get a promise resolved when queues of a certain type
  11717. // are emptied (fx is the type by default)
  11718. promise: function( type, obj ) {
  11719. var tmp,
  11720. count = 1,
  11721. defer = jQuery.Deferred(),
  11722. elements = this,
  11723. i = this.length,
  11724. resolve = function() {
  11725. if ( !( --count ) ) {
  11726. defer.resolveWith( elements, [ elements ] );
  11727. }
  11728. };
  11729. if ( typeof type !== "string" ) {
  11730. obj = type;
  11731. type = undefined;
  11732. }
  11733. type = type || "fx";
  11734. while ( i-- ) {
  11735. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  11736. if ( tmp && tmp.empty ) {
  11737. count++;
  11738. tmp.empty.add( resolve );
  11739. }
  11740. }
  11741. resolve();
  11742. return defer.promise( obj );
  11743. }
  11744. } );
  11745. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  11746. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  11747. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  11748. var documentElement = document.documentElement;
  11749. var isAttached = function( elem ) {
  11750. return jQuery.contains( elem.ownerDocument, elem );
  11751. },
  11752. composed = { composed: true };
  11753. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  11754. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  11755. // Support: iOS 10.0-10.2 only
  11756. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  11757. // leading to errors. We need to check for `getRootNode`.
  11758. if ( documentElement.getRootNode ) {
  11759. isAttached = function( elem ) {
  11760. return jQuery.contains( elem.ownerDocument, elem ) ||
  11761. elem.getRootNode( composed ) === elem.ownerDocument;
  11762. };
  11763. }
  11764. var isHiddenWithinTree = function( elem, el ) {
  11765. // isHiddenWithinTree might be called from jQuery#filter function;
  11766. // in that case, element will be second argument
  11767. elem = el || elem;
  11768. // Inline style trumps all
  11769. return elem.style.display === "none" ||
  11770. elem.style.display === "" &&
  11771. // Otherwise, check computed style
  11772. // Support: Firefox <=43 - 45
  11773. // Disconnected elements can have computed display: none, so first confirm that elem is
  11774. // in the document.
  11775. isAttached( elem ) &&
  11776. jQuery.css( elem, "display" ) === "none";
  11777. };
  11778. var swap = function( elem, options, callback, args ) {
  11779. var ret, name,
  11780. old = {};
  11781. // Remember the old values, and insert the new ones
  11782. for ( name in options ) {
  11783. old[ name ] = elem.style[ name ];
  11784. elem.style[ name ] = options[ name ];
  11785. }
  11786. ret = callback.apply( elem, args || [] );
  11787. // Revert the old values
  11788. for ( name in options ) {
  11789. elem.style[ name ] = old[ name ];
  11790. }
  11791. return ret;
  11792. };
  11793. function adjustCSS( elem, prop, valueParts, tween ) {
  11794. var adjusted, scale,
  11795. maxIterations = 20,
  11796. currentValue = tween ?
  11797. function() {
  11798. return tween.cur();
  11799. } :
  11800. function() {
  11801. return jQuery.css( elem, prop, "" );
  11802. },
  11803. initial = currentValue(),
  11804. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  11805. // Starting value computation is required for potential unit mismatches
  11806. initialInUnit = elem.nodeType &&
  11807. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  11808. rcssNum.exec( jQuery.css( elem, prop ) );
  11809. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  11810. // Support: Firefox <=54
  11811. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  11812. initial = initial / 2;
  11813. // Trust units reported by jQuery.css
  11814. unit = unit || initialInUnit[ 3 ];
  11815. // Iteratively approximate from a nonzero starting point
  11816. initialInUnit = +initial || 1;
  11817. while ( maxIterations-- ) {
  11818. // Evaluate and update our best guess (doubling guesses that zero out).
  11819. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  11820. jQuery.style( elem, prop, initialInUnit + unit );
  11821. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  11822. maxIterations = 0;
  11823. }
  11824. initialInUnit = initialInUnit / scale;
  11825. }
  11826. initialInUnit = initialInUnit * 2;
  11827. jQuery.style( elem, prop, initialInUnit + unit );
  11828. // Make sure we update the tween properties later on
  11829. valueParts = valueParts || [];
  11830. }
  11831. if ( valueParts ) {
  11832. initialInUnit = +initialInUnit || +initial || 0;
  11833. // Apply relative offset (+=/-=) if specified
  11834. adjusted = valueParts[ 1 ] ?
  11835. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  11836. +valueParts[ 2 ];
  11837. if ( tween ) {
  11838. tween.unit = unit;
  11839. tween.start = initialInUnit;
  11840. tween.end = adjusted;
  11841. }
  11842. }
  11843. return adjusted;
  11844. }
  11845. var defaultDisplayMap = {};
  11846. function getDefaultDisplay( elem ) {
  11847. var temp,
  11848. doc = elem.ownerDocument,
  11849. nodeName = elem.nodeName,
  11850. display = defaultDisplayMap[ nodeName ];
  11851. if ( display ) {
  11852. return display;
  11853. }
  11854. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  11855. display = jQuery.css( temp, "display" );
  11856. temp.parentNode.removeChild( temp );
  11857. if ( display === "none" ) {
  11858. display = "block";
  11859. }
  11860. defaultDisplayMap[ nodeName ] = display;
  11861. return display;
  11862. }
  11863. function showHide( elements, show ) {
  11864. var display, elem,
  11865. values = [],
  11866. index = 0,
  11867. length = elements.length;
  11868. // Determine new display value for elements that need to change
  11869. for ( ; index < length; index++ ) {
  11870. elem = elements[ index ];
  11871. if ( !elem.style ) {
  11872. continue;
  11873. }
  11874. display = elem.style.display;
  11875. if ( show ) {
  11876. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  11877. // check is required in this first loop unless we have a nonempty display value (either
  11878. // inline or about-to-be-restored)
  11879. if ( display === "none" ) {
  11880. values[ index ] = dataPriv.get( elem, "display" ) || null;
  11881. if ( !values[ index ] ) {
  11882. elem.style.display = "";
  11883. }
  11884. }
  11885. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  11886. values[ index ] = getDefaultDisplay( elem );
  11887. }
  11888. } else {
  11889. if ( display !== "none" ) {
  11890. values[ index ] = "none";
  11891. // Remember what we're overwriting
  11892. dataPriv.set( elem, "display", display );
  11893. }
  11894. }
  11895. }
  11896. // Set the display of the elements in a second loop to avoid constant reflow
  11897. for ( index = 0; index < length; index++ ) {
  11898. if ( values[ index ] != null ) {
  11899. elements[ index ].style.display = values[ index ];
  11900. }
  11901. }
  11902. return elements;
  11903. }
  11904. jQuery.fn.extend( {
  11905. show: function() {
  11906. return showHide( this, true );
  11907. },
  11908. hide: function() {
  11909. return showHide( this );
  11910. },
  11911. toggle: function( state ) {
  11912. if ( typeof state === "boolean" ) {
  11913. return state ? this.show() : this.hide();
  11914. }
  11915. return this.each( function() {
  11916. if ( isHiddenWithinTree( this ) ) {
  11917. jQuery( this ).show();
  11918. } else {
  11919. jQuery( this ).hide();
  11920. }
  11921. } );
  11922. }
  11923. } );
  11924. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  11925. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  11926. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  11927. // We have to close these tags to support XHTML (#13200)
  11928. var wrapMap = {
  11929. // Support: IE <=9 only
  11930. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  11931. // XHTML parsers do not magically insert elements in the
  11932. // same way that tag soup parsers do. So we cannot shorten
  11933. // this by omitting <tbody> or other required elements.
  11934. thead: [ 1, "<table>", "</table>" ],
  11935. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  11936. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  11937. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  11938. _default: [ 0, "", "" ]
  11939. };
  11940. // Support: IE <=9 only
  11941. wrapMap.optgroup = wrapMap.option;
  11942. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  11943. wrapMap.th = wrapMap.td;
  11944. function getAll( context, tag ) {
  11945. // Support: IE <=9 - 11 only
  11946. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  11947. var ret;
  11948. if ( typeof context.getElementsByTagName !== "undefined" ) {
  11949. ret = context.getElementsByTagName( tag || "*" );
  11950. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  11951. ret = context.querySelectorAll( tag || "*" );
  11952. } else {
  11953. ret = [];
  11954. }
  11955. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  11956. return jQuery.merge( [ context ], ret );
  11957. }
  11958. return ret;
  11959. }
  11960. // Mark scripts as having already been evaluated
  11961. function setGlobalEval( elems, refElements ) {
  11962. var i = 0,
  11963. l = elems.length;
  11964. for ( ; i < l; i++ ) {
  11965. dataPriv.set(
  11966. elems[ i ],
  11967. "globalEval",
  11968. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  11969. );
  11970. }
  11971. }
  11972. var rhtml = /<|&#?\w+;/;
  11973. function buildFragment( elems, context, scripts, selection, ignored ) {
  11974. var elem, tmp, tag, wrap, attached, j,
  11975. fragment = context.createDocumentFragment(),
  11976. nodes = [],
  11977. i = 0,
  11978. l = elems.length;
  11979. for ( ; i < l; i++ ) {
  11980. elem = elems[ i ];
  11981. if ( elem || elem === 0 ) {
  11982. // Add nodes directly
  11983. if ( toType( elem ) === "object" ) {
  11984. // Support: Android <=4.0 only, PhantomJS 1 only
  11985. // push.apply(_, arraylike) throws on ancient WebKit
  11986. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  11987. // Convert non-html into a text node
  11988. } else if ( !rhtml.test( elem ) ) {
  11989. nodes.push( context.createTextNode( elem ) );
  11990. // Convert html into DOM nodes
  11991. } else {
  11992. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  11993. // Deserialize a standard representation
  11994. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  11995. wrap = wrapMap[ tag ] || wrapMap._default;
  11996. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  11997. // Descend through wrappers to the right content
  11998. j = wrap[ 0 ];
  11999. while ( j-- ) {
  12000. tmp = tmp.lastChild;
  12001. }
  12002. // Support: Android <=4.0 only, PhantomJS 1 only
  12003. // push.apply(_, arraylike) throws on ancient WebKit
  12004. jQuery.merge( nodes, tmp.childNodes );
  12005. // Remember the top-level container
  12006. tmp = fragment.firstChild;
  12007. // Ensure the created nodes are orphaned (#12392)
  12008. tmp.textContent = "";
  12009. }
  12010. }
  12011. }
  12012. // Remove wrapper from fragment
  12013. fragment.textContent = "";
  12014. i = 0;
  12015. while ( ( elem = nodes[ i++ ] ) ) {
  12016. // Skip elements already in the context collection (trac-4087)
  12017. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  12018. if ( ignored ) {
  12019. ignored.push( elem );
  12020. }
  12021. continue;
  12022. }
  12023. attached = isAttached( elem );
  12024. // Append to fragment
  12025. tmp = getAll( fragment.appendChild( elem ), "script" );
  12026. // Preserve script evaluation history
  12027. if ( attached ) {
  12028. setGlobalEval( tmp );
  12029. }
  12030. // Capture executables
  12031. if ( scripts ) {
  12032. j = 0;
  12033. while ( ( elem = tmp[ j++ ] ) ) {
  12034. if ( rscriptType.test( elem.type || "" ) ) {
  12035. scripts.push( elem );
  12036. }
  12037. }
  12038. }
  12039. }
  12040. return fragment;
  12041. }
  12042. ( function() {
  12043. var fragment = document.createDocumentFragment(),
  12044. div = fragment.appendChild( document.createElement( "div" ) ),
  12045. input = document.createElement( "input" );
  12046. // Support: Android 4.0 - 4.3 only
  12047. // Check state lost if the name is set (#11217)
  12048. // Support: Windows Web Apps (WWA)
  12049. // `name` and `type` must use .setAttribute for WWA (#14901)
  12050. input.setAttribute( "type", "radio" );
  12051. input.setAttribute( "checked", "checked" );
  12052. input.setAttribute( "name", "t" );
  12053. div.appendChild( input );
  12054. // Support: Android <=4.1 only
  12055. // Older WebKit doesn't clone checked state correctly in fragments
  12056. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  12057. // Support: IE <=11 only
  12058. // Make sure textarea (and checkbox) defaultValue is properly cloned
  12059. div.innerHTML = "<textarea>x</textarea>";
  12060. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  12061. } )();
  12062. var
  12063. rkeyEvent = /^key/,
  12064. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  12065. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  12066. function returnTrue() {
  12067. return true;
  12068. }
  12069. function returnFalse() {
  12070. return false;
  12071. }
  12072. // Support: IE <=9 - 11+
  12073. // focus() and blur() are asynchronous, except when they are no-op.
  12074. // So expect focus to be synchronous when the element is already active,
  12075. // and blur to be synchronous when the element is not already active.
  12076. // (focus and blur are always synchronous in other supported browsers,
  12077. // this just defines when we can count on it).
  12078. function expectSync( elem, type ) {
  12079. return ( elem === safeActiveElement() ) === ( type === "focus" );
  12080. }
  12081. // Support: IE <=9 only
  12082. // Accessing document.activeElement can throw unexpectedly
  12083. // https://bugs.jquery.com/ticket/13393
  12084. function safeActiveElement() {
  12085. try {
  12086. return document.activeElement;
  12087. } catch ( err ) { }
  12088. }
  12089. function on( elem, types, selector, data, fn, one ) {
  12090. var origFn, type;
  12091. // Types can be a map of types/handlers
  12092. if ( typeof types === "object" ) {
  12093. // ( types-Object, selector, data )
  12094. if ( typeof selector !== "string" ) {
  12095. // ( types-Object, data )
  12096. data = data || selector;
  12097. selector = undefined;
  12098. }
  12099. for ( type in types ) {
  12100. on( elem, type, selector, data, types[ type ], one );
  12101. }
  12102. return elem;
  12103. }
  12104. if ( data == null && fn == null ) {
  12105. // ( types, fn )
  12106. fn = selector;
  12107. data = selector = undefined;
  12108. } else if ( fn == null ) {
  12109. if ( typeof selector === "string" ) {
  12110. // ( types, selector, fn )
  12111. fn = data;
  12112. data = undefined;
  12113. } else {
  12114. // ( types, data, fn )
  12115. fn = data;
  12116. data = selector;
  12117. selector = undefined;
  12118. }
  12119. }
  12120. if ( fn === false ) {
  12121. fn = returnFalse;
  12122. } else if ( !fn ) {
  12123. return elem;
  12124. }
  12125. if ( one === 1 ) {
  12126. origFn = fn;
  12127. fn = function( event ) {
  12128. // Can use an empty set, since event contains the info
  12129. jQuery().off( event );
  12130. return origFn.apply( this, arguments );
  12131. };
  12132. // Use same guid so caller can remove using origFn
  12133. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  12134. }
  12135. return elem.each( function() {
  12136. jQuery.event.add( this, types, fn, data, selector );
  12137. } );
  12138. }
  12139. /*
  12140. * Helper functions for managing events -- not part of the public interface.
  12141. * Props to Dean Edwards' addEvent library for many of the ideas.
  12142. */
  12143. jQuery.event = {
  12144. global: {},
  12145. add: function( elem, types, handler, data, selector ) {
  12146. var handleObjIn, eventHandle, tmp,
  12147. events, t, handleObj,
  12148. special, handlers, type, namespaces, origType,
  12149. elemData = dataPriv.get( elem );
  12150. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  12151. if ( !elemData ) {
  12152. return;
  12153. }
  12154. // Caller can pass in an object of custom data in lieu of the handler
  12155. if ( handler.handler ) {
  12156. handleObjIn = handler;
  12157. handler = handleObjIn.handler;
  12158. selector = handleObjIn.selector;
  12159. }
  12160. // Ensure that invalid selectors throw exceptions at attach time
  12161. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  12162. if ( selector ) {
  12163. jQuery.find.matchesSelector( documentElement, selector );
  12164. }
  12165. // Make sure that the handler has a unique ID, used to find/remove it later
  12166. if ( !handler.guid ) {
  12167. handler.guid = jQuery.guid++;
  12168. }
  12169. // Init the element's event structure and main handler, if this is the first
  12170. if ( !( events = elemData.events ) ) {
  12171. events = elemData.events = {};
  12172. }
  12173. if ( !( eventHandle = elemData.handle ) ) {
  12174. eventHandle = elemData.handle = function( e ) {
  12175. // Discard the second event of a jQuery.event.trigger() and
  12176. // when an event is called after a page has unloaded
  12177. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  12178. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  12179. };
  12180. }
  12181. // Handle multiple events separated by a space
  12182. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12183. t = types.length;
  12184. while ( t-- ) {
  12185. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12186. type = origType = tmp[ 1 ];
  12187. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12188. // There *must* be a type, no attaching namespace-only handlers
  12189. if ( !type ) {
  12190. continue;
  12191. }
  12192. // If event changes its type, use the special event handlers for the changed type
  12193. special = jQuery.event.special[ type ] || {};
  12194. // If selector defined, determine special event api type, otherwise given type
  12195. type = ( selector ? special.delegateType : special.bindType ) || type;
  12196. // Update special based on newly reset type
  12197. special = jQuery.event.special[ type ] || {};
  12198. // handleObj is passed to all event handlers
  12199. handleObj = jQuery.extend( {
  12200. type: type,
  12201. origType: origType,
  12202. data: data,
  12203. handler: handler,
  12204. guid: handler.guid,
  12205. selector: selector,
  12206. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  12207. namespace: namespaces.join( "." )
  12208. }, handleObjIn );
  12209. // Init the event handler queue if we're the first
  12210. if ( !( handlers = events[ type ] ) ) {
  12211. handlers = events[ type ] = [];
  12212. handlers.delegateCount = 0;
  12213. // Only use addEventListener if the special events handler returns false
  12214. if ( !special.setup ||
  12215. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  12216. if ( elem.addEventListener ) {
  12217. elem.addEventListener( type, eventHandle );
  12218. }
  12219. }
  12220. }
  12221. if ( special.add ) {
  12222. special.add.call( elem, handleObj );
  12223. if ( !handleObj.handler.guid ) {
  12224. handleObj.handler.guid = handler.guid;
  12225. }
  12226. }
  12227. // Add to the element's handler list, delegates in front
  12228. if ( selector ) {
  12229. handlers.splice( handlers.delegateCount++, 0, handleObj );
  12230. } else {
  12231. handlers.push( handleObj );
  12232. }
  12233. // Keep track of which events have ever been used, for event optimization
  12234. jQuery.event.global[ type ] = true;
  12235. }
  12236. },
  12237. // Detach an event or set of events from an element
  12238. remove: function( elem, types, handler, selector, mappedTypes ) {
  12239. var j, origCount, tmp,
  12240. events, t, handleObj,
  12241. special, handlers, type, namespaces, origType,
  12242. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  12243. if ( !elemData || !( events = elemData.events ) ) {
  12244. return;
  12245. }
  12246. // Once for each type.namespace in types; type may be omitted
  12247. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12248. t = types.length;
  12249. while ( t-- ) {
  12250. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12251. type = origType = tmp[ 1 ];
  12252. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12253. // Unbind all events (on this namespace, if provided) for the element
  12254. if ( !type ) {
  12255. for ( type in events ) {
  12256. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  12257. }
  12258. continue;
  12259. }
  12260. special = jQuery.event.special[ type ] || {};
  12261. type = ( selector ? special.delegateType : special.bindType ) || type;
  12262. handlers = events[ type ] || [];
  12263. tmp = tmp[ 2 ] &&
  12264. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  12265. // Remove matching events
  12266. origCount = j = handlers.length;
  12267. while ( j-- ) {
  12268. handleObj = handlers[ j ];
  12269. if ( ( mappedTypes || origType === handleObj.origType ) &&
  12270. ( !handler || handler.guid === handleObj.guid ) &&
  12271. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  12272. ( !selector || selector === handleObj.selector ||
  12273. selector === "**" && handleObj.selector ) ) {
  12274. handlers.splice( j, 1 );
  12275. if ( handleObj.selector ) {
  12276. handlers.delegateCount--;
  12277. }
  12278. if ( special.remove ) {
  12279. special.remove.call( elem, handleObj );
  12280. }
  12281. }
  12282. }
  12283. // Remove generic event handler if we removed something and no more handlers exist
  12284. // (avoids potential for endless recursion during removal of special event handlers)
  12285. if ( origCount && !handlers.length ) {
  12286. if ( !special.teardown ||
  12287. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  12288. jQuery.removeEvent( elem, type, elemData.handle );
  12289. }
  12290. delete events[ type ];
  12291. }
  12292. }
  12293. // Remove data and the expando if it's no longer used
  12294. if ( jQuery.isEmptyObject( events ) ) {
  12295. dataPriv.remove( elem, "handle events" );
  12296. }
  12297. },
  12298. dispatch: function( nativeEvent ) {
  12299. // Make a writable jQuery.Event from the native event object
  12300. var event = jQuery.event.fix( nativeEvent );
  12301. var i, j, ret, matched, handleObj, handlerQueue,
  12302. args = new Array( arguments.length ),
  12303. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  12304. special = jQuery.event.special[ event.type ] || {};
  12305. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  12306. args[ 0 ] = event;
  12307. for ( i = 1; i < arguments.length; i++ ) {
  12308. args[ i ] = arguments[ i ];
  12309. }
  12310. event.delegateTarget = this;
  12311. // Call the preDispatch hook for the mapped type, and let it bail if desired
  12312. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  12313. return;
  12314. }
  12315. // Determine handlers
  12316. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  12317. // Run delegates first; they may want to stop propagation beneath us
  12318. i = 0;
  12319. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  12320. event.currentTarget = matched.elem;
  12321. j = 0;
  12322. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  12323. !event.isImmediatePropagationStopped() ) {
  12324. // If the event is namespaced, then each handler is only invoked if it is
  12325. // specially universal or its namespaces are a superset of the event's.
  12326. if ( !event.rnamespace || handleObj.namespace === false ||
  12327. event.rnamespace.test( handleObj.namespace ) ) {
  12328. event.handleObj = handleObj;
  12329. event.data = handleObj.data;
  12330. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  12331. handleObj.handler ).apply( matched.elem, args );
  12332. if ( ret !== undefined ) {
  12333. if ( ( event.result = ret ) === false ) {
  12334. event.preventDefault();
  12335. event.stopPropagation();
  12336. }
  12337. }
  12338. }
  12339. }
  12340. }
  12341. // Call the postDispatch hook for the mapped type
  12342. if ( special.postDispatch ) {
  12343. special.postDispatch.call( this, event );
  12344. }
  12345. return event.result;
  12346. },
  12347. handlers: function( event, handlers ) {
  12348. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  12349. handlerQueue = [],
  12350. delegateCount = handlers.delegateCount,
  12351. cur = event.target;
  12352. // Find delegate handlers
  12353. if ( delegateCount &&
  12354. // Support: IE <=9
  12355. // Black-hole SVG <use> instance trees (trac-13180)
  12356. cur.nodeType &&
  12357. // Support: Firefox <=42
  12358. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  12359. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  12360. // Support: IE 11 only
  12361. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  12362. !( event.type === "click" && event.button >= 1 ) ) {
  12363. for ( ; cur !== this; cur = cur.parentNode || this ) {
  12364. // Don't check non-elements (#13208)
  12365. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  12366. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  12367. matchedHandlers = [];
  12368. matchedSelectors = {};
  12369. for ( i = 0; i < delegateCount; i++ ) {
  12370. handleObj = handlers[ i ];
  12371. // Don't conflict with Object.prototype properties (#13203)
  12372. sel = handleObj.selector + " ";
  12373. if ( matchedSelectors[ sel ] === undefined ) {
  12374. matchedSelectors[ sel ] = handleObj.needsContext ?
  12375. jQuery( sel, this ).index( cur ) > -1 :
  12376. jQuery.find( sel, this, null, [ cur ] ).length;
  12377. }
  12378. if ( matchedSelectors[ sel ] ) {
  12379. matchedHandlers.push( handleObj );
  12380. }
  12381. }
  12382. if ( matchedHandlers.length ) {
  12383. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  12384. }
  12385. }
  12386. }
  12387. }
  12388. // Add the remaining (directly-bound) handlers
  12389. cur = this;
  12390. if ( delegateCount < handlers.length ) {
  12391. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  12392. }
  12393. return handlerQueue;
  12394. },
  12395. addProp: function( name, hook ) {
  12396. Object.defineProperty( jQuery.Event.prototype, name, {
  12397. enumerable: true,
  12398. configurable: true,
  12399. get: isFunction( hook ) ?
  12400. function() {
  12401. if ( this.originalEvent ) {
  12402. return hook( this.originalEvent );
  12403. }
  12404. } :
  12405. function() {
  12406. if ( this.originalEvent ) {
  12407. return this.originalEvent[ name ];
  12408. }
  12409. },
  12410. set: function( value ) {
  12411. Object.defineProperty( this, name, {
  12412. enumerable: true,
  12413. configurable: true,
  12414. writable: true,
  12415. value: value
  12416. } );
  12417. }
  12418. } );
  12419. },
  12420. fix: function( originalEvent ) {
  12421. return originalEvent[ jQuery.expando ] ?
  12422. originalEvent :
  12423. new jQuery.Event( originalEvent );
  12424. },
  12425. special: {
  12426. load: {
  12427. // Prevent triggered image.load events from bubbling to window.load
  12428. noBubble: true
  12429. },
  12430. click: {
  12431. // Utilize native event to ensure correct state for checkable inputs
  12432. setup: function( data ) {
  12433. // For mutual compressibility with _default, replace `this` access with a local var.
  12434. // `|| data` is dead code meant only to preserve the variable through minification.
  12435. var el = this || data;
  12436. // Claim the first handler
  12437. if ( rcheckableType.test( el.type ) &&
  12438. el.click && nodeName( el, "input" ) ) {
  12439. // dataPriv.set( el, "click", ... )
  12440. leverageNative( el, "click", returnTrue );
  12441. }
  12442. // Return false to allow normal processing in the caller
  12443. return false;
  12444. },
  12445. trigger: function( data ) {
  12446. // For mutual compressibility with _default, replace `this` access with a local var.
  12447. // `|| data` is dead code meant only to preserve the variable through minification.
  12448. var el = this || data;
  12449. // Force setup before triggering a click
  12450. if ( rcheckableType.test( el.type ) &&
  12451. el.click && nodeName( el, "input" ) ) {
  12452. leverageNative( el, "click" );
  12453. }
  12454. // Return non-false to allow normal event-path propagation
  12455. return true;
  12456. },
  12457. // For cross-browser consistency, suppress native .click() on links
  12458. // Also prevent it if we're currently inside a leveraged native-event stack
  12459. _default: function( event ) {
  12460. var target = event.target;
  12461. return rcheckableType.test( target.type ) &&
  12462. target.click && nodeName( target, "input" ) &&
  12463. dataPriv.get( target, "click" ) ||
  12464. nodeName( target, "a" );
  12465. }
  12466. },
  12467. beforeunload: {
  12468. postDispatch: function( event ) {
  12469. // Support: Firefox 20+
  12470. // Firefox doesn't alert if the returnValue field is not set.
  12471. if ( event.result !== undefined && event.originalEvent ) {
  12472. event.originalEvent.returnValue = event.result;
  12473. }
  12474. }
  12475. }
  12476. }
  12477. };
  12478. // Ensure the presence of an event listener that handles manually-triggered
  12479. // synthetic events by interrupting progress until reinvoked in response to
  12480. // *native* events that it fires directly, ensuring that state changes have
  12481. // already occurred before other listeners are invoked.
  12482. function leverageNative( el, type, expectSync ) {
  12483. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  12484. if ( !expectSync ) {
  12485. if ( dataPriv.get( el, type ) === undefined ) {
  12486. jQuery.event.add( el, type, returnTrue );
  12487. }
  12488. return;
  12489. }
  12490. // Register the controller as a special universal handler for all event namespaces
  12491. dataPriv.set( el, type, false );
  12492. jQuery.event.add( el, type, {
  12493. namespace: false,
  12494. handler: function( event ) {
  12495. var notAsync, result,
  12496. saved = dataPriv.get( this, type );
  12497. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  12498. // Interrupt processing of the outer synthetic .trigger()ed event
  12499. // Saved data should be false in such cases, but might be a leftover capture object
  12500. // from an async native handler (gh-4350)
  12501. if ( !saved.length ) {
  12502. // Store arguments for use when handling the inner native event
  12503. // There will always be at least one argument (an event object), so this array
  12504. // will not be confused with a leftover capture object.
  12505. saved = slice.call( arguments );
  12506. dataPriv.set( this, type, saved );
  12507. // Trigger the native event and capture its result
  12508. // Support: IE <=9 - 11+
  12509. // focus() and blur() are asynchronous
  12510. notAsync = expectSync( this, type );
  12511. this[ type ]();
  12512. result = dataPriv.get( this, type );
  12513. if ( saved !== result || notAsync ) {
  12514. dataPriv.set( this, type, false );
  12515. } else {
  12516. result = {};
  12517. }
  12518. if ( saved !== result ) {
  12519. // Cancel the outer synthetic event
  12520. event.stopImmediatePropagation();
  12521. event.preventDefault();
  12522. return result.value;
  12523. }
  12524. // If this is an inner synthetic event for an event with a bubbling surrogate
  12525. // (focus or blur), assume that the surrogate already propagated from triggering the
  12526. // native event and prevent that from happening again here.
  12527. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  12528. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  12529. // less bad than duplication.
  12530. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  12531. event.stopPropagation();
  12532. }
  12533. // If this is a native event triggered above, everything is now in order
  12534. // Fire an inner synthetic event with the original arguments
  12535. } else if ( saved.length ) {
  12536. // ...and capture the result
  12537. dataPriv.set( this, type, {
  12538. value: jQuery.event.trigger(
  12539. // Support: IE <=9 - 11+
  12540. // Extend with the prototype to reset the above stopImmediatePropagation()
  12541. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  12542. saved.slice( 1 ),
  12543. this
  12544. )
  12545. } );
  12546. // Abort handling of the native event
  12547. event.stopImmediatePropagation();
  12548. }
  12549. }
  12550. } );
  12551. }
  12552. jQuery.removeEvent = function( elem, type, handle ) {
  12553. // This "if" is needed for plain objects
  12554. if ( elem.removeEventListener ) {
  12555. elem.removeEventListener( type, handle );
  12556. }
  12557. };
  12558. jQuery.Event = function( src, props ) {
  12559. // Allow instantiation without the 'new' keyword
  12560. if ( !( this instanceof jQuery.Event ) ) {
  12561. return new jQuery.Event( src, props );
  12562. }
  12563. // Event object
  12564. if ( src && src.type ) {
  12565. this.originalEvent = src;
  12566. this.type = src.type;
  12567. // Events bubbling up the document may have been marked as prevented
  12568. // by a handler lower down the tree; reflect the correct value.
  12569. this.isDefaultPrevented = src.defaultPrevented ||
  12570. src.defaultPrevented === undefined &&
  12571. // Support: Android <=2.3 only
  12572. src.returnValue === false ?
  12573. returnTrue :
  12574. returnFalse;
  12575. // Create target properties
  12576. // Support: Safari <=6 - 7 only
  12577. // Target should not be a text node (#504, #13143)
  12578. this.target = ( src.target && src.target.nodeType === 3 ) ?
  12579. src.target.parentNode :
  12580. src.target;
  12581. this.currentTarget = src.currentTarget;
  12582. this.relatedTarget = src.relatedTarget;
  12583. // Event type
  12584. } else {
  12585. this.type = src;
  12586. }
  12587. // Put explicitly provided properties onto the event object
  12588. if ( props ) {
  12589. jQuery.extend( this, props );
  12590. }
  12591. // Create a timestamp if incoming event doesn't have one
  12592. this.timeStamp = src && src.timeStamp || Date.now();
  12593. // Mark it as fixed
  12594. this[ jQuery.expando ] = true;
  12595. };
  12596. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  12597. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  12598. jQuery.Event.prototype = {
  12599. constructor: jQuery.Event,
  12600. isDefaultPrevented: returnFalse,
  12601. isPropagationStopped: returnFalse,
  12602. isImmediatePropagationStopped: returnFalse,
  12603. isSimulated: false,
  12604. preventDefault: function() {
  12605. var e = this.originalEvent;
  12606. this.isDefaultPrevented = returnTrue;
  12607. if ( e && !this.isSimulated ) {
  12608. e.preventDefault();
  12609. }
  12610. },
  12611. stopPropagation: function() {
  12612. var e = this.originalEvent;
  12613. this.isPropagationStopped = returnTrue;
  12614. if ( e && !this.isSimulated ) {
  12615. e.stopPropagation();
  12616. }
  12617. },
  12618. stopImmediatePropagation: function() {
  12619. var e = this.originalEvent;
  12620. this.isImmediatePropagationStopped = returnTrue;
  12621. if ( e && !this.isSimulated ) {
  12622. e.stopImmediatePropagation();
  12623. }
  12624. this.stopPropagation();
  12625. }
  12626. };
  12627. // Includes all common event props including KeyEvent and MouseEvent specific props
  12628. jQuery.each( {
  12629. altKey: true,
  12630. bubbles: true,
  12631. cancelable: true,
  12632. changedTouches: true,
  12633. ctrlKey: true,
  12634. detail: true,
  12635. eventPhase: true,
  12636. metaKey: true,
  12637. pageX: true,
  12638. pageY: true,
  12639. shiftKey: true,
  12640. view: true,
  12641. "char": true,
  12642. code: true,
  12643. charCode: true,
  12644. key: true,
  12645. keyCode: true,
  12646. button: true,
  12647. buttons: true,
  12648. clientX: true,
  12649. clientY: true,
  12650. offsetX: true,
  12651. offsetY: true,
  12652. pointerId: true,
  12653. pointerType: true,
  12654. screenX: true,
  12655. screenY: true,
  12656. targetTouches: true,
  12657. toElement: true,
  12658. touches: true,
  12659. which: function( event ) {
  12660. var button = event.button;
  12661. // Add which for key events
  12662. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  12663. return event.charCode != null ? event.charCode : event.keyCode;
  12664. }
  12665. // Add which for click: 1 === left; 2 === middle; 3 === right
  12666. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  12667. if ( button & 1 ) {
  12668. return 1;
  12669. }
  12670. if ( button & 2 ) {
  12671. return 3;
  12672. }
  12673. if ( button & 4 ) {
  12674. return 2;
  12675. }
  12676. return 0;
  12677. }
  12678. return event.which;
  12679. }
  12680. }, jQuery.event.addProp );
  12681. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  12682. jQuery.event.special[ type ] = {
  12683. // Utilize native event if possible so blur/focus sequence is correct
  12684. setup: function() {
  12685. // Claim the first handler
  12686. // dataPriv.set( this, "focus", ... )
  12687. // dataPriv.set( this, "blur", ... )
  12688. leverageNative( this, type, expectSync );
  12689. // Return false to allow normal processing in the caller
  12690. return false;
  12691. },
  12692. trigger: function() {
  12693. // Force setup before trigger
  12694. leverageNative( this, type );
  12695. // Return non-false to allow normal event-path propagation
  12696. return true;
  12697. },
  12698. delegateType: delegateType
  12699. };
  12700. } );
  12701. // Create mouseenter/leave events using mouseover/out and event-time checks
  12702. // so that event delegation works in jQuery.
  12703. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  12704. //
  12705. // Support: Safari 7 only
  12706. // Safari sends mouseenter too often; see:
  12707. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  12708. // for the description of the bug (it existed in older Chrome versions as well).
  12709. jQuery.each( {
  12710. mouseenter: "mouseover",
  12711. mouseleave: "mouseout",
  12712. pointerenter: "pointerover",
  12713. pointerleave: "pointerout"
  12714. }, function( orig, fix ) {
  12715. jQuery.event.special[ orig ] = {
  12716. delegateType: fix,
  12717. bindType: fix,
  12718. handle: function( event ) {
  12719. var ret,
  12720. target = this,
  12721. related = event.relatedTarget,
  12722. handleObj = event.handleObj;
  12723. // For mouseenter/leave call the handler if related is outside the target.
  12724. // NB: No relatedTarget if the mouse left/entered the browser window
  12725. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  12726. event.type = handleObj.origType;
  12727. ret = handleObj.handler.apply( this, arguments );
  12728. event.type = fix;
  12729. }
  12730. return ret;
  12731. }
  12732. };
  12733. } );
  12734. jQuery.fn.extend( {
  12735. on: function( types, selector, data, fn ) {
  12736. return on( this, types, selector, data, fn );
  12737. },
  12738. one: function( types, selector, data, fn ) {
  12739. return on( this, types, selector, data, fn, 1 );
  12740. },
  12741. off: function( types, selector, fn ) {
  12742. var handleObj, type;
  12743. if ( types && types.preventDefault && types.handleObj ) {
  12744. // ( event ) dispatched jQuery.Event
  12745. handleObj = types.handleObj;
  12746. jQuery( types.delegateTarget ).off(
  12747. handleObj.namespace ?
  12748. handleObj.origType + "." + handleObj.namespace :
  12749. handleObj.origType,
  12750. handleObj.selector,
  12751. handleObj.handler
  12752. );
  12753. return this;
  12754. }
  12755. if ( typeof types === "object" ) {
  12756. // ( types-object [, selector] )
  12757. for ( type in types ) {
  12758. this.off( type, selector, types[ type ] );
  12759. }
  12760. return this;
  12761. }
  12762. if ( selector === false || typeof selector === "function" ) {
  12763. // ( types [, fn] )
  12764. fn = selector;
  12765. selector = undefined;
  12766. }
  12767. if ( fn === false ) {
  12768. fn = returnFalse;
  12769. }
  12770. return this.each( function() {
  12771. jQuery.event.remove( this, types, fn, selector );
  12772. } );
  12773. }
  12774. } );
  12775. var
  12776. /* eslint-disable max-len */
  12777. // See https://github.com/eslint/eslint/issues/3229
  12778. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  12779. /* eslint-enable */
  12780. // Support: IE <=10 - 11, Edge 12 - 13 only
  12781. // In IE/Edge using regex groups here causes severe slowdowns.
  12782. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  12783. rnoInnerhtml = /<script|<style|<link/i,
  12784. // checked="checked" or checked
  12785. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  12786. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  12787. // Prefer a tbody over its parent table for containing new rows
  12788. function manipulationTarget( elem, content ) {
  12789. if ( nodeName( elem, "table" ) &&
  12790. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  12791. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  12792. }
  12793. return elem;
  12794. }
  12795. // Replace/restore the type attribute of script elements for safe DOM manipulation
  12796. function disableScript( elem ) {
  12797. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  12798. return elem;
  12799. }
  12800. function restoreScript( elem ) {
  12801. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  12802. elem.type = elem.type.slice( 5 );
  12803. } else {
  12804. elem.removeAttribute( "type" );
  12805. }
  12806. return elem;
  12807. }
  12808. function cloneCopyEvent( src, dest ) {
  12809. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  12810. if ( dest.nodeType !== 1 ) {
  12811. return;
  12812. }
  12813. // 1. Copy private data: events, handlers, etc.
  12814. if ( dataPriv.hasData( src ) ) {
  12815. pdataOld = dataPriv.access( src );
  12816. pdataCur = dataPriv.set( dest, pdataOld );
  12817. events = pdataOld.events;
  12818. if ( events ) {
  12819. delete pdataCur.handle;
  12820. pdataCur.events = {};
  12821. for ( type in events ) {
  12822. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  12823. jQuery.event.add( dest, type, events[ type ][ i ] );
  12824. }
  12825. }
  12826. }
  12827. }
  12828. // 2. Copy user data
  12829. if ( dataUser.hasData( src ) ) {
  12830. udataOld = dataUser.access( src );
  12831. udataCur = jQuery.extend( {}, udataOld );
  12832. dataUser.set( dest, udataCur );
  12833. }
  12834. }
  12835. // Fix IE bugs, see support tests
  12836. function fixInput( src, dest ) {
  12837. var nodeName = dest.nodeName.toLowerCase();
  12838. // Fails to persist the checked state of a cloned checkbox or radio button.
  12839. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  12840. dest.checked = src.checked;
  12841. // Fails to return the selected option to the default selected state when cloning options
  12842. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  12843. dest.defaultValue = src.defaultValue;
  12844. }
  12845. }
  12846. function domManip( collection, args, callback, ignored ) {
  12847. // Flatten any nested arrays
  12848. args = concat.apply( [], args );
  12849. var fragment, first, scripts, hasScripts, node, doc,
  12850. i = 0,
  12851. l = collection.length,
  12852. iNoClone = l - 1,
  12853. value = args[ 0 ],
  12854. valueIsFunction = isFunction( value );
  12855. // We can't cloneNode fragments that contain checked, in WebKit
  12856. if ( valueIsFunction ||
  12857. ( l > 1 && typeof value === "string" &&
  12858. !support.checkClone && rchecked.test( value ) ) ) {
  12859. return collection.each( function( index ) {
  12860. var self = collection.eq( index );
  12861. if ( valueIsFunction ) {
  12862. args[ 0 ] = value.call( this, index, self.html() );
  12863. }
  12864. domManip( self, args, callback, ignored );
  12865. } );
  12866. }
  12867. if ( l ) {
  12868. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  12869. first = fragment.firstChild;
  12870. if ( fragment.childNodes.length === 1 ) {
  12871. fragment = first;
  12872. }
  12873. // Require either new content or an interest in ignored elements to invoke the callback
  12874. if ( first || ignored ) {
  12875. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  12876. hasScripts = scripts.length;
  12877. // Use the original fragment for the last item
  12878. // instead of the first because it can end up
  12879. // being emptied incorrectly in certain situations (#8070).
  12880. for ( ; i < l; i++ ) {
  12881. node = fragment;
  12882. if ( i !== iNoClone ) {
  12883. node = jQuery.clone( node, true, true );
  12884. // Keep references to cloned scripts for later restoration
  12885. if ( hasScripts ) {
  12886. // Support: Android <=4.0 only, PhantomJS 1 only
  12887. // push.apply(_, arraylike) throws on ancient WebKit
  12888. jQuery.merge( scripts, getAll( node, "script" ) );
  12889. }
  12890. }
  12891. callback.call( collection[ i ], node, i );
  12892. }
  12893. if ( hasScripts ) {
  12894. doc = scripts[ scripts.length - 1 ].ownerDocument;
  12895. // Reenable scripts
  12896. jQuery.map( scripts, restoreScript );
  12897. // Evaluate executable scripts on first document insertion
  12898. for ( i = 0; i < hasScripts; i++ ) {
  12899. node = scripts[ i ];
  12900. if ( rscriptType.test( node.type || "" ) &&
  12901. !dataPriv.access( node, "globalEval" ) &&
  12902. jQuery.contains( doc, node ) ) {
  12903. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  12904. // Optional AJAX dependency, but won't run scripts if not present
  12905. if ( jQuery._evalUrl && !node.noModule ) {
  12906. jQuery._evalUrl( node.src, {
  12907. nonce: node.nonce || node.getAttribute( "nonce" )
  12908. } );
  12909. }
  12910. } else {
  12911. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  12912. }
  12913. }
  12914. }
  12915. }
  12916. }
  12917. }
  12918. return collection;
  12919. }
  12920. function remove( elem, selector, keepData ) {
  12921. var node,
  12922. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  12923. i = 0;
  12924. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  12925. if ( !keepData && node.nodeType === 1 ) {
  12926. jQuery.cleanData( getAll( node ) );
  12927. }
  12928. if ( node.parentNode ) {
  12929. if ( keepData && isAttached( node ) ) {
  12930. setGlobalEval( getAll( node, "script" ) );
  12931. }
  12932. node.parentNode.removeChild( node );
  12933. }
  12934. }
  12935. return elem;
  12936. }
  12937. jQuery.extend( {
  12938. htmlPrefilter: function( html ) {
  12939. return html.replace( rxhtmlTag, "<$1></$2>" );
  12940. },
  12941. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  12942. var i, l, srcElements, destElements,
  12943. clone = elem.cloneNode( true ),
  12944. inPage = isAttached( elem );
  12945. // Fix IE cloning issues
  12946. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  12947. !jQuery.isXMLDoc( elem ) ) {
  12948. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  12949. destElements = getAll( clone );
  12950. srcElements = getAll( elem );
  12951. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12952. fixInput( srcElements[ i ], destElements[ i ] );
  12953. }
  12954. }
  12955. // Copy the events from the original to the clone
  12956. if ( dataAndEvents ) {
  12957. if ( deepDataAndEvents ) {
  12958. srcElements = srcElements || getAll( elem );
  12959. destElements = destElements || getAll( clone );
  12960. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12961. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  12962. }
  12963. } else {
  12964. cloneCopyEvent( elem, clone );
  12965. }
  12966. }
  12967. // Preserve script evaluation history
  12968. destElements = getAll( clone, "script" );
  12969. if ( destElements.length > 0 ) {
  12970. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  12971. }
  12972. // Return the cloned set
  12973. return clone;
  12974. },
  12975. cleanData: function( elems ) {
  12976. var data, elem, type,
  12977. special = jQuery.event.special,
  12978. i = 0;
  12979. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  12980. if ( acceptData( elem ) ) {
  12981. if ( ( data = elem[ dataPriv.expando ] ) ) {
  12982. if ( data.events ) {
  12983. for ( type in data.events ) {
  12984. if ( special[ type ] ) {
  12985. jQuery.event.remove( elem, type );
  12986. // This is a shortcut to avoid jQuery.event.remove's overhead
  12987. } else {
  12988. jQuery.removeEvent( elem, type, data.handle );
  12989. }
  12990. }
  12991. }
  12992. // Support: Chrome <=35 - 45+
  12993. // Assign undefined instead of using delete, see Data#remove
  12994. elem[ dataPriv.expando ] = undefined;
  12995. }
  12996. if ( elem[ dataUser.expando ] ) {
  12997. // Support: Chrome <=35 - 45+
  12998. // Assign undefined instead of using delete, see Data#remove
  12999. elem[ dataUser.expando ] = undefined;
  13000. }
  13001. }
  13002. }
  13003. }
  13004. } );
  13005. jQuery.fn.extend( {
  13006. detach: function( selector ) {
  13007. return remove( this, selector, true );
  13008. },
  13009. remove: function( selector ) {
  13010. return remove( this, selector );
  13011. },
  13012. text: function( value ) {
  13013. return access( this, function( value ) {
  13014. return value === undefined ?
  13015. jQuery.text( this ) :
  13016. this.empty().each( function() {
  13017. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13018. this.textContent = value;
  13019. }
  13020. } );
  13021. }, null, value, arguments.length );
  13022. },
  13023. append: function() {
  13024. return domManip( this, arguments, function( elem ) {
  13025. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13026. var target = manipulationTarget( this, elem );
  13027. target.appendChild( elem );
  13028. }
  13029. } );
  13030. },
  13031. prepend: function() {
  13032. return domManip( this, arguments, function( elem ) {
  13033. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13034. var target = manipulationTarget( this, elem );
  13035. target.insertBefore( elem, target.firstChild );
  13036. }
  13037. } );
  13038. },
  13039. before: function() {
  13040. return domManip( this, arguments, function( elem ) {
  13041. if ( this.parentNode ) {
  13042. this.parentNode.insertBefore( elem, this );
  13043. }
  13044. } );
  13045. },
  13046. after: function() {
  13047. return domManip( this, arguments, function( elem ) {
  13048. if ( this.parentNode ) {
  13049. this.parentNode.insertBefore( elem, this.nextSibling );
  13050. }
  13051. } );
  13052. },
  13053. empty: function() {
  13054. var elem,
  13055. i = 0;
  13056. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  13057. if ( elem.nodeType === 1 ) {
  13058. // Prevent memory leaks
  13059. jQuery.cleanData( getAll( elem, false ) );
  13060. // Remove any remaining nodes
  13061. elem.textContent = "";
  13062. }
  13063. }
  13064. return this;
  13065. },
  13066. clone: function( dataAndEvents, deepDataAndEvents ) {
  13067. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  13068. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  13069. return this.map( function() {
  13070. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  13071. } );
  13072. },
  13073. html: function( value ) {
  13074. return access( this, function( value ) {
  13075. var elem = this[ 0 ] || {},
  13076. i = 0,
  13077. l = this.length;
  13078. if ( value === undefined && elem.nodeType === 1 ) {
  13079. return elem.innerHTML;
  13080. }
  13081. // See if we can take a shortcut and just use innerHTML
  13082. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  13083. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  13084. value = jQuery.htmlPrefilter( value );
  13085. try {
  13086. for ( ; i < l; i++ ) {
  13087. elem = this[ i ] || {};
  13088. // Remove element nodes and prevent memory leaks
  13089. if ( elem.nodeType === 1 ) {
  13090. jQuery.cleanData( getAll( elem, false ) );
  13091. elem.innerHTML = value;
  13092. }
  13093. }
  13094. elem = 0;
  13095. // If using innerHTML throws an exception, use the fallback method
  13096. } catch ( e ) {}
  13097. }
  13098. if ( elem ) {
  13099. this.empty().append( value );
  13100. }
  13101. }, null, value, arguments.length );
  13102. },
  13103. replaceWith: function() {
  13104. var ignored = [];
  13105. // Make the changes, replacing each non-ignored context element with the new content
  13106. return domManip( this, arguments, function( elem ) {
  13107. var parent = this.parentNode;
  13108. if ( jQuery.inArray( this, ignored ) < 0 ) {
  13109. jQuery.cleanData( getAll( this ) );
  13110. if ( parent ) {
  13111. parent.replaceChild( elem, this );
  13112. }
  13113. }
  13114. // Force callback invocation
  13115. }, ignored );
  13116. }
  13117. } );
  13118. jQuery.each( {
  13119. appendTo: "append",
  13120. prependTo: "prepend",
  13121. insertBefore: "before",
  13122. insertAfter: "after",
  13123. replaceAll: "replaceWith"
  13124. }, function( name, original ) {
  13125. jQuery.fn[ name ] = function( selector ) {
  13126. var elems,
  13127. ret = [],
  13128. insert = jQuery( selector ),
  13129. last = insert.length - 1,
  13130. i = 0;
  13131. for ( ; i <= last; i++ ) {
  13132. elems = i === last ? this : this.clone( true );
  13133. jQuery( insert[ i ] )[ original ]( elems );
  13134. // Support: Android <=4.0 only, PhantomJS 1 only
  13135. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  13136. push.apply( ret, elems.get() );
  13137. }
  13138. return this.pushStack( ret );
  13139. };
  13140. } );
  13141. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  13142. var getStyles = function( elem ) {
  13143. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  13144. // IE throws on elements created in popups
  13145. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  13146. var view = elem.ownerDocument.defaultView;
  13147. if ( !view || !view.opener ) {
  13148. view = window;
  13149. }
  13150. return view.getComputedStyle( elem );
  13151. };
  13152. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  13153. ( function() {
  13154. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  13155. // so they're executed at the same time to save the second computation.
  13156. function computeStyleTests() {
  13157. // This is a singleton, we need to execute it only once
  13158. if ( !div ) {
  13159. return;
  13160. }
  13161. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  13162. "margin-top:1px;padding:0;border:0";
  13163. div.style.cssText =
  13164. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  13165. "margin:auto;border:1px;padding:1px;" +
  13166. "width:60%;top:1%";
  13167. documentElement.appendChild( container ).appendChild( div );
  13168. var divStyle = window.getComputedStyle( div );
  13169. pixelPositionVal = divStyle.top !== "1%";
  13170. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  13171. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  13172. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  13173. // Some styles come back with percentage values, even though they shouldn't
  13174. div.style.right = "60%";
  13175. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  13176. // Support: IE 9 - 11 only
  13177. // Detect misreporting of content dimensions for box-sizing:border-box elements
  13178. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  13179. // Support: IE 9 only
  13180. // Detect overflow:scroll screwiness (gh-3699)
  13181. // Support: Chrome <=64
  13182. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  13183. div.style.position = "absolute";
  13184. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  13185. documentElement.removeChild( container );
  13186. // Nullify the div so it wouldn't be stored in the memory and
  13187. // it will also be a sign that checks already performed
  13188. div = null;
  13189. }
  13190. function roundPixelMeasures( measure ) {
  13191. return Math.round( parseFloat( measure ) );
  13192. }
  13193. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  13194. reliableMarginLeftVal,
  13195. container = document.createElement( "div" ),
  13196. div = document.createElement( "div" );
  13197. // Finish early in limited (non-browser) environments
  13198. if ( !div.style ) {
  13199. return;
  13200. }
  13201. // Support: IE <=9 - 11 only
  13202. // Style of cloned element affects source element cloned (#8908)
  13203. div.style.backgroundClip = "content-box";
  13204. div.cloneNode( true ).style.backgroundClip = "";
  13205. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  13206. jQuery.extend( support, {
  13207. boxSizingReliable: function() {
  13208. computeStyleTests();
  13209. return boxSizingReliableVal;
  13210. },
  13211. pixelBoxStyles: function() {
  13212. computeStyleTests();
  13213. return pixelBoxStylesVal;
  13214. },
  13215. pixelPosition: function() {
  13216. computeStyleTests();
  13217. return pixelPositionVal;
  13218. },
  13219. reliableMarginLeft: function() {
  13220. computeStyleTests();
  13221. return reliableMarginLeftVal;
  13222. },
  13223. scrollboxSize: function() {
  13224. computeStyleTests();
  13225. return scrollboxSizeVal;
  13226. }
  13227. } );
  13228. } )();
  13229. function curCSS( elem, name, computed ) {
  13230. var width, minWidth, maxWidth, ret,
  13231. // Support: Firefox 51+
  13232. // Retrieving style before computed somehow
  13233. // fixes an issue with getting wrong values
  13234. // on detached elements
  13235. style = elem.style;
  13236. computed = computed || getStyles( elem );
  13237. // getPropertyValue is needed for:
  13238. // .css('filter') (IE 9 only, #12537)
  13239. // .css('--customProperty) (#3144)
  13240. if ( computed ) {
  13241. ret = computed.getPropertyValue( name ) || computed[ name ];
  13242. if ( ret === "" && !isAttached( elem ) ) {
  13243. ret = jQuery.style( elem, name );
  13244. }
  13245. // A tribute to the "awesome hack by Dean Edwards"
  13246. // Android Browser returns percentage for some values,
  13247. // but width seems to be reliably pixels.
  13248. // This is against the CSSOM draft spec:
  13249. // https://drafts.csswg.org/cssom/#resolved-values
  13250. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  13251. // Remember the original values
  13252. width = style.width;
  13253. minWidth = style.minWidth;
  13254. maxWidth = style.maxWidth;
  13255. // Put in the new values to get a computed value out
  13256. style.minWidth = style.maxWidth = style.width = ret;
  13257. ret = computed.width;
  13258. // Revert the changed values
  13259. style.width = width;
  13260. style.minWidth = minWidth;
  13261. style.maxWidth = maxWidth;
  13262. }
  13263. }
  13264. return ret !== undefined ?
  13265. // Support: IE <=9 - 11 only
  13266. // IE returns zIndex value as an integer.
  13267. ret + "" :
  13268. ret;
  13269. }
  13270. function addGetHookIf( conditionFn, hookFn ) {
  13271. // Define the hook, we'll check on the first run if it's really needed.
  13272. return {
  13273. get: function() {
  13274. if ( conditionFn() ) {
  13275. // Hook not needed (or it's not possible to use it due
  13276. // to missing dependency), remove it.
  13277. delete this.get;
  13278. return;
  13279. }
  13280. // Hook needed; redefine it so that the support test is not executed again.
  13281. return ( this.get = hookFn ).apply( this, arguments );
  13282. }
  13283. };
  13284. }
  13285. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  13286. emptyStyle = document.createElement( "div" ).style,
  13287. vendorProps = {};
  13288. // Return a vendor-prefixed property or undefined
  13289. function vendorPropName( name ) {
  13290. // Check for vendor prefixed names
  13291. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  13292. i = cssPrefixes.length;
  13293. while ( i-- ) {
  13294. name = cssPrefixes[ i ] + capName;
  13295. if ( name in emptyStyle ) {
  13296. return name;
  13297. }
  13298. }
  13299. }
  13300. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  13301. function finalPropName( name ) {
  13302. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  13303. if ( final ) {
  13304. return final;
  13305. }
  13306. if ( name in emptyStyle ) {
  13307. return name;
  13308. }
  13309. return vendorProps[ name ] = vendorPropName( name ) || name;
  13310. }
  13311. var
  13312. // Swappable if display is none or starts with table
  13313. // except "table", "table-cell", or "table-caption"
  13314. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  13315. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  13316. rcustomProp = /^--/,
  13317. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  13318. cssNormalTransform = {
  13319. letterSpacing: "0",
  13320. fontWeight: "400"
  13321. };
  13322. function setPositiveNumber( elem, value, subtract ) {
  13323. // Any relative (+/-) values have already been
  13324. // normalized at this point
  13325. var matches = rcssNum.exec( value );
  13326. return matches ?
  13327. // Guard against undefined "subtract", e.g., when used as in cssHooks
  13328. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  13329. value;
  13330. }
  13331. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  13332. var i = dimension === "width" ? 1 : 0,
  13333. extra = 0,
  13334. delta = 0;
  13335. // Adjustment may not be necessary
  13336. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  13337. return 0;
  13338. }
  13339. for ( ; i < 4; i += 2 ) {
  13340. // Both box models exclude margin
  13341. if ( box === "margin" ) {
  13342. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  13343. }
  13344. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  13345. if ( !isBorderBox ) {
  13346. // Add padding
  13347. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13348. // For "border" or "margin", add border
  13349. if ( box !== "padding" ) {
  13350. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13351. // But still keep track of it otherwise
  13352. } else {
  13353. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13354. }
  13355. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  13356. // "padding" or "margin"
  13357. } else {
  13358. // For "content", subtract padding
  13359. if ( box === "content" ) {
  13360. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13361. }
  13362. // For "content" or "padding", subtract border
  13363. if ( box !== "margin" ) {
  13364. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13365. }
  13366. }
  13367. }
  13368. // Account for positive content-box scroll gutter when requested by providing computedVal
  13369. if ( !isBorderBox && computedVal >= 0 ) {
  13370. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  13371. // Assuming integer scroll gutter, subtract the rest and round down
  13372. delta += Math.max( 0, Math.ceil(
  13373. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13374. computedVal -
  13375. delta -
  13376. extra -
  13377. 0.5
  13378. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  13379. // Use an explicit zero to avoid NaN (gh-3964)
  13380. ) ) || 0;
  13381. }
  13382. return delta;
  13383. }
  13384. function getWidthOrHeight( elem, dimension, extra ) {
  13385. // Start with computed style
  13386. var styles = getStyles( elem ),
  13387. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  13388. // Fake content-box until we know it's needed to know the true value.
  13389. boxSizingNeeded = !support.boxSizingReliable() || extra,
  13390. isBorderBox = boxSizingNeeded &&
  13391. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13392. valueIsBorderBox = isBorderBox,
  13393. val = curCSS( elem, dimension, styles ),
  13394. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  13395. // Support: Firefox <=54
  13396. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  13397. if ( rnumnonpx.test( val ) ) {
  13398. if ( !extra ) {
  13399. return val;
  13400. }
  13401. val = "auto";
  13402. }
  13403. // Fall back to offsetWidth/offsetHeight when value is "auto"
  13404. // This happens for inline elements with no explicit setting (gh-3571)
  13405. // Support: Android <=4.1 - 4.3 only
  13406. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  13407. // Support: IE 9-11 only
  13408. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  13409. // We use getClientRects() to check for hidden/disconnected.
  13410. // In those cases, the computed value can be trusted to be border-box
  13411. if ( ( !support.boxSizingReliable() && isBorderBox ||
  13412. val === "auto" ||
  13413. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  13414. elem.getClientRects().length ) {
  13415. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  13416. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  13417. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  13418. // retrieved value as a content box dimension.
  13419. valueIsBorderBox = offsetProp in elem;
  13420. if ( valueIsBorderBox ) {
  13421. val = elem[ offsetProp ];
  13422. }
  13423. }
  13424. // Normalize "" and auto
  13425. val = parseFloat( val ) || 0;
  13426. // Adjust for the element's box model
  13427. return ( val +
  13428. boxModelAdjustment(
  13429. elem,
  13430. dimension,
  13431. extra || ( isBorderBox ? "border" : "content" ),
  13432. valueIsBorderBox,
  13433. styles,
  13434. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  13435. val
  13436. )
  13437. ) + "px";
  13438. }
  13439. jQuery.extend( {
  13440. // Add in style property hooks for overriding the default
  13441. // behavior of getting and setting a style property
  13442. cssHooks: {
  13443. opacity: {
  13444. get: function( elem, computed ) {
  13445. if ( computed ) {
  13446. // We should always get a number back from opacity
  13447. var ret = curCSS( elem, "opacity" );
  13448. return ret === "" ? "1" : ret;
  13449. }
  13450. }
  13451. }
  13452. },
  13453. // Don't automatically add "px" to these possibly-unitless properties
  13454. cssNumber: {
  13455. "animationIterationCount": true,
  13456. "columnCount": true,
  13457. "fillOpacity": true,
  13458. "flexGrow": true,
  13459. "flexShrink": true,
  13460. "fontWeight": true,
  13461. "gridArea": true,
  13462. "gridColumn": true,
  13463. "gridColumnEnd": true,
  13464. "gridColumnStart": true,
  13465. "gridRow": true,
  13466. "gridRowEnd": true,
  13467. "gridRowStart": true,
  13468. "lineHeight": true,
  13469. "opacity": true,
  13470. "order": true,
  13471. "orphans": true,
  13472. "widows": true,
  13473. "zIndex": true,
  13474. "zoom": true
  13475. },
  13476. // Add in properties whose names you wish to fix before
  13477. // setting or getting the value
  13478. cssProps: {},
  13479. // Get and set the style property on a DOM Node
  13480. style: function( elem, name, value, extra ) {
  13481. // Don't set styles on text and comment nodes
  13482. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  13483. return;
  13484. }
  13485. // Make sure that we're working with the right name
  13486. var ret, type, hooks,
  13487. origName = camelCase( name ),
  13488. isCustomProp = rcustomProp.test( name ),
  13489. style = elem.style;
  13490. // Make sure that we're working with the right name. We don't
  13491. // want to query the value if it is a CSS custom property
  13492. // since they are user-defined.
  13493. if ( !isCustomProp ) {
  13494. name = finalPropName( origName );
  13495. }
  13496. // Gets hook for the prefixed version, then unprefixed version
  13497. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13498. // Check if we're setting a value
  13499. if ( value !== undefined ) {
  13500. type = typeof value;
  13501. // Convert "+=" or "-=" to relative numbers (#7345)
  13502. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  13503. value = adjustCSS( elem, name, ret );
  13504. // Fixes bug #9237
  13505. type = "number";
  13506. }
  13507. // Make sure that null and NaN values aren't set (#7116)
  13508. if ( value == null || value !== value ) {
  13509. return;
  13510. }
  13511. // If a number was passed in, add the unit (except for certain CSS properties)
  13512. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  13513. // "px" to a few hardcoded values.
  13514. if ( type === "number" && !isCustomProp ) {
  13515. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  13516. }
  13517. // background-* props affect original clone's values
  13518. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  13519. style[ name ] = "inherit";
  13520. }
  13521. // If a hook was provided, use that value, otherwise just set the specified value
  13522. if ( !hooks || !( "set" in hooks ) ||
  13523. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  13524. if ( isCustomProp ) {
  13525. style.setProperty( name, value );
  13526. } else {
  13527. style[ name ] = value;
  13528. }
  13529. }
  13530. } else {
  13531. // If a hook was provided get the non-computed value from there
  13532. if ( hooks && "get" in hooks &&
  13533. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  13534. return ret;
  13535. }
  13536. // Otherwise just get the value from the style object
  13537. return style[ name ];
  13538. }
  13539. },
  13540. css: function( elem, name, extra, styles ) {
  13541. var val, num, hooks,
  13542. origName = camelCase( name ),
  13543. isCustomProp = rcustomProp.test( name );
  13544. // Make sure that we're working with the right name. We don't
  13545. // want to modify the value if it is a CSS custom property
  13546. // since they are user-defined.
  13547. if ( !isCustomProp ) {
  13548. name = finalPropName( origName );
  13549. }
  13550. // Try prefixed name followed by the unprefixed name
  13551. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13552. // If a hook was provided get the computed value from there
  13553. if ( hooks && "get" in hooks ) {
  13554. val = hooks.get( elem, true, extra );
  13555. }
  13556. // Otherwise, if a way to get the computed value exists, use that
  13557. if ( val === undefined ) {
  13558. val = curCSS( elem, name, styles );
  13559. }
  13560. // Convert "normal" to computed value
  13561. if ( val === "normal" && name in cssNormalTransform ) {
  13562. val = cssNormalTransform[ name ];
  13563. }
  13564. // Make numeric if forced or a qualifier was provided and val looks numeric
  13565. if ( extra === "" || extra ) {
  13566. num = parseFloat( val );
  13567. return extra === true || isFinite( num ) ? num || 0 : val;
  13568. }
  13569. return val;
  13570. }
  13571. } );
  13572. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  13573. jQuery.cssHooks[ dimension ] = {
  13574. get: function( elem, computed, extra ) {
  13575. if ( computed ) {
  13576. // Certain elements can have dimension info if we invisibly show them
  13577. // but it must have a current display style that would benefit
  13578. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  13579. // Support: Safari 8+
  13580. // Table columns in Safari have non-zero offsetWidth & zero
  13581. // getBoundingClientRect().width unless display is changed.
  13582. // Support: IE <=11 only
  13583. // Running getBoundingClientRect on a disconnected node
  13584. // in IE throws an error.
  13585. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  13586. swap( elem, cssShow, function() {
  13587. return getWidthOrHeight( elem, dimension, extra );
  13588. } ) :
  13589. getWidthOrHeight( elem, dimension, extra );
  13590. }
  13591. },
  13592. set: function( elem, value, extra ) {
  13593. var matches,
  13594. styles = getStyles( elem ),
  13595. // Only read styles.position if the test has a chance to fail
  13596. // to avoid forcing a reflow.
  13597. scrollboxSizeBuggy = !support.scrollboxSize() &&
  13598. styles.position === "absolute",
  13599. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  13600. boxSizingNeeded = scrollboxSizeBuggy || extra,
  13601. isBorderBox = boxSizingNeeded &&
  13602. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13603. subtract = extra ?
  13604. boxModelAdjustment(
  13605. elem,
  13606. dimension,
  13607. extra,
  13608. isBorderBox,
  13609. styles
  13610. ) :
  13611. 0;
  13612. // Account for unreliable border-box dimensions by comparing offset* to computed and
  13613. // faking a content-box to get border and padding (gh-3699)
  13614. if ( isBorderBox && scrollboxSizeBuggy ) {
  13615. subtract -= Math.ceil(
  13616. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13617. parseFloat( styles[ dimension ] ) -
  13618. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  13619. 0.5
  13620. );
  13621. }
  13622. // Convert to pixels if value adjustment is needed
  13623. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  13624. ( matches[ 3 ] || "px" ) !== "px" ) {
  13625. elem.style[ dimension ] = value;
  13626. value = jQuery.css( elem, dimension );
  13627. }
  13628. return setPositiveNumber( elem, value, subtract );
  13629. }
  13630. };
  13631. } );
  13632. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  13633. function( elem, computed ) {
  13634. if ( computed ) {
  13635. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  13636. elem.getBoundingClientRect().left -
  13637. swap( elem, { marginLeft: 0 }, function() {
  13638. return elem.getBoundingClientRect().left;
  13639. } )
  13640. ) + "px";
  13641. }
  13642. }
  13643. );
  13644. // These hooks are used by animate to expand properties
  13645. jQuery.each( {
  13646. margin: "",
  13647. padding: "",
  13648. border: "Width"
  13649. }, function( prefix, suffix ) {
  13650. jQuery.cssHooks[ prefix + suffix ] = {
  13651. expand: function( value ) {
  13652. var i = 0,
  13653. expanded = {},
  13654. // Assumes a single number if not a string
  13655. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  13656. for ( ; i < 4; i++ ) {
  13657. expanded[ prefix + cssExpand[ i ] + suffix ] =
  13658. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  13659. }
  13660. return expanded;
  13661. }
  13662. };
  13663. if ( prefix !== "margin" ) {
  13664. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  13665. }
  13666. } );
  13667. jQuery.fn.extend( {
  13668. css: function( name, value ) {
  13669. return access( this, function( elem, name, value ) {
  13670. var styles, len,
  13671. map = {},
  13672. i = 0;
  13673. if ( Array.isArray( name ) ) {
  13674. styles = getStyles( elem );
  13675. len = name.length;
  13676. for ( ; i < len; i++ ) {
  13677. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  13678. }
  13679. return map;
  13680. }
  13681. return value !== undefined ?
  13682. jQuery.style( elem, name, value ) :
  13683. jQuery.css( elem, name );
  13684. }, name, value, arguments.length > 1 );
  13685. }
  13686. } );
  13687. function Tween( elem, options, prop, end, easing ) {
  13688. return new Tween.prototype.init( elem, options, prop, end, easing );
  13689. }
  13690. jQuery.Tween = Tween;
  13691. Tween.prototype = {
  13692. constructor: Tween,
  13693. init: function( elem, options, prop, end, easing, unit ) {
  13694. this.elem = elem;
  13695. this.prop = prop;
  13696. this.easing = easing || jQuery.easing._default;
  13697. this.options = options;
  13698. this.start = this.now = this.cur();
  13699. this.end = end;
  13700. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  13701. },
  13702. cur: function() {
  13703. var hooks = Tween.propHooks[ this.prop ];
  13704. return hooks && hooks.get ?
  13705. hooks.get( this ) :
  13706. Tween.propHooks._default.get( this );
  13707. },
  13708. run: function( percent ) {
  13709. var eased,
  13710. hooks = Tween.propHooks[ this.prop ];
  13711. if ( this.options.duration ) {
  13712. this.pos = eased = jQuery.easing[ this.easing ](
  13713. percent, this.options.duration * percent, 0, 1, this.options.duration
  13714. );
  13715. } else {
  13716. this.pos = eased = percent;
  13717. }
  13718. this.now = ( this.end - this.start ) * eased + this.start;
  13719. if ( this.options.step ) {
  13720. this.options.step.call( this.elem, this.now, this );
  13721. }
  13722. if ( hooks && hooks.set ) {
  13723. hooks.set( this );
  13724. } else {
  13725. Tween.propHooks._default.set( this );
  13726. }
  13727. return this;
  13728. }
  13729. };
  13730. Tween.prototype.init.prototype = Tween.prototype;
  13731. Tween.propHooks = {
  13732. _default: {
  13733. get: function( tween ) {
  13734. var result;
  13735. // Use a property on the element directly when it is not a DOM element,
  13736. // or when there is no matching style property that exists.
  13737. if ( tween.elem.nodeType !== 1 ||
  13738. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  13739. return tween.elem[ tween.prop ];
  13740. }
  13741. // Passing an empty string as a 3rd parameter to .css will automatically
  13742. // attempt a parseFloat and fallback to a string if the parse fails.
  13743. // Simple values such as "10px" are parsed to Float;
  13744. // complex values such as "rotate(1rad)" are returned as-is.
  13745. result = jQuery.css( tween.elem, tween.prop, "" );
  13746. // Empty strings, null, undefined and "auto" are converted to 0.
  13747. return !result || result === "auto" ? 0 : result;
  13748. },
  13749. set: function( tween ) {
  13750. // Use step hook for back compat.
  13751. // Use cssHook if its there.
  13752. // Use .style if available and use plain properties where available.
  13753. if ( jQuery.fx.step[ tween.prop ] ) {
  13754. jQuery.fx.step[ tween.prop ]( tween );
  13755. } else if ( tween.elem.nodeType === 1 && (
  13756. jQuery.cssHooks[ tween.prop ] ||
  13757. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  13758. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  13759. } else {
  13760. tween.elem[ tween.prop ] = tween.now;
  13761. }
  13762. }
  13763. }
  13764. };
  13765. // Support: IE <=9 only
  13766. // Panic based approach to setting things on disconnected nodes
  13767. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  13768. set: function( tween ) {
  13769. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  13770. tween.elem[ tween.prop ] = tween.now;
  13771. }
  13772. }
  13773. };
  13774. jQuery.easing = {
  13775. linear: function( p ) {
  13776. return p;
  13777. },
  13778. swing: function( p ) {
  13779. return 0.5 - Math.cos( p * Math.PI ) / 2;
  13780. },
  13781. _default: "swing"
  13782. };
  13783. jQuery.fx = Tween.prototype.init;
  13784. // Back compat <1.8 extension point
  13785. jQuery.fx.step = {};
  13786. var
  13787. fxNow, inProgress,
  13788. rfxtypes = /^(?:toggle|show|hide)$/,
  13789. rrun = /queueHooks$/;
  13790. function schedule() {
  13791. if ( inProgress ) {
  13792. if ( document.hidden === false && window.requestAnimationFrame ) {
  13793. window.requestAnimationFrame( schedule );
  13794. } else {
  13795. window.setTimeout( schedule, jQuery.fx.interval );
  13796. }
  13797. jQuery.fx.tick();
  13798. }
  13799. }
  13800. // Animations created synchronously will run synchronously
  13801. function createFxNow() {
  13802. window.setTimeout( function() {
  13803. fxNow = undefined;
  13804. } );
  13805. return ( fxNow = Date.now() );
  13806. }
  13807. // Generate parameters to create a standard animation
  13808. function genFx( type, includeWidth ) {
  13809. var which,
  13810. i = 0,
  13811. attrs = { height: type };
  13812. // If we include width, step value is 1 to do all cssExpand values,
  13813. // otherwise step value is 2 to skip over Left and Right
  13814. includeWidth = includeWidth ? 1 : 0;
  13815. for ( ; i < 4; i += 2 - includeWidth ) {
  13816. which = cssExpand[ i ];
  13817. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  13818. }
  13819. if ( includeWidth ) {
  13820. attrs.opacity = attrs.width = type;
  13821. }
  13822. return attrs;
  13823. }
  13824. function createTween( value, prop, animation ) {
  13825. var tween,
  13826. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  13827. index = 0,
  13828. length = collection.length;
  13829. for ( ; index < length; index++ ) {
  13830. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  13831. // We're done with this property
  13832. return tween;
  13833. }
  13834. }
  13835. }
  13836. function defaultPrefilter( elem, props, opts ) {
  13837. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  13838. isBox = "width" in props || "height" in props,
  13839. anim = this,
  13840. orig = {},
  13841. style = elem.style,
  13842. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  13843. dataShow = dataPriv.get( elem, "fxshow" );
  13844. // Queue-skipping animations hijack the fx hooks
  13845. if ( !opts.queue ) {
  13846. hooks = jQuery._queueHooks( elem, "fx" );
  13847. if ( hooks.unqueued == null ) {
  13848. hooks.unqueued = 0;
  13849. oldfire = hooks.empty.fire;
  13850. hooks.empty.fire = function() {
  13851. if ( !hooks.unqueued ) {
  13852. oldfire();
  13853. }
  13854. };
  13855. }
  13856. hooks.unqueued++;
  13857. anim.always( function() {
  13858. // Ensure the complete handler is called before this completes
  13859. anim.always( function() {
  13860. hooks.unqueued--;
  13861. if ( !jQuery.queue( elem, "fx" ).length ) {
  13862. hooks.empty.fire();
  13863. }
  13864. } );
  13865. } );
  13866. }
  13867. // Detect show/hide animations
  13868. for ( prop in props ) {
  13869. value = props[ prop ];
  13870. if ( rfxtypes.test( value ) ) {
  13871. delete props[ prop ];
  13872. toggle = toggle || value === "toggle";
  13873. if ( value === ( hidden ? "hide" : "show" ) ) {
  13874. // Pretend to be hidden if this is a "show" and
  13875. // there is still data from a stopped show/hide
  13876. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  13877. hidden = true;
  13878. // Ignore all other no-op show/hide data
  13879. } else {
  13880. continue;
  13881. }
  13882. }
  13883. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  13884. }
  13885. }
  13886. // Bail out if this is a no-op like .hide().hide()
  13887. propTween = !jQuery.isEmptyObject( props );
  13888. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  13889. return;
  13890. }
  13891. // Restrict "overflow" and "display" styles during box animations
  13892. if ( isBox && elem.nodeType === 1 ) {
  13893. // Support: IE <=9 - 11, Edge 12 - 15
  13894. // Record all 3 overflow attributes because IE does not infer the shorthand
  13895. // from identically-valued overflowX and overflowY and Edge just mirrors
  13896. // the overflowX value there.
  13897. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  13898. // Identify a display type, preferring old show/hide data over the CSS cascade
  13899. restoreDisplay = dataShow && dataShow.display;
  13900. if ( restoreDisplay == null ) {
  13901. restoreDisplay = dataPriv.get( elem, "display" );
  13902. }
  13903. display = jQuery.css( elem, "display" );
  13904. if ( display === "none" ) {
  13905. if ( restoreDisplay ) {
  13906. display = restoreDisplay;
  13907. } else {
  13908. // Get nonempty value(s) by temporarily forcing visibility
  13909. showHide( [ elem ], true );
  13910. restoreDisplay = elem.style.display || restoreDisplay;
  13911. display = jQuery.css( elem, "display" );
  13912. showHide( [ elem ] );
  13913. }
  13914. }
  13915. // Animate inline elements as inline-block
  13916. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  13917. if ( jQuery.css( elem, "float" ) === "none" ) {
  13918. // Restore the original display value at the end of pure show/hide animations
  13919. if ( !propTween ) {
  13920. anim.done( function() {
  13921. style.display = restoreDisplay;
  13922. } );
  13923. if ( restoreDisplay == null ) {
  13924. display = style.display;
  13925. restoreDisplay = display === "none" ? "" : display;
  13926. }
  13927. }
  13928. style.display = "inline-block";
  13929. }
  13930. }
  13931. }
  13932. if ( opts.overflow ) {
  13933. style.overflow = "hidden";
  13934. anim.always( function() {
  13935. style.overflow = opts.overflow[ 0 ];
  13936. style.overflowX = opts.overflow[ 1 ];
  13937. style.overflowY = opts.overflow[ 2 ];
  13938. } );
  13939. }
  13940. // Implement show/hide animations
  13941. propTween = false;
  13942. for ( prop in orig ) {
  13943. // General show/hide setup for this element animation
  13944. if ( !propTween ) {
  13945. if ( dataShow ) {
  13946. if ( "hidden" in dataShow ) {
  13947. hidden = dataShow.hidden;
  13948. }
  13949. } else {
  13950. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  13951. }
  13952. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  13953. if ( toggle ) {
  13954. dataShow.hidden = !hidden;
  13955. }
  13956. // Show elements before animating them
  13957. if ( hidden ) {
  13958. showHide( [ elem ], true );
  13959. }
  13960. /* eslint-disable no-loop-func */
  13961. anim.done( function() {
  13962. /* eslint-enable no-loop-func */
  13963. // The final step of a "hide" animation is actually hiding the element
  13964. if ( !hidden ) {
  13965. showHide( [ elem ] );
  13966. }
  13967. dataPriv.remove( elem, "fxshow" );
  13968. for ( prop in orig ) {
  13969. jQuery.style( elem, prop, orig[ prop ] );
  13970. }
  13971. } );
  13972. }
  13973. // Per-property setup
  13974. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  13975. if ( !( prop in dataShow ) ) {
  13976. dataShow[ prop ] = propTween.start;
  13977. if ( hidden ) {
  13978. propTween.end = propTween.start;
  13979. propTween.start = 0;
  13980. }
  13981. }
  13982. }
  13983. }
  13984. function propFilter( props, specialEasing ) {
  13985. var index, name, easing, value, hooks;
  13986. // camelCase, specialEasing and expand cssHook pass
  13987. for ( index in props ) {
  13988. name = camelCase( index );
  13989. easing = specialEasing[ name ];
  13990. value = props[ index ];
  13991. if ( Array.isArray( value ) ) {
  13992. easing = value[ 1 ];
  13993. value = props[ index ] = value[ 0 ];
  13994. }
  13995. if ( index !== name ) {
  13996. props[ name ] = value;
  13997. delete props[ index ];
  13998. }
  13999. hooks = jQuery.cssHooks[ name ];
  14000. if ( hooks && "expand" in hooks ) {
  14001. value = hooks.expand( value );
  14002. delete props[ name ];
  14003. // Not quite $.extend, this won't overwrite existing keys.
  14004. // Reusing 'index' because we have the correct "name"
  14005. for ( index in value ) {
  14006. if ( !( index in props ) ) {
  14007. props[ index ] = value[ index ];
  14008. specialEasing[ index ] = easing;
  14009. }
  14010. }
  14011. } else {
  14012. specialEasing[ name ] = easing;
  14013. }
  14014. }
  14015. }
  14016. function Animation( elem, properties, options ) {
  14017. var result,
  14018. stopped,
  14019. index = 0,
  14020. length = Animation.prefilters.length,
  14021. deferred = jQuery.Deferred().always( function() {
  14022. // Don't match elem in the :animated selector
  14023. delete tick.elem;
  14024. } ),
  14025. tick = function() {
  14026. if ( stopped ) {
  14027. return false;
  14028. }
  14029. var currentTime = fxNow || createFxNow(),
  14030. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  14031. // Support: Android 2.3 only
  14032. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  14033. temp = remaining / animation.duration || 0,
  14034. percent = 1 - temp,
  14035. index = 0,
  14036. length = animation.tweens.length;
  14037. for ( ; index < length; index++ ) {
  14038. animation.tweens[ index ].run( percent );
  14039. }
  14040. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  14041. // If there's more to do, yield
  14042. if ( percent < 1 && length ) {
  14043. return remaining;
  14044. }
  14045. // If this was an empty animation, synthesize a final progress notification
  14046. if ( !length ) {
  14047. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14048. }
  14049. // Resolve the animation and report its conclusion
  14050. deferred.resolveWith( elem, [ animation ] );
  14051. return false;
  14052. },
  14053. animation = deferred.promise( {
  14054. elem: elem,
  14055. props: jQuery.extend( {}, properties ),
  14056. opts: jQuery.extend( true, {
  14057. specialEasing: {},
  14058. easing: jQuery.easing._default
  14059. }, options ),
  14060. originalProperties: properties,
  14061. originalOptions: options,
  14062. startTime: fxNow || createFxNow(),
  14063. duration: options.duration,
  14064. tweens: [],
  14065. createTween: function( prop, end ) {
  14066. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  14067. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  14068. animation.tweens.push( tween );
  14069. return tween;
  14070. },
  14071. stop: function( gotoEnd ) {
  14072. var index = 0,
  14073. // If we are going to the end, we want to run all the tweens
  14074. // otherwise we skip this part
  14075. length = gotoEnd ? animation.tweens.length : 0;
  14076. if ( stopped ) {
  14077. return this;
  14078. }
  14079. stopped = true;
  14080. for ( ; index < length; index++ ) {
  14081. animation.tweens[ index ].run( 1 );
  14082. }
  14083. // Resolve when we played the last frame; otherwise, reject
  14084. if ( gotoEnd ) {
  14085. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14086. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  14087. } else {
  14088. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  14089. }
  14090. return this;
  14091. }
  14092. } ),
  14093. props = animation.props;
  14094. propFilter( props, animation.opts.specialEasing );
  14095. for ( ; index < length; index++ ) {
  14096. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  14097. if ( result ) {
  14098. if ( isFunction( result.stop ) ) {
  14099. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  14100. result.stop.bind( result );
  14101. }
  14102. return result;
  14103. }
  14104. }
  14105. jQuery.map( props, createTween, animation );
  14106. if ( isFunction( animation.opts.start ) ) {
  14107. animation.opts.start.call( elem, animation );
  14108. }
  14109. // Attach callbacks from options
  14110. animation
  14111. .progress( animation.opts.progress )
  14112. .done( animation.opts.done, animation.opts.complete )
  14113. .fail( animation.opts.fail )
  14114. .always( animation.opts.always );
  14115. jQuery.fx.timer(
  14116. jQuery.extend( tick, {
  14117. elem: elem,
  14118. anim: animation,
  14119. queue: animation.opts.queue
  14120. } )
  14121. );
  14122. return animation;
  14123. }
  14124. jQuery.Animation = jQuery.extend( Animation, {
  14125. tweeners: {
  14126. "*": [ function( prop, value ) {
  14127. var tween = this.createTween( prop, value );
  14128. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  14129. return tween;
  14130. } ]
  14131. },
  14132. tweener: function( props, callback ) {
  14133. if ( isFunction( props ) ) {
  14134. callback = props;
  14135. props = [ "*" ];
  14136. } else {
  14137. props = props.match( rnothtmlwhite );
  14138. }
  14139. var prop,
  14140. index = 0,
  14141. length = props.length;
  14142. for ( ; index < length; index++ ) {
  14143. prop = props[ index ];
  14144. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  14145. Animation.tweeners[ prop ].unshift( callback );
  14146. }
  14147. },
  14148. prefilters: [ defaultPrefilter ],
  14149. prefilter: function( callback, prepend ) {
  14150. if ( prepend ) {
  14151. Animation.prefilters.unshift( callback );
  14152. } else {
  14153. Animation.prefilters.push( callback );
  14154. }
  14155. }
  14156. } );
  14157. jQuery.speed = function( speed, easing, fn ) {
  14158. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  14159. complete: fn || !fn && easing ||
  14160. isFunction( speed ) && speed,
  14161. duration: speed,
  14162. easing: fn && easing || easing && !isFunction( easing ) && easing
  14163. };
  14164. // Go to the end state if fx are off
  14165. if ( jQuery.fx.off ) {
  14166. opt.duration = 0;
  14167. } else {
  14168. if ( typeof opt.duration !== "number" ) {
  14169. if ( opt.duration in jQuery.fx.speeds ) {
  14170. opt.duration = jQuery.fx.speeds[ opt.duration ];
  14171. } else {
  14172. opt.duration = jQuery.fx.speeds._default;
  14173. }
  14174. }
  14175. }
  14176. // Normalize opt.queue - true/undefined/null -> "fx"
  14177. if ( opt.queue == null || opt.queue === true ) {
  14178. opt.queue = "fx";
  14179. }
  14180. // Queueing
  14181. opt.old = opt.complete;
  14182. opt.complete = function() {
  14183. if ( isFunction( opt.old ) ) {
  14184. opt.old.call( this );
  14185. }
  14186. if ( opt.queue ) {
  14187. jQuery.dequeue( this, opt.queue );
  14188. }
  14189. };
  14190. return opt;
  14191. };
  14192. jQuery.fn.extend( {
  14193. fadeTo: function( speed, to, easing, callback ) {
  14194. // Show any hidden elements after setting opacity to 0
  14195. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  14196. // Animate to the value specified
  14197. .end().animate( { opacity: to }, speed, easing, callback );
  14198. },
  14199. animate: function( prop, speed, easing, callback ) {
  14200. var empty = jQuery.isEmptyObject( prop ),
  14201. optall = jQuery.speed( speed, easing, callback ),
  14202. doAnimation = function() {
  14203. // Operate on a copy of prop so per-property easing won't be lost
  14204. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  14205. // Empty animations, or finishing resolves immediately
  14206. if ( empty || dataPriv.get( this, "finish" ) ) {
  14207. anim.stop( true );
  14208. }
  14209. };
  14210. doAnimation.finish = doAnimation;
  14211. return empty || optall.queue === false ?
  14212. this.each( doAnimation ) :
  14213. this.queue( optall.queue, doAnimation );
  14214. },
  14215. stop: function( type, clearQueue, gotoEnd ) {
  14216. var stopQueue = function( hooks ) {
  14217. var stop = hooks.stop;
  14218. delete hooks.stop;
  14219. stop( gotoEnd );
  14220. };
  14221. if ( typeof type !== "string" ) {
  14222. gotoEnd = clearQueue;
  14223. clearQueue = type;
  14224. type = undefined;
  14225. }
  14226. if ( clearQueue && type !== false ) {
  14227. this.queue( type || "fx", [] );
  14228. }
  14229. return this.each( function() {
  14230. var dequeue = true,
  14231. index = type != null && type + "queueHooks",
  14232. timers = jQuery.timers,
  14233. data = dataPriv.get( this );
  14234. if ( index ) {
  14235. if ( data[ index ] && data[ index ].stop ) {
  14236. stopQueue( data[ index ] );
  14237. }
  14238. } else {
  14239. for ( index in data ) {
  14240. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  14241. stopQueue( data[ index ] );
  14242. }
  14243. }
  14244. }
  14245. for ( index = timers.length; index--; ) {
  14246. if ( timers[ index ].elem === this &&
  14247. ( type == null || timers[ index ].queue === type ) ) {
  14248. timers[ index ].anim.stop( gotoEnd );
  14249. dequeue = false;
  14250. timers.splice( index, 1 );
  14251. }
  14252. }
  14253. // Start the next in the queue if the last step wasn't forced.
  14254. // Timers currently will call their complete callbacks, which
  14255. // will dequeue but only if they were gotoEnd.
  14256. if ( dequeue || !gotoEnd ) {
  14257. jQuery.dequeue( this, type );
  14258. }
  14259. } );
  14260. },
  14261. finish: function( type ) {
  14262. if ( type !== false ) {
  14263. type = type || "fx";
  14264. }
  14265. return this.each( function() {
  14266. var index,
  14267. data = dataPriv.get( this ),
  14268. queue = data[ type + "queue" ],
  14269. hooks = data[ type + "queueHooks" ],
  14270. timers = jQuery.timers,
  14271. length = queue ? queue.length : 0;
  14272. // Enable finishing flag on private data
  14273. data.finish = true;
  14274. // Empty the queue first
  14275. jQuery.queue( this, type, [] );
  14276. if ( hooks && hooks.stop ) {
  14277. hooks.stop.call( this, true );
  14278. }
  14279. // Look for any active animations, and finish them
  14280. for ( index = timers.length; index--; ) {
  14281. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  14282. timers[ index ].anim.stop( true );
  14283. timers.splice( index, 1 );
  14284. }
  14285. }
  14286. // Look for any animations in the old queue and finish them
  14287. for ( index = 0; index < length; index++ ) {
  14288. if ( queue[ index ] && queue[ index ].finish ) {
  14289. queue[ index ].finish.call( this );
  14290. }
  14291. }
  14292. // Turn off finishing flag
  14293. delete data.finish;
  14294. } );
  14295. }
  14296. } );
  14297. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  14298. var cssFn = jQuery.fn[ name ];
  14299. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14300. return speed == null || typeof speed === "boolean" ?
  14301. cssFn.apply( this, arguments ) :
  14302. this.animate( genFx( name, true ), speed, easing, callback );
  14303. };
  14304. } );
  14305. // Generate shortcuts for custom animations
  14306. jQuery.each( {
  14307. slideDown: genFx( "show" ),
  14308. slideUp: genFx( "hide" ),
  14309. slideToggle: genFx( "toggle" ),
  14310. fadeIn: { opacity: "show" },
  14311. fadeOut: { opacity: "hide" },
  14312. fadeToggle: { opacity: "toggle" }
  14313. }, function( name, props ) {
  14314. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14315. return this.animate( props, speed, easing, callback );
  14316. };
  14317. } );
  14318. jQuery.timers = [];
  14319. jQuery.fx.tick = function() {
  14320. var timer,
  14321. i = 0,
  14322. timers = jQuery.timers;
  14323. fxNow = Date.now();
  14324. for ( ; i < timers.length; i++ ) {
  14325. timer = timers[ i ];
  14326. // Run the timer and safely remove it when done (allowing for external removal)
  14327. if ( !timer() && timers[ i ] === timer ) {
  14328. timers.splice( i--, 1 );
  14329. }
  14330. }
  14331. if ( !timers.length ) {
  14332. jQuery.fx.stop();
  14333. }
  14334. fxNow = undefined;
  14335. };
  14336. jQuery.fx.timer = function( timer ) {
  14337. jQuery.timers.push( timer );
  14338. jQuery.fx.start();
  14339. };
  14340. jQuery.fx.interval = 13;
  14341. jQuery.fx.start = function() {
  14342. if ( inProgress ) {
  14343. return;
  14344. }
  14345. inProgress = true;
  14346. schedule();
  14347. };
  14348. jQuery.fx.stop = function() {
  14349. inProgress = null;
  14350. };
  14351. jQuery.fx.speeds = {
  14352. slow: 600,
  14353. fast: 200,
  14354. // Default speed
  14355. _default: 400
  14356. };
  14357. // Based off of the plugin by Clint Helfers, with permission.
  14358. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  14359. jQuery.fn.delay = function( time, type ) {
  14360. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  14361. type = type || "fx";
  14362. return this.queue( type, function( next, hooks ) {
  14363. var timeout = window.setTimeout( next, time );
  14364. hooks.stop = function() {
  14365. window.clearTimeout( timeout );
  14366. };
  14367. } );
  14368. };
  14369. ( function() {
  14370. var input = document.createElement( "input" ),
  14371. select = document.createElement( "select" ),
  14372. opt = select.appendChild( document.createElement( "option" ) );
  14373. input.type = "checkbox";
  14374. // Support: Android <=4.3 only
  14375. // Default value for a checkbox should be "on"
  14376. support.checkOn = input.value !== "";
  14377. // Support: IE <=11 only
  14378. // Must access selectedIndex to make default options select
  14379. support.optSelected = opt.selected;
  14380. // Support: IE <=11 only
  14381. // An input loses its value after becoming a radio
  14382. input = document.createElement( "input" );
  14383. input.value = "t";
  14384. input.type = "radio";
  14385. support.radioValue = input.value === "t";
  14386. } )();
  14387. var boolHook,
  14388. attrHandle = jQuery.expr.attrHandle;
  14389. jQuery.fn.extend( {
  14390. attr: function( name, value ) {
  14391. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  14392. },
  14393. removeAttr: function( name ) {
  14394. return this.each( function() {
  14395. jQuery.removeAttr( this, name );
  14396. } );
  14397. }
  14398. } );
  14399. jQuery.extend( {
  14400. attr: function( elem, name, value ) {
  14401. var ret, hooks,
  14402. nType = elem.nodeType;
  14403. // Don't get/set attributes on text, comment and attribute nodes
  14404. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14405. return;
  14406. }
  14407. // Fallback to prop when attributes are not supported
  14408. if ( typeof elem.getAttribute === "undefined" ) {
  14409. return jQuery.prop( elem, name, value );
  14410. }
  14411. // Attribute hooks are determined by the lowercase version
  14412. // Grab necessary hook if one is defined
  14413. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14414. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  14415. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  14416. }
  14417. if ( value !== undefined ) {
  14418. if ( value === null ) {
  14419. jQuery.removeAttr( elem, name );
  14420. return;
  14421. }
  14422. if ( hooks && "set" in hooks &&
  14423. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14424. return ret;
  14425. }
  14426. elem.setAttribute( name, value + "" );
  14427. return value;
  14428. }
  14429. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14430. return ret;
  14431. }
  14432. ret = jQuery.find.attr( elem, name );
  14433. // Non-existent attributes return null, we normalize to undefined
  14434. return ret == null ? undefined : ret;
  14435. },
  14436. attrHooks: {
  14437. type: {
  14438. set: function( elem, value ) {
  14439. if ( !support.radioValue && value === "radio" &&
  14440. nodeName( elem, "input" ) ) {
  14441. var val = elem.value;
  14442. elem.setAttribute( "type", value );
  14443. if ( val ) {
  14444. elem.value = val;
  14445. }
  14446. return value;
  14447. }
  14448. }
  14449. }
  14450. },
  14451. removeAttr: function( elem, value ) {
  14452. var name,
  14453. i = 0,
  14454. // Attribute names can contain non-HTML whitespace characters
  14455. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  14456. attrNames = value && value.match( rnothtmlwhite );
  14457. if ( attrNames && elem.nodeType === 1 ) {
  14458. while ( ( name = attrNames[ i++ ] ) ) {
  14459. elem.removeAttribute( name );
  14460. }
  14461. }
  14462. }
  14463. } );
  14464. // Hooks for boolean attributes
  14465. boolHook = {
  14466. set: function( elem, value, name ) {
  14467. if ( value === false ) {
  14468. // Remove boolean attributes when set to false
  14469. jQuery.removeAttr( elem, name );
  14470. } else {
  14471. elem.setAttribute( name, name );
  14472. }
  14473. return name;
  14474. }
  14475. };
  14476. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  14477. var getter = attrHandle[ name ] || jQuery.find.attr;
  14478. attrHandle[ name ] = function( elem, name, isXML ) {
  14479. var ret, handle,
  14480. lowercaseName = name.toLowerCase();
  14481. if ( !isXML ) {
  14482. // Avoid an infinite loop by temporarily removing this function from the getter
  14483. handle = attrHandle[ lowercaseName ];
  14484. attrHandle[ lowercaseName ] = ret;
  14485. ret = getter( elem, name, isXML ) != null ?
  14486. lowercaseName :
  14487. null;
  14488. attrHandle[ lowercaseName ] = handle;
  14489. }
  14490. return ret;
  14491. };
  14492. } );
  14493. var rfocusable = /^(?:input|select|textarea|button)$/i,
  14494. rclickable = /^(?:a|area)$/i;
  14495. jQuery.fn.extend( {
  14496. prop: function( name, value ) {
  14497. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  14498. },
  14499. removeProp: function( name ) {
  14500. return this.each( function() {
  14501. delete this[ jQuery.propFix[ name ] || name ];
  14502. } );
  14503. }
  14504. } );
  14505. jQuery.extend( {
  14506. prop: function( elem, name, value ) {
  14507. var ret, hooks,
  14508. nType = elem.nodeType;
  14509. // Don't get/set properties on text, comment and attribute nodes
  14510. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14511. return;
  14512. }
  14513. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14514. // Fix name and attach hooks
  14515. name = jQuery.propFix[ name ] || name;
  14516. hooks = jQuery.propHooks[ name ];
  14517. }
  14518. if ( value !== undefined ) {
  14519. if ( hooks && "set" in hooks &&
  14520. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14521. return ret;
  14522. }
  14523. return ( elem[ name ] = value );
  14524. }
  14525. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14526. return ret;
  14527. }
  14528. return elem[ name ];
  14529. },
  14530. propHooks: {
  14531. tabIndex: {
  14532. get: function( elem ) {
  14533. // Support: IE <=9 - 11 only
  14534. // elem.tabIndex doesn't always return the
  14535. // correct value when it hasn't been explicitly set
  14536. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  14537. // Use proper attribute retrieval(#12072)
  14538. var tabindex = jQuery.find.attr( elem, "tabindex" );
  14539. if ( tabindex ) {
  14540. return parseInt( tabindex, 10 );
  14541. }
  14542. if (
  14543. rfocusable.test( elem.nodeName ) ||
  14544. rclickable.test( elem.nodeName ) &&
  14545. elem.href
  14546. ) {
  14547. return 0;
  14548. }
  14549. return -1;
  14550. }
  14551. }
  14552. },
  14553. propFix: {
  14554. "for": "htmlFor",
  14555. "class": "className"
  14556. }
  14557. } );
  14558. // Support: IE <=11 only
  14559. // Accessing the selectedIndex property
  14560. // forces the browser to respect setting selected
  14561. // on the option
  14562. // The getter ensures a default option is selected
  14563. // when in an optgroup
  14564. // eslint rule "no-unused-expressions" is disabled for this code
  14565. // since it considers such accessions noop
  14566. if ( !support.optSelected ) {
  14567. jQuery.propHooks.selected = {
  14568. get: function( elem ) {
  14569. /* eslint no-unused-expressions: "off" */
  14570. var parent = elem.parentNode;
  14571. if ( parent && parent.parentNode ) {
  14572. parent.parentNode.selectedIndex;
  14573. }
  14574. return null;
  14575. },
  14576. set: function( elem ) {
  14577. /* eslint no-unused-expressions: "off" */
  14578. var parent = elem.parentNode;
  14579. if ( parent ) {
  14580. parent.selectedIndex;
  14581. if ( parent.parentNode ) {
  14582. parent.parentNode.selectedIndex;
  14583. }
  14584. }
  14585. }
  14586. };
  14587. }
  14588. jQuery.each( [
  14589. "tabIndex",
  14590. "readOnly",
  14591. "maxLength",
  14592. "cellSpacing",
  14593. "cellPadding",
  14594. "rowSpan",
  14595. "colSpan",
  14596. "useMap",
  14597. "frameBorder",
  14598. "contentEditable"
  14599. ], function() {
  14600. jQuery.propFix[ this.toLowerCase() ] = this;
  14601. } );
  14602. // Strip and collapse whitespace according to HTML spec
  14603. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  14604. function stripAndCollapse( value ) {
  14605. var tokens = value.match( rnothtmlwhite ) || [];
  14606. return tokens.join( " " );
  14607. }
  14608. function getClass( elem ) {
  14609. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  14610. }
  14611. function classesToArray( value ) {
  14612. if ( Array.isArray( value ) ) {
  14613. return value;
  14614. }
  14615. if ( typeof value === "string" ) {
  14616. return value.match( rnothtmlwhite ) || [];
  14617. }
  14618. return [];
  14619. }
  14620. jQuery.fn.extend( {
  14621. addClass: function( value ) {
  14622. var classes, elem, cur, curValue, clazz, j, finalValue,
  14623. i = 0;
  14624. if ( isFunction( value ) ) {
  14625. return this.each( function( j ) {
  14626. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  14627. } );
  14628. }
  14629. classes = classesToArray( value );
  14630. if ( classes.length ) {
  14631. while ( ( elem = this[ i++ ] ) ) {
  14632. curValue = getClass( elem );
  14633. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14634. if ( cur ) {
  14635. j = 0;
  14636. while ( ( clazz = classes[ j++ ] ) ) {
  14637. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  14638. cur += clazz + " ";
  14639. }
  14640. }
  14641. // Only assign if different to avoid unneeded rendering.
  14642. finalValue = stripAndCollapse( cur );
  14643. if ( curValue !== finalValue ) {
  14644. elem.setAttribute( "class", finalValue );
  14645. }
  14646. }
  14647. }
  14648. }
  14649. return this;
  14650. },
  14651. removeClass: function( value ) {
  14652. var classes, elem, cur, curValue, clazz, j, finalValue,
  14653. i = 0;
  14654. if ( isFunction( value ) ) {
  14655. return this.each( function( j ) {
  14656. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  14657. } );
  14658. }
  14659. if ( !arguments.length ) {
  14660. return this.attr( "class", "" );
  14661. }
  14662. classes = classesToArray( value );
  14663. if ( classes.length ) {
  14664. while ( ( elem = this[ i++ ] ) ) {
  14665. curValue = getClass( elem );
  14666. // This expression is here for better compressibility (see addClass)
  14667. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14668. if ( cur ) {
  14669. j = 0;
  14670. while ( ( clazz = classes[ j++ ] ) ) {
  14671. // Remove *all* instances
  14672. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  14673. cur = cur.replace( " " + clazz + " ", " " );
  14674. }
  14675. }
  14676. // Only assign if different to avoid unneeded rendering.
  14677. finalValue = stripAndCollapse( cur );
  14678. if ( curValue !== finalValue ) {
  14679. elem.setAttribute( "class", finalValue );
  14680. }
  14681. }
  14682. }
  14683. }
  14684. return this;
  14685. },
  14686. toggleClass: function( value, stateVal ) {
  14687. var type = typeof value,
  14688. isValidValue = type === "string" || Array.isArray( value );
  14689. if ( typeof stateVal === "boolean" && isValidValue ) {
  14690. return stateVal ? this.addClass( value ) : this.removeClass( value );
  14691. }
  14692. if ( isFunction( value ) ) {
  14693. return this.each( function( i ) {
  14694. jQuery( this ).toggleClass(
  14695. value.call( this, i, getClass( this ), stateVal ),
  14696. stateVal
  14697. );
  14698. } );
  14699. }
  14700. return this.each( function() {
  14701. var className, i, self, classNames;
  14702. if ( isValidValue ) {
  14703. // Toggle individual class names
  14704. i = 0;
  14705. self = jQuery( this );
  14706. classNames = classesToArray( value );
  14707. while ( ( className = classNames[ i++ ] ) ) {
  14708. // Check each className given, space separated list
  14709. if ( self.hasClass( className ) ) {
  14710. self.removeClass( className );
  14711. } else {
  14712. self.addClass( className );
  14713. }
  14714. }
  14715. // Toggle whole class name
  14716. } else if ( value === undefined || type === "boolean" ) {
  14717. className = getClass( this );
  14718. if ( className ) {
  14719. // Store className if set
  14720. dataPriv.set( this, "__className__", className );
  14721. }
  14722. // If the element has a class name or if we're passed `false`,
  14723. // then remove the whole classname (if there was one, the above saved it).
  14724. // Otherwise bring back whatever was previously saved (if anything),
  14725. // falling back to the empty string if nothing was stored.
  14726. if ( this.setAttribute ) {
  14727. this.setAttribute( "class",
  14728. className || value === false ?
  14729. "" :
  14730. dataPriv.get( this, "__className__" ) || ""
  14731. );
  14732. }
  14733. }
  14734. } );
  14735. },
  14736. hasClass: function( selector ) {
  14737. var className, elem,
  14738. i = 0;
  14739. className = " " + selector + " ";
  14740. while ( ( elem = this[ i++ ] ) ) {
  14741. if ( elem.nodeType === 1 &&
  14742. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  14743. return true;
  14744. }
  14745. }
  14746. return false;
  14747. }
  14748. } );
  14749. var rreturn = /\r/g;
  14750. jQuery.fn.extend( {
  14751. val: function( value ) {
  14752. var hooks, ret, valueIsFunction,
  14753. elem = this[ 0 ];
  14754. if ( !arguments.length ) {
  14755. if ( elem ) {
  14756. hooks = jQuery.valHooks[ elem.type ] ||
  14757. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  14758. if ( hooks &&
  14759. "get" in hooks &&
  14760. ( ret = hooks.get( elem, "value" ) ) !== undefined
  14761. ) {
  14762. return ret;
  14763. }
  14764. ret = elem.value;
  14765. // Handle most common string cases
  14766. if ( typeof ret === "string" ) {
  14767. return ret.replace( rreturn, "" );
  14768. }
  14769. // Handle cases where value is null/undef or number
  14770. return ret == null ? "" : ret;
  14771. }
  14772. return;
  14773. }
  14774. valueIsFunction = isFunction( value );
  14775. return this.each( function( i ) {
  14776. var val;
  14777. if ( this.nodeType !== 1 ) {
  14778. return;
  14779. }
  14780. if ( valueIsFunction ) {
  14781. val = value.call( this, i, jQuery( this ).val() );
  14782. } else {
  14783. val = value;
  14784. }
  14785. // Treat null/undefined as ""; convert numbers to string
  14786. if ( val == null ) {
  14787. val = "";
  14788. } else if ( typeof val === "number" ) {
  14789. val += "";
  14790. } else if ( Array.isArray( val ) ) {
  14791. val = jQuery.map( val, function( value ) {
  14792. return value == null ? "" : value + "";
  14793. } );
  14794. }
  14795. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  14796. // If set returns undefined, fall back to normal setting
  14797. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  14798. this.value = val;
  14799. }
  14800. } );
  14801. }
  14802. } );
  14803. jQuery.extend( {
  14804. valHooks: {
  14805. option: {
  14806. get: function( elem ) {
  14807. var val = jQuery.find.attr( elem, "value" );
  14808. return val != null ?
  14809. val :
  14810. // Support: IE <=10 - 11 only
  14811. // option.text throws exceptions (#14686, #14858)
  14812. // Strip and collapse whitespace
  14813. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  14814. stripAndCollapse( jQuery.text( elem ) );
  14815. }
  14816. },
  14817. select: {
  14818. get: function( elem ) {
  14819. var value, option, i,
  14820. options = elem.options,
  14821. index = elem.selectedIndex,
  14822. one = elem.type === "select-one",
  14823. values = one ? null : [],
  14824. max = one ? index + 1 : options.length;
  14825. if ( index < 0 ) {
  14826. i = max;
  14827. } else {
  14828. i = one ? index : 0;
  14829. }
  14830. // Loop through all the selected options
  14831. for ( ; i < max; i++ ) {
  14832. option = options[ i ];
  14833. // Support: IE <=9 only
  14834. // IE8-9 doesn't update selected after form reset (#2551)
  14835. if ( ( option.selected || i === index ) &&
  14836. // Don't return options that are disabled or in a disabled optgroup
  14837. !option.disabled &&
  14838. ( !option.parentNode.disabled ||
  14839. !nodeName( option.parentNode, "optgroup" ) ) ) {
  14840. // Get the specific value for the option
  14841. value = jQuery( option ).val();
  14842. // We don't need an array for one selects
  14843. if ( one ) {
  14844. return value;
  14845. }
  14846. // Multi-Selects return an array
  14847. values.push( value );
  14848. }
  14849. }
  14850. return values;
  14851. },
  14852. set: function( elem, value ) {
  14853. var optionSet, option,
  14854. options = elem.options,
  14855. values = jQuery.makeArray( value ),
  14856. i = options.length;
  14857. while ( i-- ) {
  14858. option = options[ i ];
  14859. /* eslint-disable no-cond-assign */
  14860. if ( option.selected =
  14861. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  14862. ) {
  14863. optionSet = true;
  14864. }
  14865. /* eslint-enable no-cond-assign */
  14866. }
  14867. // Force browsers to behave consistently when non-matching value is set
  14868. if ( !optionSet ) {
  14869. elem.selectedIndex = -1;
  14870. }
  14871. return values;
  14872. }
  14873. }
  14874. }
  14875. } );
  14876. // Radios and checkboxes getter/setter
  14877. jQuery.each( [ "radio", "checkbox" ], function() {
  14878. jQuery.valHooks[ this ] = {
  14879. set: function( elem, value ) {
  14880. if ( Array.isArray( value ) ) {
  14881. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  14882. }
  14883. }
  14884. };
  14885. if ( !support.checkOn ) {
  14886. jQuery.valHooks[ this ].get = function( elem ) {
  14887. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  14888. };
  14889. }
  14890. } );
  14891. // Return jQuery for attributes-only inclusion
  14892. support.focusin = "onfocusin" in window;
  14893. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  14894. stopPropagationCallback = function( e ) {
  14895. e.stopPropagation();
  14896. };
  14897. jQuery.extend( jQuery.event, {
  14898. trigger: function( event, data, elem, onlyHandlers ) {
  14899. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  14900. eventPath = [ elem || document ],
  14901. type = hasOwn.call( event, "type" ) ? event.type : event,
  14902. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  14903. cur = lastElement = tmp = elem = elem || document;
  14904. // Don't do events on text and comment nodes
  14905. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  14906. return;
  14907. }
  14908. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  14909. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  14910. return;
  14911. }
  14912. if ( type.indexOf( "." ) > -1 ) {
  14913. // Namespaced trigger; create a regexp to match event type in handle()
  14914. namespaces = type.split( "." );
  14915. type = namespaces.shift();
  14916. namespaces.sort();
  14917. }
  14918. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  14919. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  14920. event = event[ jQuery.expando ] ?
  14921. event :
  14922. new jQuery.Event( type, typeof event === "object" && event );
  14923. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  14924. event.isTrigger = onlyHandlers ? 2 : 3;
  14925. event.namespace = namespaces.join( "." );
  14926. event.rnamespace = event.namespace ?
  14927. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  14928. null;
  14929. // Clean up the event in case it is being reused
  14930. event.result = undefined;
  14931. if ( !event.target ) {
  14932. event.target = elem;
  14933. }
  14934. // Clone any incoming data and prepend the event, creating the handler arg list
  14935. data = data == null ?
  14936. [ event ] :
  14937. jQuery.makeArray( data, [ event ] );
  14938. // Allow special events to draw outside the lines
  14939. special = jQuery.event.special[ type ] || {};
  14940. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  14941. return;
  14942. }
  14943. // Determine event propagation path in advance, per W3C events spec (#9951)
  14944. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  14945. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  14946. bubbleType = special.delegateType || type;
  14947. if ( !rfocusMorph.test( bubbleType + type ) ) {
  14948. cur = cur.parentNode;
  14949. }
  14950. for ( ; cur; cur = cur.parentNode ) {
  14951. eventPath.push( cur );
  14952. tmp = cur;
  14953. }
  14954. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  14955. if ( tmp === ( elem.ownerDocument || document ) ) {
  14956. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  14957. }
  14958. }
  14959. // Fire handlers on the event path
  14960. i = 0;
  14961. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  14962. lastElement = cur;
  14963. event.type = i > 1 ?
  14964. bubbleType :
  14965. special.bindType || type;
  14966. // jQuery handler
  14967. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  14968. dataPriv.get( cur, "handle" );
  14969. if ( handle ) {
  14970. handle.apply( cur, data );
  14971. }
  14972. // Native handler
  14973. handle = ontype && cur[ ontype ];
  14974. if ( handle && handle.apply && acceptData( cur ) ) {
  14975. event.result = handle.apply( cur, data );
  14976. if ( event.result === false ) {
  14977. event.preventDefault();
  14978. }
  14979. }
  14980. }
  14981. event.type = type;
  14982. // If nobody prevented the default action, do it now
  14983. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  14984. if ( ( !special._default ||
  14985. special._default.apply( eventPath.pop(), data ) === false ) &&
  14986. acceptData( elem ) ) {
  14987. // Call a native DOM method on the target with the same name as the event.
  14988. // Don't do default actions on window, that's where global variables be (#6170)
  14989. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  14990. // Don't re-trigger an onFOO event when we call its FOO() method
  14991. tmp = elem[ ontype ];
  14992. if ( tmp ) {
  14993. elem[ ontype ] = null;
  14994. }
  14995. // Prevent re-triggering of the same event, since we already bubbled it above
  14996. jQuery.event.triggered = type;
  14997. if ( event.isPropagationStopped() ) {
  14998. lastElement.addEventListener( type, stopPropagationCallback );
  14999. }
  15000. elem[ type ]();
  15001. if ( event.isPropagationStopped() ) {
  15002. lastElement.removeEventListener( type, stopPropagationCallback );
  15003. }
  15004. jQuery.event.triggered = undefined;
  15005. if ( tmp ) {
  15006. elem[ ontype ] = tmp;
  15007. }
  15008. }
  15009. }
  15010. }
  15011. return event.result;
  15012. },
  15013. // Piggyback on a donor event to simulate a different one
  15014. // Used only for `focus(in | out)` events
  15015. simulate: function( type, elem, event ) {
  15016. var e = jQuery.extend(
  15017. new jQuery.Event(),
  15018. event,
  15019. {
  15020. type: type,
  15021. isSimulated: true
  15022. }
  15023. );
  15024. jQuery.event.trigger( e, null, elem );
  15025. }
  15026. } );
  15027. jQuery.fn.extend( {
  15028. trigger: function( type, data ) {
  15029. return this.each( function() {
  15030. jQuery.event.trigger( type, data, this );
  15031. } );
  15032. },
  15033. triggerHandler: function( type, data ) {
  15034. var elem = this[ 0 ];
  15035. if ( elem ) {
  15036. return jQuery.event.trigger( type, data, elem, true );
  15037. }
  15038. }
  15039. } );
  15040. // Support: Firefox <=44
  15041. // Firefox doesn't have focus(in | out) events
  15042. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  15043. //
  15044. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  15045. // focus(in | out) events fire after focus & blur events,
  15046. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  15047. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  15048. if ( !support.focusin ) {
  15049. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  15050. // Attach a single capturing handler on the document while someone wants focusin/focusout
  15051. var handler = function( event ) {
  15052. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  15053. };
  15054. jQuery.event.special[ fix ] = {
  15055. setup: function() {
  15056. var doc = this.ownerDocument || this,
  15057. attaches = dataPriv.access( doc, fix );
  15058. if ( !attaches ) {
  15059. doc.addEventListener( orig, handler, true );
  15060. }
  15061. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  15062. },
  15063. teardown: function() {
  15064. var doc = this.ownerDocument || this,
  15065. attaches = dataPriv.access( doc, fix ) - 1;
  15066. if ( !attaches ) {
  15067. doc.removeEventListener( orig, handler, true );
  15068. dataPriv.remove( doc, fix );
  15069. } else {
  15070. dataPriv.access( doc, fix, attaches );
  15071. }
  15072. }
  15073. };
  15074. } );
  15075. }
  15076. var location = window.location;
  15077. var nonce = Date.now();
  15078. var rquery = ( /\?/ );
  15079. // Cross-browser xml parsing
  15080. jQuery.parseXML = function( data ) {
  15081. var xml;
  15082. if ( !data || typeof data !== "string" ) {
  15083. return null;
  15084. }
  15085. // Support: IE 9 - 11 only
  15086. // IE throws on parseFromString with invalid input.
  15087. try {
  15088. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  15089. } catch ( e ) {
  15090. xml = undefined;
  15091. }
  15092. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  15093. jQuery.error( "Invalid XML: " + data );
  15094. }
  15095. return xml;
  15096. };
  15097. var
  15098. rbracket = /\[\]$/,
  15099. rCRLF = /\r?\n/g,
  15100. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  15101. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  15102. function buildParams( prefix, obj, traditional, add ) {
  15103. var name;
  15104. if ( Array.isArray( obj ) ) {
  15105. // Serialize array item.
  15106. jQuery.each( obj, function( i, v ) {
  15107. if ( traditional || rbracket.test( prefix ) ) {
  15108. // Treat each array item as a scalar.
  15109. add( prefix, v );
  15110. } else {
  15111. // Item is non-scalar (array or object), encode its numeric index.
  15112. buildParams(
  15113. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  15114. v,
  15115. traditional,
  15116. add
  15117. );
  15118. }
  15119. } );
  15120. } else if ( !traditional && toType( obj ) === "object" ) {
  15121. // Serialize object item.
  15122. for ( name in obj ) {
  15123. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  15124. }
  15125. } else {
  15126. // Serialize scalar item.
  15127. add( prefix, obj );
  15128. }
  15129. }
  15130. // Serialize an array of form elements or a set of
  15131. // key/values into a query string
  15132. jQuery.param = function( a, traditional ) {
  15133. var prefix,
  15134. s = [],
  15135. add = function( key, valueOrFunction ) {
  15136. // If value is a function, invoke it and use its return value
  15137. var value = isFunction( valueOrFunction ) ?
  15138. valueOrFunction() :
  15139. valueOrFunction;
  15140. s[ s.length ] = encodeURIComponent( key ) + "=" +
  15141. encodeURIComponent( value == null ? "" : value );
  15142. };
  15143. if ( a == null ) {
  15144. return "";
  15145. }
  15146. // If an array was passed in, assume that it is an array of form elements.
  15147. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  15148. // Serialize the form elements
  15149. jQuery.each( a, function() {
  15150. add( this.name, this.value );
  15151. } );
  15152. } else {
  15153. // If traditional, encode the "old" way (the way 1.3.2 or older
  15154. // did it), otherwise encode params recursively.
  15155. for ( prefix in a ) {
  15156. buildParams( prefix, a[ prefix ], traditional, add );
  15157. }
  15158. }
  15159. // Return the resulting serialization
  15160. return s.join( "&" );
  15161. };
  15162. jQuery.fn.extend( {
  15163. serialize: function() {
  15164. return jQuery.param( this.serializeArray() );
  15165. },
  15166. serializeArray: function() {
  15167. return this.map( function() {
  15168. // Can add propHook for "elements" to filter or add form elements
  15169. var elements = jQuery.prop( this, "elements" );
  15170. return elements ? jQuery.makeArray( elements ) : this;
  15171. } )
  15172. .filter( function() {
  15173. var type = this.type;
  15174. // Use .is( ":disabled" ) so that fieldset[disabled] works
  15175. return this.name && !jQuery( this ).is( ":disabled" ) &&
  15176. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  15177. ( this.checked || !rcheckableType.test( type ) );
  15178. } )
  15179. .map( function( i, elem ) {
  15180. var val = jQuery( this ).val();
  15181. if ( val == null ) {
  15182. return null;
  15183. }
  15184. if ( Array.isArray( val ) ) {
  15185. return jQuery.map( val, function( val ) {
  15186. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15187. } );
  15188. }
  15189. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15190. } ).get();
  15191. }
  15192. } );
  15193. var
  15194. r20 = /%20/g,
  15195. rhash = /#.*$/,
  15196. rantiCache = /([?&])_=[^&]*/,
  15197. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  15198. // #7653, #8125, #8152: local protocol detection
  15199. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  15200. rnoContent = /^(?:GET|HEAD)$/,
  15201. rprotocol = /^\/\//,
  15202. /* Prefilters
  15203. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  15204. * 2) These are called:
  15205. * - BEFORE asking for a transport
  15206. * - AFTER param serialization (s.data is a string if s.processData is true)
  15207. * 3) key is the dataType
  15208. * 4) the catchall symbol "*" can be used
  15209. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  15210. */
  15211. prefilters = {},
  15212. /* Transports bindings
  15213. * 1) key is the dataType
  15214. * 2) the catchall symbol "*" can be used
  15215. * 3) selection will start with transport dataType and THEN go to "*" if needed
  15216. */
  15217. transports = {},
  15218. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  15219. allTypes = "*/".concat( "*" ),
  15220. // Anchor tag for parsing the document origin
  15221. originAnchor = document.createElement( "a" );
  15222. originAnchor.href = location.href;
  15223. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  15224. function addToPrefiltersOrTransports( structure ) {
  15225. // dataTypeExpression is optional and defaults to "*"
  15226. return function( dataTypeExpression, func ) {
  15227. if ( typeof dataTypeExpression !== "string" ) {
  15228. func = dataTypeExpression;
  15229. dataTypeExpression = "*";
  15230. }
  15231. var dataType,
  15232. i = 0,
  15233. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  15234. if ( isFunction( func ) ) {
  15235. // For each dataType in the dataTypeExpression
  15236. while ( ( dataType = dataTypes[ i++ ] ) ) {
  15237. // Prepend if requested
  15238. if ( dataType[ 0 ] === "+" ) {
  15239. dataType = dataType.slice( 1 ) || "*";
  15240. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  15241. // Otherwise append
  15242. } else {
  15243. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  15244. }
  15245. }
  15246. }
  15247. };
  15248. }
  15249. // Base inspection function for prefilters and transports
  15250. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  15251. var inspected = {},
  15252. seekingTransport = ( structure === transports );
  15253. function inspect( dataType ) {
  15254. var selected;
  15255. inspected[ dataType ] = true;
  15256. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  15257. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  15258. if ( typeof dataTypeOrTransport === "string" &&
  15259. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  15260. options.dataTypes.unshift( dataTypeOrTransport );
  15261. inspect( dataTypeOrTransport );
  15262. return false;
  15263. } else if ( seekingTransport ) {
  15264. return !( selected = dataTypeOrTransport );
  15265. }
  15266. } );
  15267. return selected;
  15268. }
  15269. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  15270. }
  15271. // A special extend for ajax options
  15272. // that takes "flat" options (not to be deep extended)
  15273. // Fixes #9887
  15274. function ajaxExtend( target, src ) {
  15275. var key, deep,
  15276. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  15277. for ( key in src ) {
  15278. if ( src[ key ] !== undefined ) {
  15279. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  15280. }
  15281. }
  15282. if ( deep ) {
  15283. jQuery.extend( true, target, deep );
  15284. }
  15285. return target;
  15286. }
  15287. /* Handles responses to an ajax request:
  15288. * - finds the right dataType (mediates between content-type and expected dataType)
  15289. * - returns the corresponding response
  15290. */
  15291. function ajaxHandleResponses( s, jqXHR, responses ) {
  15292. var ct, type, finalDataType, firstDataType,
  15293. contents = s.contents,
  15294. dataTypes = s.dataTypes;
  15295. // Remove auto dataType and get content-type in the process
  15296. while ( dataTypes[ 0 ] === "*" ) {
  15297. dataTypes.shift();
  15298. if ( ct === undefined ) {
  15299. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  15300. }
  15301. }
  15302. // Check if we're dealing with a known content-type
  15303. if ( ct ) {
  15304. for ( type in contents ) {
  15305. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  15306. dataTypes.unshift( type );
  15307. break;
  15308. }
  15309. }
  15310. }
  15311. // Check to see if we have a response for the expected dataType
  15312. if ( dataTypes[ 0 ] in responses ) {
  15313. finalDataType = dataTypes[ 0 ];
  15314. } else {
  15315. // Try convertible dataTypes
  15316. for ( type in responses ) {
  15317. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  15318. finalDataType = type;
  15319. break;
  15320. }
  15321. if ( !firstDataType ) {
  15322. firstDataType = type;
  15323. }
  15324. }
  15325. // Or just use first one
  15326. finalDataType = finalDataType || firstDataType;
  15327. }
  15328. // If we found a dataType
  15329. // We add the dataType to the list if needed
  15330. // and return the corresponding response
  15331. if ( finalDataType ) {
  15332. if ( finalDataType !== dataTypes[ 0 ] ) {
  15333. dataTypes.unshift( finalDataType );
  15334. }
  15335. return responses[ finalDataType ];
  15336. }
  15337. }
  15338. /* Chain conversions given the request and the original response
  15339. * Also sets the responseXXX fields on the jqXHR instance
  15340. */
  15341. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  15342. var conv2, current, conv, tmp, prev,
  15343. converters = {},
  15344. // Work with a copy of dataTypes in case we need to modify it for conversion
  15345. dataTypes = s.dataTypes.slice();
  15346. // Create converters map with lowercased keys
  15347. if ( dataTypes[ 1 ] ) {
  15348. for ( conv in s.converters ) {
  15349. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  15350. }
  15351. }
  15352. current = dataTypes.shift();
  15353. // Convert to each sequential dataType
  15354. while ( current ) {
  15355. if ( s.responseFields[ current ] ) {
  15356. jqXHR[ s.responseFields[ current ] ] = response;
  15357. }
  15358. // Apply the dataFilter if provided
  15359. if ( !prev && isSuccess && s.dataFilter ) {
  15360. response = s.dataFilter( response, s.dataType );
  15361. }
  15362. prev = current;
  15363. current = dataTypes.shift();
  15364. if ( current ) {
  15365. // There's only work to do if current dataType is non-auto
  15366. if ( current === "*" ) {
  15367. current = prev;
  15368. // Convert response if prev dataType is non-auto and differs from current
  15369. } else if ( prev !== "*" && prev !== current ) {
  15370. // Seek a direct converter
  15371. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  15372. // If none found, seek a pair
  15373. if ( !conv ) {
  15374. for ( conv2 in converters ) {
  15375. // If conv2 outputs current
  15376. tmp = conv2.split( " " );
  15377. if ( tmp[ 1 ] === current ) {
  15378. // If prev can be converted to accepted input
  15379. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  15380. converters[ "* " + tmp[ 0 ] ];
  15381. if ( conv ) {
  15382. // Condense equivalence converters
  15383. if ( conv === true ) {
  15384. conv = converters[ conv2 ];
  15385. // Otherwise, insert the intermediate dataType
  15386. } else if ( converters[ conv2 ] !== true ) {
  15387. current = tmp[ 0 ];
  15388. dataTypes.unshift( tmp[ 1 ] );
  15389. }
  15390. break;
  15391. }
  15392. }
  15393. }
  15394. }
  15395. // Apply converter (if not an equivalence)
  15396. if ( conv !== true ) {
  15397. // Unless errors are allowed to bubble, catch and return them
  15398. if ( conv && s.throws ) {
  15399. response = conv( response );
  15400. } else {
  15401. try {
  15402. response = conv( response );
  15403. } catch ( e ) {
  15404. return {
  15405. state: "parsererror",
  15406. error: conv ? e : "No conversion from " + prev + " to " + current
  15407. };
  15408. }
  15409. }
  15410. }
  15411. }
  15412. }
  15413. }
  15414. return { state: "success", data: response };
  15415. }
  15416. jQuery.extend( {
  15417. // Counter for holding the number of active queries
  15418. active: 0,
  15419. // Last-Modified header cache for next request
  15420. lastModified: {},
  15421. etag: {},
  15422. ajaxSettings: {
  15423. url: location.href,
  15424. type: "GET",
  15425. isLocal: rlocalProtocol.test( location.protocol ),
  15426. global: true,
  15427. processData: true,
  15428. async: true,
  15429. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  15430. /*
  15431. timeout: 0,
  15432. data: null,
  15433. dataType: null,
  15434. username: null,
  15435. password: null,
  15436. cache: null,
  15437. throws: false,
  15438. traditional: false,
  15439. headers: {},
  15440. */
  15441. accepts: {
  15442. "*": allTypes,
  15443. text: "text/plain",
  15444. html: "text/html",
  15445. xml: "application/xml, text/xml",
  15446. json: "application/json, text/javascript"
  15447. },
  15448. contents: {
  15449. xml: /\bxml\b/,
  15450. html: /\bhtml/,
  15451. json: /\bjson\b/
  15452. },
  15453. responseFields: {
  15454. xml: "responseXML",
  15455. text: "responseText",
  15456. json: "responseJSON"
  15457. },
  15458. // Data converters
  15459. // Keys separate source (or catchall "*") and destination types with a single space
  15460. converters: {
  15461. // Convert anything to text
  15462. "* text": String,
  15463. // Text to html (true = no transformation)
  15464. "text html": true,
  15465. // Evaluate text as a json expression
  15466. "text json": JSON.parse,
  15467. // Parse text as xml
  15468. "text xml": jQuery.parseXML
  15469. },
  15470. // For options that shouldn't be deep extended:
  15471. // you can add your own custom options here if
  15472. // and when you create one that shouldn't be
  15473. // deep extended (see ajaxExtend)
  15474. flatOptions: {
  15475. url: true,
  15476. context: true
  15477. }
  15478. },
  15479. // Creates a full fledged settings object into target
  15480. // with both ajaxSettings and settings fields.
  15481. // If target is omitted, writes into ajaxSettings.
  15482. ajaxSetup: function( target, settings ) {
  15483. return settings ?
  15484. // Building a settings object
  15485. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  15486. // Extending ajaxSettings
  15487. ajaxExtend( jQuery.ajaxSettings, target );
  15488. },
  15489. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  15490. ajaxTransport: addToPrefiltersOrTransports( transports ),
  15491. // Main method
  15492. ajax: function( url, options ) {
  15493. // If url is an object, simulate pre-1.5 signature
  15494. if ( typeof url === "object" ) {
  15495. options = url;
  15496. url = undefined;
  15497. }
  15498. // Force options to be an object
  15499. options = options || {};
  15500. var transport,
  15501. // URL without anti-cache param
  15502. cacheURL,
  15503. // Response headers
  15504. responseHeadersString,
  15505. responseHeaders,
  15506. // timeout handle
  15507. timeoutTimer,
  15508. // Url cleanup var
  15509. urlAnchor,
  15510. // Request state (becomes false upon send and true upon completion)
  15511. completed,
  15512. // To know if global events are to be dispatched
  15513. fireGlobals,
  15514. // Loop variable
  15515. i,
  15516. // uncached part of the url
  15517. uncached,
  15518. // Create the final options object
  15519. s = jQuery.ajaxSetup( {}, options ),
  15520. // Callbacks context
  15521. callbackContext = s.context || s,
  15522. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  15523. globalEventContext = s.context &&
  15524. ( callbackContext.nodeType || callbackContext.jquery ) ?
  15525. jQuery( callbackContext ) :
  15526. jQuery.event,
  15527. // Deferreds
  15528. deferred = jQuery.Deferred(),
  15529. completeDeferred = jQuery.Callbacks( "once memory" ),
  15530. // Status-dependent callbacks
  15531. statusCode = s.statusCode || {},
  15532. // Headers (they are sent all at once)
  15533. requestHeaders = {},
  15534. requestHeadersNames = {},
  15535. // Default abort message
  15536. strAbort = "canceled",
  15537. // Fake xhr
  15538. jqXHR = {
  15539. readyState: 0,
  15540. // Builds headers hashtable if needed
  15541. getResponseHeader: function( key ) {
  15542. var match;
  15543. if ( completed ) {
  15544. if ( !responseHeaders ) {
  15545. responseHeaders = {};
  15546. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  15547. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  15548. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  15549. .concat( match[ 2 ] );
  15550. }
  15551. }
  15552. match = responseHeaders[ key.toLowerCase() + " " ];
  15553. }
  15554. return match == null ? null : match.join( ", " );
  15555. },
  15556. // Raw string
  15557. getAllResponseHeaders: function() {
  15558. return completed ? responseHeadersString : null;
  15559. },
  15560. // Caches the header
  15561. setRequestHeader: function( name, value ) {
  15562. if ( completed == null ) {
  15563. name = requestHeadersNames[ name.toLowerCase() ] =
  15564. requestHeadersNames[ name.toLowerCase() ] || name;
  15565. requestHeaders[ name ] = value;
  15566. }
  15567. return this;
  15568. },
  15569. // Overrides response content-type header
  15570. overrideMimeType: function( type ) {
  15571. if ( completed == null ) {
  15572. s.mimeType = type;
  15573. }
  15574. return this;
  15575. },
  15576. // Status-dependent callbacks
  15577. statusCode: function( map ) {
  15578. var code;
  15579. if ( map ) {
  15580. if ( completed ) {
  15581. // Execute the appropriate callbacks
  15582. jqXHR.always( map[ jqXHR.status ] );
  15583. } else {
  15584. // Lazy-add the new callbacks in a way that preserves old ones
  15585. for ( code in map ) {
  15586. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  15587. }
  15588. }
  15589. }
  15590. return this;
  15591. },
  15592. // Cancel the request
  15593. abort: function( statusText ) {
  15594. var finalText = statusText || strAbort;
  15595. if ( transport ) {
  15596. transport.abort( finalText );
  15597. }
  15598. done( 0, finalText );
  15599. return this;
  15600. }
  15601. };
  15602. // Attach deferreds
  15603. deferred.promise( jqXHR );
  15604. // Add protocol if not provided (prefilters might expect it)
  15605. // Handle falsy url in the settings object (#10093: consistency with old signature)
  15606. // We also use the url parameter if available
  15607. s.url = ( ( url || s.url || location.href ) + "" )
  15608. .replace( rprotocol, location.protocol + "//" );
  15609. // Alias method option to type as per ticket #12004
  15610. s.type = options.method || options.type || s.method || s.type;
  15611. // Extract dataTypes list
  15612. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  15613. // A cross-domain request is in order when the origin doesn't match the current origin.
  15614. if ( s.crossDomain == null ) {
  15615. urlAnchor = document.createElement( "a" );
  15616. // Support: IE <=8 - 11, Edge 12 - 15
  15617. // IE throws exception on accessing the href property if url is malformed,
  15618. // e.g. http://example.com:80x/
  15619. try {
  15620. urlAnchor.href = s.url;
  15621. // Support: IE <=8 - 11 only
  15622. // Anchor's host property isn't correctly set when s.url is relative
  15623. urlAnchor.href = urlAnchor.href;
  15624. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  15625. urlAnchor.protocol + "//" + urlAnchor.host;
  15626. } catch ( e ) {
  15627. // If there is an error parsing the URL, assume it is crossDomain,
  15628. // it can be rejected by the transport if it is invalid
  15629. s.crossDomain = true;
  15630. }
  15631. }
  15632. // Convert data if not already a string
  15633. if ( s.data && s.processData && typeof s.data !== "string" ) {
  15634. s.data = jQuery.param( s.data, s.traditional );
  15635. }
  15636. // Apply prefilters
  15637. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  15638. // If request was aborted inside a prefilter, stop there
  15639. if ( completed ) {
  15640. return jqXHR;
  15641. }
  15642. // We can fire global events as of now if asked to
  15643. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  15644. fireGlobals = jQuery.event && s.global;
  15645. // Watch for a new set of requests
  15646. if ( fireGlobals && jQuery.active++ === 0 ) {
  15647. jQuery.event.trigger( "ajaxStart" );
  15648. }
  15649. // Uppercase the type
  15650. s.type = s.type.toUpperCase();
  15651. // Determine if request has content
  15652. s.hasContent = !rnoContent.test( s.type );
  15653. // Save the URL in case we're toying with the If-Modified-Since
  15654. // and/or If-None-Match header later on
  15655. // Remove hash to simplify url manipulation
  15656. cacheURL = s.url.replace( rhash, "" );
  15657. // More options handling for requests with no content
  15658. if ( !s.hasContent ) {
  15659. // Remember the hash so we can put it back
  15660. uncached = s.url.slice( cacheURL.length );
  15661. // If data is available and should be processed, append data to url
  15662. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  15663. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  15664. // #9682: remove data so that it's not used in an eventual retry
  15665. delete s.data;
  15666. }
  15667. // Add or update anti-cache param if needed
  15668. if ( s.cache === false ) {
  15669. cacheURL = cacheURL.replace( rantiCache, "$1" );
  15670. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  15671. }
  15672. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  15673. s.url = cacheURL + uncached;
  15674. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  15675. } else if ( s.data && s.processData &&
  15676. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  15677. s.data = s.data.replace( r20, "+" );
  15678. }
  15679. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15680. if ( s.ifModified ) {
  15681. if ( jQuery.lastModified[ cacheURL ] ) {
  15682. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  15683. }
  15684. if ( jQuery.etag[ cacheURL ] ) {
  15685. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  15686. }
  15687. }
  15688. // Set the correct header, if data is being sent
  15689. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  15690. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  15691. }
  15692. // Set the Accepts header for the server, depending on the dataType
  15693. jqXHR.setRequestHeader(
  15694. "Accept",
  15695. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  15696. s.accepts[ s.dataTypes[ 0 ] ] +
  15697. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  15698. s.accepts[ "*" ]
  15699. );
  15700. // Check for headers option
  15701. for ( i in s.headers ) {
  15702. jqXHR.setRequestHeader( i, s.headers[ i ] );
  15703. }
  15704. // Allow custom headers/mimetypes and early abort
  15705. if ( s.beforeSend &&
  15706. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  15707. // Abort if not done already and return
  15708. return jqXHR.abort();
  15709. }
  15710. // Aborting is no longer a cancellation
  15711. strAbort = "abort";
  15712. // Install callbacks on deferreds
  15713. completeDeferred.add( s.complete );
  15714. jqXHR.done( s.success );
  15715. jqXHR.fail( s.error );
  15716. // Get transport
  15717. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  15718. // If no transport, we auto-abort
  15719. if ( !transport ) {
  15720. done( -1, "No Transport" );
  15721. } else {
  15722. jqXHR.readyState = 1;
  15723. // Send global event
  15724. if ( fireGlobals ) {
  15725. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  15726. }
  15727. // If request was aborted inside ajaxSend, stop there
  15728. if ( completed ) {
  15729. return jqXHR;
  15730. }
  15731. // Timeout
  15732. if ( s.async && s.timeout > 0 ) {
  15733. timeoutTimer = window.setTimeout( function() {
  15734. jqXHR.abort( "timeout" );
  15735. }, s.timeout );
  15736. }
  15737. try {
  15738. completed = false;
  15739. transport.send( requestHeaders, done );
  15740. } catch ( e ) {
  15741. // Rethrow post-completion exceptions
  15742. if ( completed ) {
  15743. throw e;
  15744. }
  15745. // Propagate others as results
  15746. done( -1, e );
  15747. }
  15748. }
  15749. // Callback for when everything is done
  15750. function done( status, nativeStatusText, responses, headers ) {
  15751. var isSuccess, success, error, response, modified,
  15752. statusText = nativeStatusText;
  15753. // Ignore repeat invocations
  15754. if ( completed ) {
  15755. return;
  15756. }
  15757. completed = true;
  15758. // Clear timeout if it exists
  15759. if ( timeoutTimer ) {
  15760. window.clearTimeout( timeoutTimer );
  15761. }
  15762. // Dereference transport for early garbage collection
  15763. // (no matter how long the jqXHR object will be used)
  15764. transport = undefined;
  15765. // Cache response headers
  15766. responseHeadersString = headers || "";
  15767. // Set readyState
  15768. jqXHR.readyState = status > 0 ? 4 : 0;
  15769. // Determine if successful
  15770. isSuccess = status >= 200 && status < 300 || status === 304;
  15771. // Get response data
  15772. if ( responses ) {
  15773. response = ajaxHandleResponses( s, jqXHR, responses );
  15774. }
  15775. // Convert no matter what (that way responseXXX fields are always set)
  15776. response = ajaxConvert( s, response, jqXHR, isSuccess );
  15777. // If successful, handle type chaining
  15778. if ( isSuccess ) {
  15779. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15780. if ( s.ifModified ) {
  15781. modified = jqXHR.getResponseHeader( "Last-Modified" );
  15782. if ( modified ) {
  15783. jQuery.lastModified[ cacheURL ] = modified;
  15784. }
  15785. modified = jqXHR.getResponseHeader( "etag" );
  15786. if ( modified ) {
  15787. jQuery.etag[ cacheURL ] = modified;
  15788. }
  15789. }
  15790. // if no content
  15791. if ( status === 204 || s.type === "HEAD" ) {
  15792. statusText = "nocontent";
  15793. // if not modified
  15794. } else if ( status === 304 ) {
  15795. statusText = "notmodified";
  15796. // If we have data, let's convert it
  15797. } else {
  15798. statusText = response.state;
  15799. success = response.data;
  15800. error = response.error;
  15801. isSuccess = !error;
  15802. }
  15803. } else {
  15804. // Extract error from statusText and normalize for non-aborts
  15805. error = statusText;
  15806. if ( status || !statusText ) {
  15807. statusText = "error";
  15808. if ( status < 0 ) {
  15809. status = 0;
  15810. }
  15811. }
  15812. }
  15813. // Set data for the fake xhr object
  15814. jqXHR.status = status;
  15815. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  15816. // Success/Error
  15817. if ( isSuccess ) {
  15818. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  15819. } else {
  15820. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  15821. }
  15822. // Status-dependent callbacks
  15823. jqXHR.statusCode( statusCode );
  15824. statusCode = undefined;
  15825. if ( fireGlobals ) {
  15826. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  15827. [ jqXHR, s, isSuccess ? success : error ] );
  15828. }
  15829. // Complete
  15830. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  15831. if ( fireGlobals ) {
  15832. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  15833. // Handle the global AJAX counter
  15834. if ( !( --jQuery.active ) ) {
  15835. jQuery.event.trigger( "ajaxStop" );
  15836. }
  15837. }
  15838. }
  15839. return jqXHR;
  15840. },
  15841. getJSON: function( url, data, callback ) {
  15842. return jQuery.get( url, data, callback, "json" );
  15843. },
  15844. getScript: function( url, callback ) {
  15845. return jQuery.get( url, undefined, callback, "script" );
  15846. }
  15847. } );
  15848. jQuery.each( [ "get", "post" ], function( i, method ) {
  15849. jQuery[ method ] = function( url, data, callback, type ) {
  15850. // Shift arguments if data argument was omitted
  15851. if ( isFunction( data ) ) {
  15852. type = type || callback;
  15853. callback = data;
  15854. data = undefined;
  15855. }
  15856. // The url can be an options object (which then must have .url)
  15857. return jQuery.ajax( jQuery.extend( {
  15858. url: url,
  15859. type: method,
  15860. dataType: type,
  15861. data: data,
  15862. success: callback
  15863. }, jQuery.isPlainObject( url ) && url ) );
  15864. };
  15865. } );
  15866. jQuery._evalUrl = function( url, options ) {
  15867. return jQuery.ajax( {
  15868. url: url,
  15869. // Make this explicit, since user can override this through ajaxSetup (#11264)
  15870. type: "GET",
  15871. dataType: "script",
  15872. cache: true,
  15873. async: false,
  15874. global: false,
  15875. // Only evaluate the response if it is successful (gh-4126)
  15876. // dataFilter is not invoked for failure responses, so using it instead
  15877. // of the default converter is kludgy but it works.
  15878. converters: {
  15879. "text script": function() {}
  15880. },
  15881. dataFilter: function( response ) {
  15882. jQuery.globalEval( response, options );
  15883. }
  15884. } );
  15885. };
  15886. jQuery.fn.extend( {
  15887. wrapAll: function( html ) {
  15888. var wrap;
  15889. if ( this[ 0 ] ) {
  15890. if ( isFunction( html ) ) {
  15891. html = html.call( this[ 0 ] );
  15892. }
  15893. // The elements to wrap the target around
  15894. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  15895. if ( this[ 0 ].parentNode ) {
  15896. wrap.insertBefore( this[ 0 ] );
  15897. }
  15898. wrap.map( function() {
  15899. var elem = this;
  15900. while ( elem.firstElementChild ) {
  15901. elem = elem.firstElementChild;
  15902. }
  15903. return elem;
  15904. } ).append( this );
  15905. }
  15906. return this;
  15907. },
  15908. wrapInner: function( html ) {
  15909. if ( isFunction( html ) ) {
  15910. return this.each( function( i ) {
  15911. jQuery( this ).wrapInner( html.call( this, i ) );
  15912. } );
  15913. }
  15914. return this.each( function() {
  15915. var self = jQuery( this ),
  15916. contents = self.contents();
  15917. if ( contents.length ) {
  15918. contents.wrapAll( html );
  15919. } else {
  15920. self.append( html );
  15921. }
  15922. } );
  15923. },
  15924. wrap: function( html ) {
  15925. var htmlIsFunction = isFunction( html );
  15926. return this.each( function( i ) {
  15927. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  15928. } );
  15929. },
  15930. unwrap: function( selector ) {
  15931. this.parent( selector ).not( "body" ).each( function() {
  15932. jQuery( this ).replaceWith( this.childNodes );
  15933. } );
  15934. return this;
  15935. }
  15936. } );
  15937. jQuery.expr.pseudos.hidden = function( elem ) {
  15938. return !jQuery.expr.pseudos.visible( elem );
  15939. };
  15940. jQuery.expr.pseudos.visible = function( elem ) {
  15941. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  15942. };
  15943. jQuery.ajaxSettings.xhr = function() {
  15944. try {
  15945. return new window.XMLHttpRequest();
  15946. } catch ( e ) {}
  15947. };
  15948. var xhrSuccessStatus = {
  15949. // File protocol always yields status code 0, assume 200
  15950. 0: 200,
  15951. // Support: IE <=9 only
  15952. // #1450: sometimes IE returns 1223 when it should be 204
  15953. 1223: 204
  15954. },
  15955. xhrSupported = jQuery.ajaxSettings.xhr();
  15956. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  15957. support.ajax = xhrSupported = !!xhrSupported;
  15958. jQuery.ajaxTransport( function( options ) {
  15959. var callback, errorCallback;
  15960. // Cross domain only allowed if supported through XMLHttpRequest
  15961. if ( support.cors || xhrSupported && !options.crossDomain ) {
  15962. return {
  15963. send: function( headers, complete ) {
  15964. var i,
  15965. xhr = options.xhr();
  15966. xhr.open(
  15967. options.type,
  15968. options.url,
  15969. options.async,
  15970. options.username,
  15971. options.password
  15972. );
  15973. // Apply custom fields if provided
  15974. if ( options.xhrFields ) {
  15975. for ( i in options.xhrFields ) {
  15976. xhr[ i ] = options.xhrFields[ i ];
  15977. }
  15978. }
  15979. // Override mime type if needed
  15980. if ( options.mimeType && xhr.overrideMimeType ) {
  15981. xhr.overrideMimeType( options.mimeType );
  15982. }
  15983. // X-Requested-With header
  15984. // For cross-domain requests, seeing as conditions for a preflight are
  15985. // akin to a jigsaw puzzle, we simply never set it to be sure.
  15986. // (it can always be set on a per-request basis or even using ajaxSetup)
  15987. // For same-domain requests, won't change header if already provided.
  15988. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  15989. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  15990. }
  15991. // Set headers
  15992. for ( i in headers ) {
  15993. xhr.setRequestHeader( i, headers[ i ] );
  15994. }
  15995. // Callback
  15996. callback = function( type ) {
  15997. return function() {
  15998. if ( callback ) {
  15999. callback = errorCallback = xhr.onload =
  16000. xhr.onerror = xhr.onabort = xhr.ontimeout =
  16001. xhr.onreadystatechange = null;
  16002. if ( type === "abort" ) {
  16003. xhr.abort();
  16004. } else if ( type === "error" ) {
  16005. // Support: IE <=9 only
  16006. // On a manual native abort, IE9 throws
  16007. // errors on any property access that is not readyState
  16008. if ( typeof xhr.status !== "number" ) {
  16009. complete( 0, "error" );
  16010. } else {
  16011. complete(
  16012. // File: protocol always yields status 0; see #8605, #14207
  16013. xhr.status,
  16014. xhr.statusText
  16015. );
  16016. }
  16017. } else {
  16018. complete(
  16019. xhrSuccessStatus[ xhr.status ] || xhr.status,
  16020. xhr.statusText,
  16021. // Support: IE <=9 only
  16022. // IE9 has no XHR2 but throws on binary (trac-11426)
  16023. // For XHR2 non-text, let the caller handle it (gh-2498)
  16024. ( xhr.responseType || "text" ) !== "text" ||
  16025. typeof xhr.responseText !== "string" ?
  16026. { binary: xhr.response } :
  16027. { text: xhr.responseText },
  16028. xhr.getAllResponseHeaders()
  16029. );
  16030. }
  16031. }
  16032. };
  16033. };
  16034. // Listen to events
  16035. xhr.onload = callback();
  16036. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  16037. // Support: IE 9 only
  16038. // Use onreadystatechange to replace onabort
  16039. // to handle uncaught aborts
  16040. if ( xhr.onabort !== undefined ) {
  16041. xhr.onabort = errorCallback;
  16042. } else {
  16043. xhr.onreadystatechange = function() {
  16044. // Check readyState before timeout as it changes
  16045. if ( xhr.readyState === 4 ) {
  16046. // Allow onerror to be called first,
  16047. // but that will not handle a native abort
  16048. // Also, save errorCallback to a variable
  16049. // as xhr.onerror cannot be accessed
  16050. window.setTimeout( function() {
  16051. if ( callback ) {
  16052. errorCallback();
  16053. }
  16054. } );
  16055. }
  16056. };
  16057. }
  16058. // Create the abort callback
  16059. callback = callback( "abort" );
  16060. try {
  16061. // Do send the request (this may raise an exception)
  16062. xhr.send( options.hasContent && options.data || null );
  16063. } catch ( e ) {
  16064. // #14683: Only rethrow if this hasn't been notified as an error yet
  16065. if ( callback ) {
  16066. throw e;
  16067. }
  16068. }
  16069. },
  16070. abort: function() {
  16071. if ( callback ) {
  16072. callback();
  16073. }
  16074. }
  16075. };
  16076. }
  16077. } );
  16078. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  16079. jQuery.ajaxPrefilter( function( s ) {
  16080. if ( s.crossDomain ) {
  16081. s.contents.script = false;
  16082. }
  16083. } );
  16084. // Install script dataType
  16085. jQuery.ajaxSetup( {
  16086. accepts: {
  16087. script: "text/javascript, application/javascript, " +
  16088. "application/ecmascript, application/x-ecmascript"
  16089. },
  16090. contents: {
  16091. script: /\b(?:java|ecma)script\b/
  16092. },
  16093. converters: {
  16094. "text script": function( text ) {
  16095. jQuery.globalEval( text );
  16096. return text;
  16097. }
  16098. }
  16099. } );
  16100. // Handle cache's special case and crossDomain
  16101. jQuery.ajaxPrefilter( "script", function( s ) {
  16102. if ( s.cache === undefined ) {
  16103. s.cache = false;
  16104. }
  16105. if ( s.crossDomain ) {
  16106. s.type = "GET";
  16107. }
  16108. } );
  16109. // Bind script tag hack transport
  16110. jQuery.ajaxTransport( "script", function( s ) {
  16111. // This transport only deals with cross domain or forced-by-attrs requests
  16112. if ( s.crossDomain || s.scriptAttrs ) {
  16113. var script, callback;
  16114. return {
  16115. send: function( _, complete ) {
  16116. script = jQuery( "<script>" )
  16117. .attr( s.scriptAttrs || {} )
  16118. .prop( { charset: s.scriptCharset, src: s.url } )
  16119. .on( "load error", callback = function( evt ) {
  16120. script.remove();
  16121. callback = null;
  16122. if ( evt ) {
  16123. complete( evt.type === "error" ? 404 : 200, evt.type );
  16124. }
  16125. } );
  16126. // Use native DOM manipulation to avoid our domManip AJAX trickery
  16127. document.head.appendChild( script[ 0 ] );
  16128. },
  16129. abort: function() {
  16130. if ( callback ) {
  16131. callback();
  16132. }
  16133. }
  16134. };
  16135. }
  16136. } );
  16137. var oldCallbacks = [],
  16138. rjsonp = /(=)\?(?=&|$)|\?\?/;
  16139. // Default jsonp settings
  16140. jQuery.ajaxSetup( {
  16141. jsonp: "callback",
  16142. jsonpCallback: function() {
  16143. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  16144. this[ callback ] = true;
  16145. return callback;
  16146. }
  16147. } );
  16148. // Detect, normalize options and install callbacks for jsonp requests
  16149. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  16150. var callbackName, overwritten, responseContainer,
  16151. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  16152. "url" :
  16153. typeof s.data === "string" &&
  16154. ( s.contentType || "" )
  16155. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  16156. rjsonp.test( s.data ) && "data"
  16157. );
  16158. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  16159. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  16160. // Get callback name, remembering preexisting value associated with it
  16161. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  16162. s.jsonpCallback() :
  16163. s.jsonpCallback;
  16164. // Insert callback into url or form data
  16165. if ( jsonProp ) {
  16166. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  16167. } else if ( s.jsonp !== false ) {
  16168. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  16169. }
  16170. // Use data converter to retrieve json after script execution
  16171. s.converters[ "script json" ] = function() {
  16172. if ( !responseContainer ) {
  16173. jQuery.error( callbackName + " was not called" );
  16174. }
  16175. return responseContainer[ 0 ];
  16176. };
  16177. // Force json dataType
  16178. s.dataTypes[ 0 ] = "json";
  16179. // Install callback
  16180. overwritten = window[ callbackName ];
  16181. window[ callbackName ] = function() {
  16182. responseContainer = arguments;
  16183. };
  16184. // Clean-up function (fires after converters)
  16185. jqXHR.always( function() {
  16186. // If previous value didn't exist - remove it
  16187. if ( overwritten === undefined ) {
  16188. jQuery( window ).removeProp( callbackName );
  16189. // Otherwise restore preexisting value
  16190. } else {
  16191. window[ callbackName ] = overwritten;
  16192. }
  16193. // Save back as free
  16194. if ( s[ callbackName ] ) {
  16195. // Make sure that re-using the options doesn't screw things around
  16196. s.jsonpCallback = originalSettings.jsonpCallback;
  16197. // Save the callback name for future use
  16198. oldCallbacks.push( callbackName );
  16199. }
  16200. // Call if it was a function and we have a response
  16201. if ( responseContainer && isFunction( overwritten ) ) {
  16202. overwritten( responseContainer[ 0 ] );
  16203. }
  16204. responseContainer = overwritten = undefined;
  16205. } );
  16206. // Delegate to script
  16207. return "script";
  16208. }
  16209. } );
  16210. // Support: Safari 8 only
  16211. // In Safari 8 documents created via document.implementation.createHTMLDocument
  16212. // collapse sibling forms: the second one becomes a child of the first one.
  16213. // Because of that, this security measure has to be disabled in Safari 8.
  16214. // https://bugs.webkit.org/show_bug.cgi?id=137337
  16215. support.createHTMLDocument = ( function() {
  16216. var body = document.implementation.createHTMLDocument( "" ).body;
  16217. body.innerHTML = "<form></form><form></form>";
  16218. return body.childNodes.length === 2;
  16219. } )();
  16220. // Argument "data" should be string of html
  16221. // context (optional): If specified, the fragment will be created in this context,
  16222. // defaults to document
  16223. // keepScripts (optional): If true, will include scripts passed in the html string
  16224. jQuery.parseHTML = function( data, context, keepScripts ) {
  16225. if ( typeof data !== "string" ) {
  16226. return [];
  16227. }
  16228. if ( typeof context === "boolean" ) {
  16229. keepScripts = context;
  16230. context = false;
  16231. }
  16232. var base, parsed, scripts;
  16233. if ( !context ) {
  16234. // Stop scripts or inline event handlers from being executed immediately
  16235. // by using document.implementation
  16236. if ( support.createHTMLDocument ) {
  16237. context = document.implementation.createHTMLDocument( "" );
  16238. // Set the base href for the created document
  16239. // so any parsed elements with URLs
  16240. // are based on the document's URL (gh-2965)
  16241. base = context.createElement( "base" );
  16242. base.href = document.location.href;
  16243. context.head.appendChild( base );
  16244. } else {
  16245. context = document;
  16246. }
  16247. }
  16248. parsed = rsingleTag.exec( data );
  16249. scripts = !keepScripts && [];
  16250. // Single tag
  16251. if ( parsed ) {
  16252. return [ context.createElement( parsed[ 1 ] ) ];
  16253. }
  16254. parsed = buildFragment( [ data ], context, scripts );
  16255. if ( scripts && scripts.length ) {
  16256. jQuery( scripts ).remove();
  16257. }
  16258. return jQuery.merge( [], parsed.childNodes );
  16259. };
  16260. /**
  16261. * Load a url into a page
  16262. */
  16263. jQuery.fn.load = function( url, params, callback ) {
  16264. var selector, type, response,
  16265. self = this,
  16266. off = url.indexOf( " " );
  16267. if ( off > -1 ) {
  16268. selector = stripAndCollapse( url.slice( off ) );
  16269. url = url.slice( 0, off );
  16270. }
  16271. // If it's a function
  16272. if ( isFunction( params ) ) {
  16273. // We assume that it's the callback
  16274. callback = params;
  16275. params = undefined;
  16276. // Otherwise, build a param string
  16277. } else if ( params && typeof params === "object" ) {
  16278. type = "POST";
  16279. }
  16280. // If we have elements to modify, make the request
  16281. if ( self.length > 0 ) {
  16282. jQuery.ajax( {
  16283. url: url,
  16284. // If "type" variable is undefined, then "GET" method will be used.
  16285. // Make value of this field explicit since
  16286. // user can override it through ajaxSetup method
  16287. type: type || "GET",
  16288. dataType: "html",
  16289. data: params
  16290. } ).done( function( responseText ) {
  16291. // Save response for use in complete callback
  16292. response = arguments;
  16293. self.html( selector ?
  16294. // If a selector was specified, locate the right elements in a dummy div
  16295. // Exclude scripts to avoid IE 'Permission Denied' errors
  16296. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  16297. // Otherwise use the full result
  16298. responseText );
  16299. // If the request succeeds, this function gets "data", "status", "jqXHR"
  16300. // but they are ignored because response was set above.
  16301. // If it fails, this function gets "jqXHR", "status", "error"
  16302. } ).always( callback && function( jqXHR, status ) {
  16303. self.each( function() {
  16304. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  16305. } );
  16306. } );
  16307. }
  16308. return this;
  16309. };
  16310. // Attach a bunch of functions for handling common AJAX events
  16311. jQuery.each( [
  16312. "ajaxStart",
  16313. "ajaxStop",
  16314. "ajaxComplete",
  16315. "ajaxError",
  16316. "ajaxSuccess",
  16317. "ajaxSend"
  16318. ], function( i, type ) {
  16319. jQuery.fn[ type ] = function( fn ) {
  16320. return this.on( type, fn );
  16321. };
  16322. } );
  16323. jQuery.expr.pseudos.animated = function( elem ) {
  16324. return jQuery.grep( jQuery.timers, function( fn ) {
  16325. return elem === fn.elem;
  16326. } ).length;
  16327. };
  16328. jQuery.offset = {
  16329. setOffset: function( elem, options, i ) {
  16330. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  16331. position = jQuery.css( elem, "position" ),
  16332. curElem = jQuery( elem ),
  16333. props = {};
  16334. // Set position first, in-case top/left are set even on static elem
  16335. if ( position === "static" ) {
  16336. elem.style.position = "relative";
  16337. }
  16338. curOffset = curElem.offset();
  16339. curCSSTop = jQuery.css( elem, "top" );
  16340. curCSSLeft = jQuery.css( elem, "left" );
  16341. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  16342. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  16343. // Need to be able to calculate position if either
  16344. // top or left is auto and position is either absolute or fixed
  16345. if ( calculatePosition ) {
  16346. curPosition = curElem.position();
  16347. curTop = curPosition.top;
  16348. curLeft = curPosition.left;
  16349. } else {
  16350. curTop = parseFloat( curCSSTop ) || 0;
  16351. curLeft = parseFloat( curCSSLeft ) || 0;
  16352. }
  16353. if ( isFunction( options ) ) {
  16354. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  16355. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  16356. }
  16357. if ( options.top != null ) {
  16358. props.top = ( options.top - curOffset.top ) + curTop;
  16359. }
  16360. if ( options.left != null ) {
  16361. props.left = ( options.left - curOffset.left ) + curLeft;
  16362. }
  16363. if ( "using" in options ) {
  16364. options.using.call( elem, props );
  16365. } else {
  16366. curElem.css( props );
  16367. }
  16368. }
  16369. };
  16370. jQuery.fn.extend( {
  16371. // offset() relates an element's border box to the document origin
  16372. offset: function( options ) {
  16373. // Preserve chaining for setter
  16374. if ( arguments.length ) {
  16375. return options === undefined ?
  16376. this :
  16377. this.each( function( i ) {
  16378. jQuery.offset.setOffset( this, options, i );
  16379. } );
  16380. }
  16381. var rect, win,
  16382. elem = this[ 0 ];
  16383. if ( !elem ) {
  16384. return;
  16385. }
  16386. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  16387. // Support: IE <=11 only
  16388. // Running getBoundingClientRect on a
  16389. // disconnected node in IE throws an error
  16390. if ( !elem.getClientRects().length ) {
  16391. return { top: 0, left: 0 };
  16392. }
  16393. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  16394. rect = elem.getBoundingClientRect();
  16395. win = elem.ownerDocument.defaultView;
  16396. return {
  16397. top: rect.top + win.pageYOffset,
  16398. left: rect.left + win.pageXOffset
  16399. };
  16400. },
  16401. // position() relates an element's margin box to its offset parent's padding box
  16402. // This corresponds to the behavior of CSS absolute positioning
  16403. position: function() {
  16404. if ( !this[ 0 ] ) {
  16405. return;
  16406. }
  16407. var offsetParent, offset, doc,
  16408. elem = this[ 0 ],
  16409. parentOffset = { top: 0, left: 0 };
  16410. // position:fixed elements are offset from the viewport, which itself always has zero offset
  16411. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  16412. // Assume position:fixed implies availability of getBoundingClientRect
  16413. offset = elem.getBoundingClientRect();
  16414. } else {
  16415. offset = this.offset();
  16416. // Account for the *real* offset parent, which can be the document or its root element
  16417. // when a statically positioned element is identified
  16418. doc = elem.ownerDocument;
  16419. offsetParent = elem.offsetParent || doc.documentElement;
  16420. while ( offsetParent &&
  16421. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  16422. jQuery.css( offsetParent, "position" ) === "static" ) {
  16423. offsetParent = offsetParent.parentNode;
  16424. }
  16425. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  16426. // Incorporate borders into its offset, since they are outside its content origin
  16427. parentOffset = jQuery( offsetParent ).offset();
  16428. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  16429. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  16430. }
  16431. }
  16432. // Subtract parent offsets and element margins
  16433. return {
  16434. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  16435. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  16436. };
  16437. },
  16438. // This method will return documentElement in the following cases:
  16439. // 1) For the element inside the iframe without offsetParent, this method will return
  16440. // documentElement of the parent window
  16441. // 2) For the hidden or detached element
  16442. // 3) For body or html element, i.e. in case of the html node - it will return itself
  16443. //
  16444. // but those exceptions were never presented as a real life use-cases
  16445. // and might be considered as more preferable results.
  16446. //
  16447. // This logic, however, is not guaranteed and can change at any point in the future
  16448. offsetParent: function() {
  16449. return this.map( function() {
  16450. var offsetParent = this.offsetParent;
  16451. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  16452. offsetParent = offsetParent.offsetParent;
  16453. }
  16454. return offsetParent || documentElement;
  16455. } );
  16456. }
  16457. } );
  16458. // Create scrollLeft and scrollTop methods
  16459. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  16460. var top = "pageYOffset" === prop;
  16461. jQuery.fn[ method ] = function( val ) {
  16462. return access( this, function( elem, method, val ) {
  16463. // Coalesce documents and windows
  16464. var win;
  16465. if ( isWindow( elem ) ) {
  16466. win = elem;
  16467. } else if ( elem.nodeType === 9 ) {
  16468. win = elem.defaultView;
  16469. }
  16470. if ( val === undefined ) {
  16471. return win ? win[ prop ] : elem[ method ];
  16472. }
  16473. if ( win ) {
  16474. win.scrollTo(
  16475. !top ? val : win.pageXOffset,
  16476. top ? val : win.pageYOffset
  16477. );
  16478. } else {
  16479. elem[ method ] = val;
  16480. }
  16481. }, method, val, arguments.length );
  16482. };
  16483. } );
  16484. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  16485. // Add the top/left cssHooks using jQuery.fn.position
  16486. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  16487. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  16488. // getComputedStyle returns percent when specified for top/left/bottom/right;
  16489. // rather than make the css module depend on the offset module, just check for it here
  16490. jQuery.each( [ "top", "left" ], function( i, prop ) {
  16491. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  16492. function( elem, computed ) {
  16493. if ( computed ) {
  16494. computed = curCSS( elem, prop );
  16495. // If curCSS returns percentage, fallback to offset
  16496. return rnumnonpx.test( computed ) ?
  16497. jQuery( elem ).position()[ prop ] + "px" :
  16498. computed;
  16499. }
  16500. }
  16501. );
  16502. } );
  16503. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  16504. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  16505. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  16506. function( defaultExtra, funcName ) {
  16507. // Margin is only for outerHeight, outerWidth
  16508. jQuery.fn[ funcName ] = function( margin, value ) {
  16509. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  16510. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  16511. return access( this, function( elem, type, value ) {
  16512. var doc;
  16513. if ( isWindow( elem ) ) {
  16514. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  16515. return funcName.indexOf( "outer" ) === 0 ?
  16516. elem[ "inner" + name ] :
  16517. elem.document.documentElement[ "client" + name ];
  16518. }
  16519. // Get document width or height
  16520. if ( elem.nodeType === 9 ) {
  16521. doc = elem.documentElement;
  16522. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  16523. // whichever is greatest
  16524. return Math.max(
  16525. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  16526. elem.body[ "offset" + name ], doc[ "offset" + name ],
  16527. doc[ "client" + name ]
  16528. );
  16529. }
  16530. return value === undefined ?
  16531. // Get width or height on the element, requesting but not forcing parseFloat
  16532. jQuery.css( elem, type, extra ) :
  16533. // Set width or height on the element
  16534. jQuery.style( elem, type, value, extra );
  16535. }, type, chainable ? margin : undefined, chainable );
  16536. };
  16537. } );
  16538. } );
  16539. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  16540. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  16541. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  16542. function( i, name ) {
  16543. // Handle event binding
  16544. jQuery.fn[ name ] = function( data, fn ) {
  16545. return arguments.length > 0 ?
  16546. this.on( name, null, data, fn ) :
  16547. this.trigger( name );
  16548. };
  16549. } );
  16550. jQuery.fn.extend( {
  16551. hover: function( fnOver, fnOut ) {
  16552. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  16553. }
  16554. } );
  16555. jQuery.fn.extend( {
  16556. bind: function( types, data, fn ) {
  16557. return this.on( types, null, data, fn );
  16558. },
  16559. unbind: function( types, fn ) {
  16560. return this.off( types, null, fn );
  16561. },
  16562. delegate: function( selector, types, data, fn ) {
  16563. return this.on( types, selector, data, fn );
  16564. },
  16565. undelegate: function( selector, types, fn ) {
  16566. // ( namespace ) or ( selector, types [, fn] )
  16567. return arguments.length === 1 ?
  16568. this.off( selector, "**" ) :
  16569. this.off( types, selector || "**", fn );
  16570. }
  16571. } );
  16572. // Bind a function to a context, optionally partially applying any
  16573. // arguments.
  16574. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  16575. // However, it is not slated for removal any time soon
  16576. jQuery.proxy = function( fn, context ) {
  16577. var tmp, args, proxy;
  16578. if ( typeof context === "string" ) {
  16579. tmp = fn[ context ];
  16580. context = fn;
  16581. fn = tmp;
  16582. }
  16583. // Quick check to determine if target is callable, in the spec
  16584. // this throws a TypeError, but we will just return undefined.
  16585. if ( !isFunction( fn ) ) {
  16586. return undefined;
  16587. }
  16588. // Simulated bind
  16589. args = slice.call( arguments, 2 );
  16590. proxy = function() {
  16591. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  16592. };
  16593. // Set the guid of unique handler to the same of original handler, so it can be removed
  16594. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  16595. return proxy;
  16596. };
  16597. jQuery.holdReady = function( hold ) {
  16598. if ( hold ) {
  16599. jQuery.readyWait++;
  16600. } else {
  16601. jQuery.ready( true );
  16602. }
  16603. };
  16604. jQuery.isArray = Array.isArray;
  16605. jQuery.parseJSON = JSON.parse;
  16606. jQuery.nodeName = nodeName;
  16607. jQuery.isFunction = isFunction;
  16608. jQuery.isWindow = isWindow;
  16609. jQuery.camelCase = camelCase;
  16610. jQuery.type = toType;
  16611. jQuery.now = Date.now;
  16612. jQuery.isNumeric = function( obj ) {
  16613. // As of jQuery 3.0, isNumeric is limited to
  16614. // strings and numbers (primitives or objects)
  16615. // that can be coerced to finite numbers (gh-2662)
  16616. var type = jQuery.type( obj );
  16617. return ( type === "number" || type === "string" ) &&
  16618. // parseFloat NaNs numeric-cast false positives ("")
  16619. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  16620. // subtraction forces infinities to NaN
  16621. !isNaN( obj - parseFloat( obj ) );
  16622. };
  16623. // Register as a named AMD module, since jQuery can be concatenated with other
  16624. // files that may use define, but not via a proper concatenation script that
  16625. // understands anonymous AMD modules. A named AMD is safest and most robust
  16626. // way to register. Lowercase jquery is used because AMD module names are
  16627. // derived from file names, and jQuery is normally delivered in a lowercase
  16628. // file name. Do this after creating the global so that if an AMD module wants
  16629. // to call noConflict to hide this version of jQuery, it will work.
  16630. // Note that for maximum portability, libraries that are not jQuery should
  16631. // declare themselves as anonymous modules, and avoid setting a global if an
  16632. // AMD loader is present. jQuery is a special case. For more information, see
  16633. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  16634. if ( true ) {
  16635. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  16636. return jQuery;
  16637. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  16638. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16639. }
  16640. var
  16641. // Map over jQuery in case of overwrite
  16642. _jQuery = window.jQuery,
  16643. // Map over the $ in case of overwrite
  16644. _$ = window.$;
  16645. jQuery.noConflict = function( deep ) {
  16646. if ( window.$ === jQuery ) {
  16647. window.$ = _$;
  16648. }
  16649. if ( deep && window.jQuery === jQuery ) {
  16650. window.jQuery = _jQuery;
  16651. }
  16652. return jQuery;
  16653. };
  16654. // Expose jQuery and $ identifiers, even in AMD
  16655. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  16656. // and CommonJS for browser emulators (#13566)
  16657. if ( !noGlobal ) {
  16658. window.jQuery = window.$ = jQuery;
  16659. }
  16660. return jQuery;
  16661. } );
  16662. /***/ }),
  16663. /***/ "./node_modules/laravel-echo/dist/echo.js":
  16664. /*!************************************************!*\
  16665. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  16666. \************************************************/
  16667. /*! exports provided: default */
  16668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16669. "use strict";
  16670. __webpack_require__.r(__webpack_exports__);
  16671. var classCallCheck = function (instance, Constructor) {
  16672. if (!(instance instanceof Constructor)) {
  16673. throw new TypeError("Cannot call a class as a function");
  16674. }
  16675. };
  16676. var createClass = function () {
  16677. function defineProperties(target, props) {
  16678. for (var i = 0; i < props.length; i++) {
  16679. var descriptor = props[i];
  16680. descriptor.enumerable = descriptor.enumerable || false;
  16681. descriptor.configurable = true;
  16682. if ("value" in descriptor) descriptor.writable = true;
  16683. Object.defineProperty(target, descriptor.key, descriptor);
  16684. }
  16685. }
  16686. return function (Constructor, protoProps, staticProps) {
  16687. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  16688. if (staticProps) defineProperties(Constructor, staticProps);
  16689. return Constructor;
  16690. };
  16691. }();
  16692. var _extends = Object.assign || function (target) {
  16693. for (var i = 1; i < arguments.length; i++) {
  16694. var source = arguments[i];
  16695. for (var key in source) {
  16696. if (Object.prototype.hasOwnProperty.call(source, key)) {
  16697. target[key] = source[key];
  16698. }
  16699. }
  16700. }
  16701. return target;
  16702. };
  16703. var inherits = function (subClass, superClass) {
  16704. if (typeof superClass !== "function" && superClass !== null) {
  16705. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  16706. }
  16707. subClass.prototype = Object.create(superClass && superClass.prototype, {
  16708. constructor: {
  16709. value: subClass,
  16710. enumerable: false,
  16711. writable: true,
  16712. configurable: true
  16713. }
  16714. });
  16715. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  16716. };
  16717. var possibleConstructorReturn = function (self, call) {
  16718. if (!self) {
  16719. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  16720. }
  16721. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  16722. };
  16723. var Connector = function () {
  16724. /**
  16725. * Create a new class instance.
  16726. */
  16727. function Connector(options) {
  16728. classCallCheck(this, Connector);
  16729. /**
  16730. * Default connector options.
  16731. */
  16732. this._defaultOptions = {
  16733. auth: {
  16734. headers: {}
  16735. },
  16736. authEndpoint: '/broadcasting/auth',
  16737. broadcaster: 'pusher',
  16738. csrfToken: null,
  16739. host: null,
  16740. key: null,
  16741. namespace: 'App.Events'
  16742. };
  16743. this.setOptions(options);
  16744. this.connect();
  16745. }
  16746. /**
  16747. * Merge the custom options with the defaults.
  16748. */
  16749. createClass(Connector, [{
  16750. key: 'setOptions',
  16751. value: function setOptions(options) {
  16752. this.options = _extends(this._defaultOptions, options);
  16753. if (this.csrfToken()) {
  16754. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  16755. }
  16756. return options;
  16757. }
  16758. /**
  16759. * Extract the CSRF token from the page.
  16760. */
  16761. }, {
  16762. key: 'csrfToken',
  16763. value: function csrfToken() {
  16764. var selector = void 0;
  16765. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  16766. return window['Laravel'].csrfToken;
  16767. } else if (this.options.csrfToken) {
  16768. return this.options.csrfToken;
  16769. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  16770. return selector.getAttribute('content');
  16771. }
  16772. return null;
  16773. }
  16774. }]);
  16775. return Connector;
  16776. }();
  16777. /**
  16778. * This class represents a basic channel.
  16779. */
  16780. var Channel = function () {
  16781. function Channel() {
  16782. classCallCheck(this, Channel);
  16783. }
  16784. createClass(Channel, [{
  16785. key: 'listenForWhisper',
  16786. /**
  16787. * Listen for a whisper event on the channel instance.
  16788. */
  16789. value: function listenForWhisper(event, callback) {
  16790. return this.listen('.client-' + event, callback);
  16791. }
  16792. /**
  16793. * Listen for an event on the channel instance.
  16794. */
  16795. }, {
  16796. key: 'notification',
  16797. value: function notification(callback) {
  16798. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  16799. }
  16800. /**
  16801. * Stop listening for a whispser event on the channel instance.
  16802. */
  16803. }, {
  16804. key: 'stopListeningForWhisper',
  16805. value: function stopListeningForWhisper(event) {
  16806. return this.stopListening('.client-' + event);
  16807. }
  16808. }]);
  16809. return Channel;
  16810. }();
  16811. /**
  16812. * Event name formatter
  16813. */
  16814. var EventFormatter = function () {
  16815. /**
  16816. * Create a new class instance.
  16817. */
  16818. function EventFormatter(namespace) {
  16819. classCallCheck(this, EventFormatter);
  16820. this.setNamespace(namespace);
  16821. }
  16822. /**
  16823. * Format the given event name.
  16824. */
  16825. createClass(EventFormatter, [{
  16826. key: 'format',
  16827. value: function format(event) {
  16828. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  16829. return event.substr(1);
  16830. } else if (this.namespace) {
  16831. event = this.namespace + '.' + event;
  16832. }
  16833. return event.replace(/\./g, '\\');
  16834. }
  16835. /**
  16836. * Set the event namespace.
  16837. */
  16838. }, {
  16839. key: 'setNamespace',
  16840. value: function setNamespace(value) {
  16841. this.namespace = value;
  16842. }
  16843. }]);
  16844. return EventFormatter;
  16845. }();
  16846. /**
  16847. * This class represents a Pusher channel.
  16848. */
  16849. var PusherChannel = function (_Channel) {
  16850. inherits(PusherChannel, _Channel);
  16851. /**
  16852. * Create a new class instance.
  16853. */
  16854. function PusherChannel(pusher, name, options) {
  16855. classCallCheck(this, PusherChannel);
  16856. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  16857. _this.name = name;
  16858. _this.pusher = pusher;
  16859. _this.options = options;
  16860. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16861. _this.subscribe();
  16862. return _this;
  16863. }
  16864. /**
  16865. * Subscribe to a Pusher channel.
  16866. */
  16867. createClass(PusherChannel, [{
  16868. key: 'subscribe',
  16869. value: function subscribe() {
  16870. this.subscription = this.pusher.subscribe(this.name);
  16871. }
  16872. /**
  16873. * Unsubscribe from a Pusher channel.
  16874. */
  16875. }, {
  16876. key: 'unsubscribe',
  16877. value: function unsubscribe() {
  16878. this.pusher.unsubscribe(this.name);
  16879. }
  16880. /**
  16881. * Listen for an event on the channel instance.
  16882. */
  16883. }, {
  16884. key: 'listen',
  16885. value: function listen(event, callback) {
  16886. this.on(this.eventFormatter.format(event), callback);
  16887. return this;
  16888. }
  16889. /**
  16890. * Stop listening for an event on the channel instance.
  16891. */
  16892. }, {
  16893. key: 'stopListening',
  16894. value: function stopListening(event) {
  16895. this.subscription.unbind(this.eventFormatter.format(event));
  16896. return this;
  16897. }
  16898. /**
  16899. * Bind a channel to an event.
  16900. */
  16901. }, {
  16902. key: 'on',
  16903. value: function on(event, callback) {
  16904. this.subscription.bind(event, callback);
  16905. return this;
  16906. }
  16907. }]);
  16908. return PusherChannel;
  16909. }(Channel);
  16910. /**
  16911. * This class represents a Pusher private channel.
  16912. */
  16913. var PusherPrivateChannel = function (_PusherChannel) {
  16914. inherits(PusherPrivateChannel, _PusherChannel);
  16915. function PusherPrivateChannel() {
  16916. classCallCheck(this, PusherPrivateChannel);
  16917. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  16918. }
  16919. createClass(PusherPrivateChannel, [{
  16920. key: 'whisper',
  16921. /**
  16922. * Trigger client event on the channel.
  16923. */
  16924. value: function whisper(eventName, data) {
  16925. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16926. return this;
  16927. }
  16928. }]);
  16929. return PusherPrivateChannel;
  16930. }(PusherChannel);
  16931. /**
  16932. * This class represents a Pusher presence channel.
  16933. */
  16934. var PusherPresenceChannel = function (_PusherChannel) {
  16935. inherits(PusherPresenceChannel, _PusherChannel);
  16936. function PusherPresenceChannel() {
  16937. classCallCheck(this, PusherPresenceChannel);
  16938. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  16939. }
  16940. createClass(PusherPresenceChannel, [{
  16941. key: 'here',
  16942. /**
  16943. * Register a callback to be called anytime the member list changes.
  16944. */
  16945. value: function here(callback) {
  16946. this.on('pusher:subscription_succeeded', function (data) {
  16947. callback(Object.keys(data.members).map(function (k) {
  16948. return data.members[k];
  16949. }));
  16950. });
  16951. return this;
  16952. }
  16953. /**
  16954. * Listen for someone joining the channel.
  16955. */
  16956. }, {
  16957. key: 'joining',
  16958. value: function joining(callback) {
  16959. this.on('pusher:member_added', function (member) {
  16960. callback(member.info);
  16961. });
  16962. return this;
  16963. }
  16964. /**
  16965. * Listen for someone leaving the channel.
  16966. */
  16967. }, {
  16968. key: 'leaving',
  16969. value: function leaving(callback) {
  16970. this.on('pusher:member_removed', function (member) {
  16971. callback(member.info);
  16972. });
  16973. return this;
  16974. }
  16975. /**
  16976. * Trigger client event on the channel.
  16977. */
  16978. }, {
  16979. key: 'whisper',
  16980. value: function whisper(eventName, data) {
  16981. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16982. return this;
  16983. }
  16984. }]);
  16985. return PusherPresenceChannel;
  16986. }(PusherChannel);
  16987. /**
  16988. * This class represents a Socket.io channel.
  16989. */
  16990. var SocketIoChannel = function (_Channel) {
  16991. inherits(SocketIoChannel, _Channel);
  16992. /**
  16993. * Create a new class instance.
  16994. */
  16995. function SocketIoChannel(socket, name, options) {
  16996. classCallCheck(this, SocketIoChannel);
  16997. /**
  16998. * The event callbacks applied to the channel.
  16999. */
  17000. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  17001. _this.events = {};
  17002. _this.name = name;
  17003. _this.socket = socket;
  17004. _this.options = options;
  17005. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  17006. _this.subscribe();
  17007. _this.configureReconnector();
  17008. return _this;
  17009. }
  17010. /**
  17011. * Subscribe to a Socket.io channel.
  17012. */
  17013. createClass(SocketIoChannel, [{
  17014. key: 'subscribe',
  17015. value: function subscribe() {
  17016. this.socket.emit('subscribe', {
  17017. channel: this.name,
  17018. auth: this.options.auth || {}
  17019. });
  17020. }
  17021. /**
  17022. * Unsubscribe from channel and ubind event callbacks.
  17023. */
  17024. }, {
  17025. key: 'unsubscribe',
  17026. value: function unsubscribe() {
  17027. this.unbind();
  17028. this.socket.emit('unsubscribe', {
  17029. channel: this.name,
  17030. auth: this.options.auth || {}
  17031. });
  17032. }
  17033. /**
  17034. * Listen for an event on the channel instance.
  17035. */
  17036. }, {
  17037. key: 'listen',
  17038. value: function listen(event, callback) {
  17039. this.on(this.eventFormatter.format(event), callback);
  17040. return this;
  17041. }
  17042. /**
  17043. * Stop listening for an event on the channel instance.
  17044. */
  17045. }, {
  17046. key: 'stopListening',
  17047. value: function stopListening(event) {
  17048. var name = this.eventFormatter.format(event);
  17049. this.socket.removeListener(name);
  17050. delete this.events[name];
  17051. return this;
  17052. }
  17053. /**
  17054. * Bind the channel's socket to an event and store the callback.
  17055. */
  17056. }, {
  17057. key: 'on',
  17058. value: function on(event, callback) {
  17059. var _this2 = this;
  17060. var listener = function listener(channel, data) {
  17061. if (_this2.name == channel) {
  17062. callback(data);
  17063. }
  17064. };
  17065. this.socket.on(event, listener);
  17066. this.bind(event, listener);
  17067. }
  17068. /**
  17069. * Attach a 'reconnect' listener and bind the event.
  17070. */
  17071. }, {
  17072. key: 'configureReconnector',
  17073. value: function configureReconnector() {
  17074. var _this3 = this;
  17075. var listener = function listener() {
  17076. _this3.subscribe();
  17077. };
  17078. this.socket.on('reconnect', listener);
  17079. this.bind('reconnect', listener);
  17080. }
  17081. /**
  17082. * Bind the channel's socket to an event and store the callback.
  17083. */
  17084. }, {
  17085. key: 'bind',
  17086. value: function bind(event, callback) {
  17087. this.events[event] = this.events[event] || [];
  17088. this.events[event].push(callback);
  17089. }
  17090. /**
  17091. * Unbind the channel's socket from all stored event callbacks.
  17092. */
  17093. }, {
  17094. key: 'unbind',
  17095. value: function unbind() {
  17096. var _this4 = this;
  17097. Object.keys(this.events).forEach(function (event) {
  17098. _this4.events[event].forEach(function (callback) {
  17099. _this4.socket.removeListener(event, callback);
  17100. });
  17101. delete _this4.events[event];
  17102. });
  17103. }
  17104. }]);
  17105. return SocketIoChannel;
  17106. }(Channel);
  17107. /**
  17108. * This class represents a Socket.io presence channel.
  17109. */
  17110. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  17111. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  17112. function SocketIoPrivateChannel() {
  17113. classCallCheck(this, SocketIoPrivateChannel);
  17114. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  17115. }
  17116. createClass(SocketIoPrivateChannel, [{
  17117. key: 'whisper',
  17118. /**
  17119. * Trigger client event on the channel.
  17120. */
  17121. value: function whisper(eventName, data) {
  17122. this.socket.emit('client event', {
  17123. channel: this.name,
  17124. event: 'client-' + eventName,
  17125. data: data
  17126. });
  17127. return this;
  17128. }
  17129. }]);
  17130. return SocketIoPrivateChannel;
  17131. }(SocketIoChannel);
  17132. /**
  17133. * This class represents a Socket.io presence channel.
  17134. */
  17135. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  17136. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  17137. function SocketIoPresenceChannel() {
  17138. classCallCheck(this, SocketIoPresenceChannel);
  17139. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  17140. }
  17141. createClass(SocketIoPresenceChannel, [{
  17142. key: 'here',
  17143. /**
  17144. * Register a callback to be called anytime the member list changes.
  17145. */
  17146. value: function here(callback) {
  17147. this.on('presence:subscribed', function (members) {
  17148. callback(members.map(function (m) {
  17149. return m.user_info;
  17150. }));
  17151. });
  17152. return this;
  17153. }
  17154. /**
  17155. * Listen for someone joining the channel.
  17156. */
  17157. }, {
  17158. key: 'joining',
  17159. value: function joining(callback) {
  17160. this.on('presence:joining', function (member) {
  17161. return callback(member.user_info);
  17162. });
  17163. return this;
  17164. }
  17165. /**
  17166. * Listen for someone leaving the channel.
  17167. */
  17168. }, {
  17169. key: 'leaving',
  17170. value: function leaving(callback) {
  17171. this.on('presence:leaving', function (member) {
  17172. return callback(member.user_info);
  17173. });
  17174. return this;
  17175. }
  17176. }]);
  17177. return SocketIoPresenceChannel;
  17178. }(SocketIoPrivateChannel);
  17179. /**
  17180. * This class represents a null channel.
  17181. */
  17182. var NullChannel = function (_Channel) {
  17183. inherits(NullChannel, _Channel);
  17184. function NullChannel() {
  17185. classCallCheck(this, NullChannel);
  17186. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  17187. }
  17188. createClass(NullChannel, [{
  17189. key: 'subscribe',
  17190. /**
  17191. * Subscribe to a channel.
  17192. */
  17193. value: function subscribe() {}
  17194. //
  17195. /**
  17196. * Unsubscribe from a channel.
  17197. */
  17198. }, {
  17199. key: 'unsubscribe',
  17200. value: function unsubscribe() {}
  17201. //
  17202. /**
  17203. * Listen for an event on the channel instance.
  17204. */
  17205. }, {
  17206. key: 'listen',
  17207. value: function listen(event, callback) {
  17208. return this;
  17209. }
  17210. /**
  17211. * Stop listening for an event on the channel instance.
  17212. */
  17213. }, {
  17214. key: 'stopListening',
  17215. value: function stopListening(event) {
  17216. return this;
  17217. }
  17218. /**
  17219. * Bind a channel to an event.
  17220. */
  17221. }, {
  17222. key: 'on',
  17223. value: function on(event, callback) {
  17224. return this;
  17225. }
  17226. }]);
  17227. return NullChannel;
  17228. }(Channel);
  17229. /**
  17230. * This class represents a null private channel.
  17231. */
  17232. var NullPrivateChannel = function (_NullChannel) {
  17233. inherits(NullPrivateChannel, _NullChannel);
  17234. function NullPrivateChannel() {
  17235. classCallCheck(this, NullPrivateChannel);
  17236. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  17237. }
  17238. createClass(NullPrivateChannel, [{
  17239. key: 'whisper',
  17240. /**
  17241. * Trigger client event on the channel.
  17242. */
  17243. value: function whisper(eventName, data) {
  17244. return this;
  17245. }
  17246. }]);
  17247. return NullPrivateChannel;
  17248. }(NullChannel);
  17249. /**
  17250. * This class represents a null presence channel.
  17251. */
  17252. var NullPresenceChannel = function (_NullChannel) {
  17253. inherits(NullPresenceChannel, _NullChannel);
  17254. function NullPresenceChannel() {
  17255. classCallCheck(this, NullPresenceChannel);
  17256. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  17257. }
  17258. createClass(NullPresenceChannel, [{
  17259. key: 'here',
  17260. /**
  17261. * Register a callback to be called anytime the member list changes.
  17262. */
  17263. value: function here(callback) {
  17264. return this;
  17265. }
  17266. /**
  17267. * Listen for someone joining the channel.
  17268. */
  17269. }, {
  17270. key: 'joining',
  17271. value: function joining(callback) {
  17272. return this;
  17273. }
  17274. /**
  17275. * Listen for someone leaving the channel.
  17276. */
  17277. }, {
  17278. key: 'leaving',
  17279. value: function leaving(callback) {
  17280. return this;
  17281. }
  17282. /**
  17283. * Trigger client event on the channel.
  17284. */
  17285. }, {
  17286. key: 'whisper',
  17287. value: function whisper(eventName, data) {
  17288. return this;
  17289. }
  17290. }]);
  17291. return NullPresenceChannel;
  17292. }(NullChannel);
  17293. /**
  17294. * This class creates a connector to Pusher.
  17295. */
  17296. var PusherConnector = function (_Connector) {
  17297. inherits(PusherConnector, _Connector);
  17298. function PusherConnector() {
  17299. classCallCheck(this, PusherConnector);
  17300. /**
  17301. * All of the subscribed channel names.
  17302. */
  17303. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  17304. _this.channels = {};
  17305. return _this;
  17306. }
  17307. /**
  17308. * Create a fresh Pusher connection.
  17309. */
  17310. createClass(PusherConnector, [{
  17311. key: 'connect',
  17312. value: function connect() {
  17313. if (typeof this.options.client !== 'undefined') {
  17314. this.pusher = this.options.client;
  17315. } else {
  17316. this.pusher = new Pusher(this.options.key, this.options);
  17317. }
  17318. }
  17319. /**
  17320. * Listen for an event on a channel instance.
  17321. */
  17322. }, {
  17323. key: 'listen',
  17324. value: function listen(name, event, callback) {
  17325. return this.channel(name).listen(event, callback);
  17326. }
  17327. /**
  17328. * Get a channel instance by name.
  17329. */
  17330. }, {
  17331. key: 'channel',
  17332. value: function channel(name) {
  17333. if (!this.channels[name]) {
  17334. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  17335. }
  17336. return this.channels[name];
  17337. }
  17338. /**
  17339. * Get a private channel instance by name.
  17340. */
  17341. }, {
  17342. key: 'privateChannel',
  17343. value: function privateChannel(name) {
  17344. if (!this.channels['private-' + name]) {
  17345. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  17346. }
  17347. return this.channels['private-' + name];
  17348. }
  17349. /**
  17350. * Get a presence channel instance by name.
  17351. */
  17352. }, {
  17353. key: 'presenceChannel',
  17354. value: function presenceChannel(name) {
  17355. if (!this.channels['presence-' + name]) {
  17356. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  17357. }
  17358. return this.channels['presence-' + name];
  17359. }
  17360. /**
  17361. * Leave the given channel, as well as its private and presence variants.
  17362. */
  17363. }, {
  17364. key: 'leave',
  17365. value: function leave(name) {
  17366. var _this2 = this;
  17367. var channels = [name, 'private-' + name, 'presence-' + name];
  17368. channels.forEach(function (name, index) {
  17369. _this2.leaveChannel(name);
  17370. });
  17371. }
  17372. /**
  17373. * Leave the given channel.
  17374. */
  17375. }, {
  17376. key: 'leaveChannel',
  17377. value: function leaveChannel(name) {
  17378. if (this.channels[name]) {
  17379. this.channels[name].unsubscribe();
  17380. delete this.channels[name];
  17381. }
  17382. }
  17383. /**
  17384. * Get the socket ID for the connection.
  17385. */
  17386. }, {
  17387. key: 'socketId',
  17388. value: function socketId() {
  17389. return this.pusher.connection.socket_id;
  17390. }
  17391. /**
  17392. * Disconnect Pusher connection.
  17393. */
  17394. }, {
  17395. key: 'disconnect',
  17396. value: function disconnect() {
  17397. this.pusher.disconnect();
  17398. }
  17399. }]);
  17400. return PusherConnector;
  17401. }(Connector);
  17402. /**
  17403. * This class creates a connnector to a Socket.io server.
  17404. */
  17405. var SocketIoConnector = function (_Connector) {
  17406. inherits(SocketIoConnector, _Connector);
  17407. function SocketIoConnector() {
  17408. classCallCheck(this, SocketIoConnector);
  17409. /**
  17410. * All of the subscribed channel names.
  17411. */
  17412. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  17413. _this.channels = {};
  17414. return _this;
  17415. }
  17416. /**
  17417. * Create a fresh Socket.io connection.
  17418. */
  17419. createClass(SocketIoConnector, [{
  17420. key: 'connect',
  17421. value: function connect() {
  17422. var io = this.getSocketIO();
  17423. this.socket = io(this.options.host, this.options);
  17424. return this.socket;
  17425. }
  17426. /**
  17427. * Get socket.io module from global scope or options.
  17428. */
  17429. }, {
  17430. key: 'getSocketIO',
  17431. value: function getSocketIO() {
  17432. if (typeof this.options.client !== 'undefined') {
  17433. return this.options.client;
  17434. }
  17435. if (typeof io !== 'undefined') {
  17436. return io;
  17437. }
  17438. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  17439. }
  17440. /**
  17441. * Listen for an event on a channel instance.
  17442. */
  17443. }, {
  17444. key: 'listen',
  17445. value: function listen(name, event, callback) {
  17446. return this.channel(name).listen(event, callback);
  17447. }
  17448. /**
  17449. * Get a channel instance by name.
  17450. */
  17451. }, {
  17452. key: 'channel',
  17453. value: function channel(name) {
  17454. if (!this.channels[name]) {
  17455. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  17456. }
  17457. return this.channels[name];
  17458. }
  17459. /**
  17460. * Get a private channel instance by name.
  17461. */
  17462. }, {
  17463. key: 'privateChannel',
  17464. value: function privateChannel(name) {
  17465. if (!this.channels['private-' + name]) {
  17466. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  17467. }
  17468. return this.channels['private-' + name];
  17469. }
  17470. /**
  17471. * Get a presence channel instance by name.
  17472. */
  17473. }, {
  17474. key: 'presenceChannel',
  17475. value: function presenceChannel(name) {
  17476. if (!this.channels['presence-' + name]) {
  17477. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  17478. }
  17479. return this.channels['presence-' + name];
  17480. }
  17481. /**
  17482. * Leave the given channel, as well as its private and presence variants.
  17483. */
  17484. }, {
  17485. key: 'leave',
  17486. value: function leave(name) {
  17487. var _this2 = this;
  17488. var channels = [name, 'private-' + name, 'presence-' + name];
  17489. channels.forEach(function (name) {
  17490. _this2.leaveChannel(name);
  17491. });
  17492. }
  17493. /**
  17494. * Leave the given channel.
  17495. */
  17496. }, {
  17497. key: 'leaveChannel',
  17498. value: function leaveChannel(name) {
  17499. if (this.channels[name]) {
  17500. this.channels[name].unsubscribe();
  17501. delete this.channels[name];
  17502. }
  17503. }
  17504. /**
  17505. * Get the socket ID for the connection.
  17506. */
  17507. }, {
  17508. key: 'socketId',
  17509. value: function socketId() {
  17510. return this.socket.id;
  17511. }
  17512. /**
  17513. * Disconnect Socketio connection.
  17514. */
  17515. }, {
  17516. key: 'disconnect',
  17517. value: function disconnect() {
  17518. this.socket.disconnect();
  17519. }
  17520. }]);
  17521. return SocketIoConnector;
  17522. }(Connector);
  17523. /**
  17524. * This class creates a null connector.
  17525. */
  17526. var NullConnector = function (_Connector) {
  17527. inherits(NullConnector, _Connector);
  17528. function NullConnector() {
  17529. classCallCheck(this, NullConnector);
  17530. /**
  17531. * All of the subscribed channel names.
  17532. */
  17533. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  17534. _this.channels = {};
  17535. return _this;
  17536. }
  17537. /**
  17538. * Create a fresh connection.
  17539. */
  17540. createClass(NullConnector, [{
  17541. key: 'connect',
  17542. value: function connect() {}
  17543. //
  17544. /**
  17545. * Listen for an event on a channel instance.
  17546. */
  17547. }, {
  17548. key: 'listen',
  17549. value: function listen(name, event, callback) {
  17550. return new NullChannel();
  17551. }
  17552. /**
  17553. * Get a channel instance by name.
  17554. */
  17555. }, {
  17556. key: 'channel',
  17557. value: function channel(name) {
  17558. return new NullChannel();
  17559. }
  17560. /**
  17561. * Get a private channel instance by name.
  17562. */
  17563. }, {
  17564. key: 'privateChannel',
  17565. value: function privateChannel(name) {
  17566. return new NullPrivateChannel();
  17567. }
  17568. /**
  17569. * Get a presence channel instance by name.
  17570. */
  17571. }, {
  17572. key: 'presenceChannel',
  17573. value: function presenceChannel(name) {
  17574. return new NullPresenceChannel();
  17575. }
  17576. /**
  17577. * Leave the given channel, as well as its private and presence variants.
  17578. */
  17579. }, {
  17580. key: 'leave',
  17581. value: function leave(name) {}
  17582. //
  17583. /**
  17584. * Leave the given channel.
  17585. */
  17586. }, {
  17587. key: 'leaveChannel',
  17588. value: function leaveChannel(name) {}
  17589. //
  17590. /**
  17591. * Get the socket ID for the connection.
  17592. */
  17593. }, {
  17594. key: 'socketId',
  17595. value: function socketId() {
  17596. return 'fake-socket-id';
  17597. }
  17598. /**
  17599. * Disconnect the connection.
  17600. */
  17601. }, {
  17602. key: 'disconnect',
  17603. value: function disconnect() {
  17604. //
  17605. }
  17606. }]);
  17607. return NullConnector;
  17608. }(Connector);
  17609. /**
  17610. * This class is the primary API for interacting with broadcasting.
  17611. */
  17612. var Echo = function () {
  17613. /**
  17614. * Create a new class instance.
  17615. */
  17616. function Echo(options) {
  17617. classCallCheck(this, Echo);
  17618. this.options = options;
  17619. this.connect();
  17620. if (!this.options.withoutInterceptors) {
  17621. this.registerInterceptors();
  17622. }
  17623. }
  17624. /**
  17625. * Get a channel instance by name.
  17626. */
  17627. createClass(Echo, [{
  17628. key: 'channel',
  17629. value: function channel(_channel) {
  17630. return this.connector.channel(_channel);
  17631. }
  17632. /**
  17633. * Create a new connection.
  17634. */
  17635. }, {
  17636. key: 'connect',
  17637. value: function connect() {
  17638. if (this.options.broadcaster == 'pusher') {
  17639. this.connector = new PusherConnector(this.options);
  17640. } else if (this.options.broadcaster == 'socket.io') {
  17641. this.connector = new SocketIoConnector(this.options);
  17642. } else if (this.options.broadcaster == 'null') {
  17643. this.connector = new NullConnector(this.options);
  17644. } else if (typeof this.options.broadcaster == 'function') {
  17645. this.connector = new this.options.broadcaster(this.options);
  17646. }
  17647. }
  17648. /**
  17649. * Disconnect from the Echo server.
  17650. */
  17651. }, {
  17652. key: 'disconnect',
  17653. value: function disconnect() {
  17654. this.connector.disconnect();
  17655. }
  17656. /**
  17657. * Get a presence channel instance by name.
  17658. */
  17659. }, {
  17660. key: 'join',
  17661. value: function join(channel) {
  17662. return this.connector.presenceChannel(channel);
  17663. }
  17664. /**
  17665. * Leave the given channel, as well as its private and presence variants.
  17666. */
  17667. }, {
  17668. key: 'leave',
  17669. value: function leave(channel) {
  17670. this.connector.leave(channel);
  17671. }
  17672. /**
  17673. * Leave the given channel.
  17674. */
  17675. }, {
  17676. key: 'leaveChannel',
  17677. value: function leaveChannel(channel) {
  17678. this.connector.leaveChannel(channel);
  17679. }
  17680. /**
  17681. * Listen for an event on a channel instance.
  17682. */
  17683. }, {
  17684. key: 'listen',
  17685. value: function listen(channel, event, callback) {
  17686. return this.connector.listen(channel, event, callback);
  17687. }
  17688. /**
  17689. * Get a private channel instance by name.
  17690. */
  17691. }, {
  17692. key: 'private',
  17693. value: function _private(channel) {
  17694. return this.connector.privateChannel(channel);
  17695. }
  17696. /**
  17697. * Get the Socket ID for the connection.
  17698. */
  17699. }, {
  17700. key: 'socketId',
  17701. value: function socketId() {
  17702. return this.connector.socketId();
  17703. }
  17704. /**
  17705. * Register 3rd party request interceptiors. These are used to automatically
  17706. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  17707. */
  17708. }, {
  17709. key: 'registerInterceptors',
  17710. value: function registerInterceptors() {
  17711. if (typeof Vue === 'function' && Vue.http) {
  17712. this.registerVueRequestInterceptor();
  17713. }
  17714. if (typeof axios === 'function') {
  17715. this.registerAxiosRequestInterceptor();
  17716. }
  17717. if (typeof jQuery === 'function') {
  17718. this.registerjQueryAjaxSetup();
  17719. }
  17720. }
  17721. /**
  17722. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  17723. */
  17724. }, {
  17725. key: 'registerVueRequestInterceptor',
  17726. value: function registerVueRequestInterceptor() {
  17727. var _this = this;
  17728. Vue.http.interceptors.push(function (request, next) {
  17729. if (_this.socketId()) {
  17730. request.headers.set('X-Socket-ID', _this.socketId());
  17731. }
  17732. next();
  17733. });
  17734. }
  17735. /**
  17736. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  17737. */
  17738. }, {
  17739. key: 'registerAxiosRequestInterceptor',
  17740. value: function registerAxiosRequestInterceptor() {
  17741. var _this2 = this;
  17742. axios.interceptors.request.use(function (config) {
  17743. if (_this2.socketId()) {
  17744. config.headers['X-Socket-Id'] = _this2.socketId();
  17745. }
  17746. return config;
  17747. });
  17748. }
  17749. /**
  17750. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  17751. */
  17752. }, {
  17753. key: 'registerjQueryAjaxSetup',
  17754. value: function registerjQueryAjaxSetup() {
  17755. var _this3 = this;
  17756. if (typeof jQuery.ajax != 'undefined') {
  17757. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  17758. if (_this3.socketId()) {
  17759. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  17760. }
  17761. });
  17762. }
  17763. }
  17764. }]);
  17765. return Echo;
  17766. }();
  17767. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  17768. /***/ }),
  17769. /***/ "./node_modules/lodash/lodash.js":
  17770. /*!***************************************!*\
  17771. !*** ./node_modules/lodash/lodash.js ***!
  17772. \***************************************/
  17773. /*! no static exports found */
  17774. /***/ (function(module, exports, __webpack_require__) {
  17775. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  17776. * @license
  17777. * Lodash <https://lodash.com/>
  17778. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  17779. * Released under MIT license <https://lodash.com/license>
  17780. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  17781. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  17782. */
  17783. ;(function() {
  17784. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  17785. var undefined;
  17786. /** Used as the semantic version number. */
  17787. var VERSION = '4.17.15';
  17788. /** Used as the size to enable large array optimizations. */
  17789. var LARGE_ARRAY_SIZE = 200;
  17790. /** Error message constants. */
  17791. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  17792. FUNC_ERROR_TEXT = 'Expected a function';
  17793. /** Used to stand-in for `undefined` hash values. */
  17794. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  17795. /** Used as the maximum memoize cache size. */
  17796. var MAX_MEMOIZE_SIZE = 500;
  17797. /** Used as the internal argument placeholder. */
  17798. var PLACEHOLDER = '__lodash_placeholder__';
  17799. /** Used to compose bitmasks for cloning. */
  17800. var CLONE_DEEP_FLAG = 1,
  17801. CLONE_FLAT_FLAG = 2,
  17802. CLONE_SYMBOLS_FLAG = 4;
  17803. /** Used to compose bitmasks for value comparisons. */
  17804. var COMPARE_PARTIAL_FLAG = 1,
  17805. COMPARE_UNORDERED_FLAG = 2;
  17806. /** Used to compose bitmasks for function metadata. */
  17807. var WRAP_BIND_FLAG = 1,
  17808. WRAP_BIND_KEY_FLAG = 2,
  17809. WRAP_CURRY_BOUND_FLAG = 4,
  17810. WRAP_CURRY_FLAG = 8,
  17811. WRAP_CURRY_RIGHT_FLAG = 16,
  17812. WRAP_PARTIAL_FLAG = 32,
  17813. WRAP_PARTIAL_RIGHT_FLAG = 64,
  17814. WRAP_ARY_FLAG = 128,
  17815. WRAP_REARG_FLAG = 256,
  17816. WRAP_FLIP_FLAG = 512;
  17817. /** Used as default options for `_.truncate`. */
  17818. var DEFAULT_TRUNC_LENGTH = 30,
  17819. DEFAULT_TRUNC_OMISSION = '...';
  17820. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  17821. var HOT_COUNT = 800,
  17822. HOT_SPAN = 16;
  17823. /** Used to indicate the type of lazy iteratees. */
  17824. var LAZY_FILTER_FLAG = 1,
  17825. LAZY_MAP_FLAG = 2,
  17826. LAZY_WHILE_FLAG = 3;
  17827. /** Used as references for various `Number` constants. */
  17828. var INFINITY = 1 / 0,
  17829. MAX_SAFE_INTEGER = 9007199254740991,
  17830. MAX_INTEGER = 1.7976931348623157e+308,
  17831. NAN = 0 / 0;
  17832. /** Used as references for the maximum length and index of an array. */
  17833. var MAX_ARRAY_LENGTH = 4294967295,
  17834. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  17835. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  17836. /** Used to associate wrap methods with their bit flags. */
  17837. var wrapFlags = [
  17838. ['ary', WRAP_ARY_FLAG],
  17839. ['bind', WRAP_BIND_FLAG],
  17840. ['bindKey', WRAP_BIND_KEY_FLAG],
  17841. ['curry', WRAP_CURRY_FLAG],
  17842. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  17843. ['flip', WRAP_FLIP_FLAG],
  17844. ['partial', WRAP_PARTIAL_FLAG],
  17845. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  17846. ['rearg', WRAP_REARG_FLAG]
  17847. ];
  17848. /** `Object#toString` result references. */
  17849. var argsTag = '[object Arguments]',
  17850. arrayTag = '[object Array]',
  17851. asyncTag = '[object AsyncFunction]',
  17852. boolTag = '[object Boolean]',
  17853. dateTag = '[object Date]',
  17854. domExcTag = '[object DOMException]',
  17855. errorTag = '[object Error]',
  17856. funcTag = '[object Function]',
  17857. genTag = '[object GeneratorFunction]',
  17858. mapTag = '[object Map]',
  17859. numberTag = '[object Number]',
  17860. nullTag = '[object Null]',
  17861. objectTag = '[object Object]',
  17862. promiseTag = '[object Promise]',
  17863. proxyTag = '[object Proxy]',
  17864. regexpTag = '[object RegExp]',
  17865. setTag = '[object Set]',
  17866. stringTag = '[object String]',
  17867. symbolTag = '[object Symbol]',
  17868. undefinedTag = '[object Undefined]',
  17869. weakMapTag = '[object WeakMap]',
  17870. weakSetTag = '[object WeakSet]';
  17871. var arrayBufferTag = '[object ArrayBuffer]',
  17872. dataViewTag = '[object DataView]',
  17873. float32Tag = '[object Float32Array]',
  17874. float64Tag = '[object Float64Array]',
  17875. int8Tag = '[object Int8Array]',
  17876. int16Tag = '[object Int16Array]',
  17877. int32Tag = '[object Int32Array]',
  17878. uint8Tag = '[object Uint8Array]',
  17879. uint8ClampedTag = '[object Uint8ClampedArray]',
  17880. uint16Tag = '[object Uint16Array]',
  17881. uint32Tag = '[object Uint32Array]';
  17882. /** Used to match empty string literals in compiled template source. */
  17883. var reEmptyStringLeading = /\b__p \+= '';/g,
  17884. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  17885. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  17886. /** Used to match HTML entities and HTML characters. */
  17887. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  17888. reUnescapedHtml = /[&<>"']/g,
  17889. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  17890. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  17891. /** Used to match template delimiters. */
  17892. var reEscape = /<%-([\s\S]+?)%>/g,
  17893. reEvaluate = /<%([\s\S]+?)%>/g,
  17894. reInterpolate = /<%=([\s\S]+?)%>/g;
  17895. /** Used to match property names within property paths. */
  17896. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  17897. reIsPlainProp = /^\w*$/,
  17898. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  17899. /**
  17900. * Used to match `RegExp`
  17901. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  17902. */
  17903. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  17904. reHasRegExpChar = RegExp(reRegExpChar.source);
  17905. /** Used to match leading and trailing whitespace. */
  17906. var reTrim = /^\s+|\s+$/g,
  17907. reTrimStart = /^\s+/,
  17908. reTrimEnd = /\s+$/;
  17909. /** Used to match wrap detail comments. */
  17910. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  17911. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  17912. reSplitDetails = /,? & /;
  17913. /** Used to match words composed of alphanumeric characters. */
  17914. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  17915. /** Used to match backslashes in property paths. */
  17916. var reEscapeChar = /\\(\\)?/g;
  17917. /**
  17918. * Used to match
  17919. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  17920. */
  17921. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  17922. /** Used to match `RegExp` flags from their coerced string values. */
  17923. var reFlags = /\w*$/;
  17924. /** Used to detect bad signed hexadecimal string values. */
  17925. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  17926. /** Used to detect binary string values. */
  17927. var reIsBinary = /^0b[01]+$/i;
  17928. /** Used to detect host constructors (Safari). */
  17929. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  17930. /** Used to detect octal string values. */
  17931. var reIsOctal = /^0o[0-7]+$/i;
  17932. /** Used to detect unsigned integer values. */
  17933. var reIsUint = /^(?:0|[1-9]\d*)$/;
  17934. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  17935. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  17936. /** Used to ensure capturing order of template delimiters. */
  17937. var reNoMatch = /($^)/;
  17938. /** Used to match unescaped characters in compiled string literals. */
  17939. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  17940. /** Used to compose unicode character classes. */
  17941. var rsAstralRange = '\\ud800-\\udfff',
  17942. rsComboMarksRange = '\\u0300-\\u036f',
  17943. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  17944. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  17945. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  17946. rsDingbatRange = '\\u2700-\\u27bf',
  17947. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  17948. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  17949. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  17950. rsPunctuationRange = '\\u2000-\\u206f',
  17951. 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',
  17952. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  17953. rsVarRange = '\\ufe0e\\ufe0f',
  17954. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  17955. /** Used to compose unicode capture groups. */
  17956. var rsApos = "['\u2019]",
  17957. rsAstral = '[' + rsAstralRange + ']',
  17958. rsBreak = '[' + rsBreakRange + ']',
  17959. rsCombo = '[' + rsComboRange + ']',
  17960. rsDigits = '\\d+',
  17961. rsDingbat = '[' + rsDingbatRange + ']',
  17962. rsLower = '[' + rsLowerRange + ']',
  17963. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  17964. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  17965. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  17966. rsNonAstral = '[^' + rsAstralRange + ']',
  17967. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  17968. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  17969. rsUpper = '[' + rsUpperRange + ']',
  17970. rsZWJ = '\\u200d';
  17971. /** Used to compose unicode regexes. */
  17972. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  17973. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  17974. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  17975. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  17976. reOptMod = rsModifier + '?',
  17977. rsOptVar = '[' + rsVarRange + ']?',
  17978. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  17979. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  17980. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  17981. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  17982. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  17983. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  17984. /** Used to match apostrophes. */
  17985. var reApos = RegExp(rsApos, 'g');
  17986. /**
  17987. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  17988. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  17989. */
  17990. var reComboMark = RegExp(rsCombo, 'g');
  17991. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  17992. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  17993. /** Used to match complex or compound words. */
  17994. var reUnicodeWord = RegExp([
  17995. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  17996. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  17997. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  17998. rsUpper + '+' + rsOptContrUpper,
  17999. rsOrdUpper,
  18000. rsOrdLower,
  18001. rsDigits,
  18002. rsEmoji
  18003. ].join('|'), 'g');
  18004. /** 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/). */
  18005. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  18006. /** Used to detect strings that need a more robust regexp to match words. */
  18007. 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 ]/;
  18008. /** Used to assign default `context` object properties. */
  18009. var contextProps = [
  18010. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  18011. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  18012. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  18013. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  18014. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  18015. ];
  18016. /** Used to make template sourceURLs easier to identify. */
  18017. var templateCounter = -1;
  18018. /** Used to identify `toStringTag` values of typed arrays. */
  18019. var typedArrayTags = {};
  18020. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  18021. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  18022. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  18023. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  18024. typedArrayTags[uint32Tag] = true;
  18025. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  18026. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  18027. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  18028. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  18029. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  18030. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  18031. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  18032. typedArrayTags[weakMapTag] = false;
  18033. /** Used to identify `toStringTag` values supported by `_.clone`. */
  18034. var cloneableTags = {};
  18035. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  18036. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  18037. cloneableTags[boolTag] = cloneableTags[dateTag] =
  18038. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  18039. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  18040. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  18041. cloneableTags[numberTag] = cloneableTags[objectTag] =
  18042. cloneableTags[regexpTag] = cloneableTags[setTag] =
  18043. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  18044. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  18045. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  18046. cloneableTags[errorTag] = cloneableTags[funcTag] =
  18047. cloneableTags[weakMapTag] = false;
  18048. /** Used to map Latin Unicode letters to basic Latin letters. */
  18049. var deburredLetters = {
  18050. // Latin-1 Supplement block.
  18051. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  18052. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  18053. '\xc7': 'C', '\xe7': 'c',
  18054. '\xd0': 'D', '\xf0': 'd',
  18055. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  18056. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  18057. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  18058. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  18059. '\xd1': 'N', '\xf1': 'n',
  18060. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  18061. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  18062. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  18063. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  18064. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  18065. '\xc6': 'Ae', '\xe6': 'ae',
  18066. '\xde': 'Th', '\xfe': 'th',
  18067. '\xdf': 'ss',
  18068. // Latin Extended-A block.
  18069. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  18070. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  18071. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  18072. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  18073. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  18074. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  18075. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  18076. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  18077. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  18078. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  18079. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  18080. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  18081. '\u0134': 'J', '\u0135': 'j',
  18082. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  18083. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  18084. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  18085. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  18086. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  18087. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  18088. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  18089. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  18090. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  18091. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  18092. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  18093. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  18094. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  18095. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  18096. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  18097. '\u0174': 'W', '\u0175': 'w',
  18098. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  18099. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  18100. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  18101. '\u0132': 'IJ', '\u0133': 'ij',
  18102. '\u0152': 'Oe', '\u0153': 'oe',
  18103. '\u0149': "'n", '\u017f': 's'
  18104. };
  18105. /** Used to map characters to HTML entities. */
  18106. var htmlEscapes = {
  18107. '&': '&amp;',
  18108. '<': '&lt;',
  18109. '>': '&gt;',
  18110. '"': '&quot;',
  18111. "'": '&#39;'
  18112. };
  18113. /** Used to map HTML entities to characters. */
  18114. var htmlUnescapes = {
  18115. '&amp;': '&',
  18116. '&lt;': '<',
  18117. '&gt;': '>',
  18118. '&quot;': '"',
  18119. '&#39;': "'"
  18120. };
  18121. /** Used to escape characters for inclusion in compiled string literals. */
  18122. var stringEscapes = {
  18123. '\\': '\\',
  18124. "'": "'",
  18125. '\n': 'n',
  18126. '\r': 'r',
  18127. '\u2028': 'u2028',
  18128. '\u2029': 'u2029'
  18129. };
  18130. /** Built-in method references without a dependency on `root`. */
  18131. var freeParseFloat = parseFloat,
  18132. freeParseInt = parseInt;
  18133. /** Detect free variable `global` from Node.js. */
  18134. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  18135. /** Detect free variable `self`. */
  18136. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  18137. /** Used as a reference to the global object. */
  18138. var root = freeGlobal || freeSelf || Function('return this')();
  18139. /** Detect free variable `exports`. */
  18140. var freeExports = true && exports && !exports.nodeType && exports;
  18141. /** Detect free variable `module`. */
  18142. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  18143. /** Detect the popular CommonJS extension `module.exports`. */
  18144. var moduleExports = freeModule && freeModule.exports === freeExports;
  18145. /** Detect free variable `process` from Node.js. */
  18146. var freeProcess = moduleExports && freeGlobal.process;
  18147. /** Used to access faster Node.js helpers. */
  18148. var nodeUtil = (function() {
  18149. try {
  18150. // Use `util.types` for Node.js 10+.
  18151. var types = freeModule && freeModule.require && freeModule.require('util').types;
  18152. if (types) {
  18153. return types;
  18154. }
  18155. // Legacy `process.binding('util')` for Node.js < 10.
  18156. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  18157. } catch (e) {}
  18158. }());
  18159. /* Node.js helper references. */
  18160. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  18161. nodeIsDate = nodeUtil && nodeUtil.isDate,
  18162. nodeIsMap = nodeUtil && nodeUtil.isMap,
  18163. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  18164. nodeIsSet = nodeUtil && nodeUtil.isSet,
  18165. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  18166. /*--------------------------------------------------------------------------*/
  18167. /**
  18168. * A faster alternative to `Function#apply`, this function invokes `func`
  18169. * with the `this` binding of `thisArg` and the arguments of `args`.
  18170. *
  18171. * @private
  18172. * @param {Function} func The function to invoke.
  18173. * @param {*} thisArg The `this` binding of `func`.
  18174. * @param {Array} args The arguments to invoke `func` with.
  18175. * @returns {*} Returns the result of `func`.
  18176. */
  18177. function apply(func, thisArg, args) {
  18178. switch (args.length) {
  18179. case 0: return func.call(thisArg);
  18180. case 1: return func.call(thisArg, args[0]);
  18181. case 2: return func.call(thisArg, args[0], args[1]);
  18182. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  18183. }
  18184. return func.apply(thisArg, args);
  18185. }
  18186. /**
  18187. * A specialized version of `baseAggregator` for arrays.
  18188. *
  18189. * @private
  18190. * @param {Array} [array] The array to iterate over.
  18191. * @param {Function} setter The function to set `accumulator` values.
  18192. * @param {Function} iteratee The iteratee to transform keys.
  18193. * @param {Object} accumulator The initial aggregated object.
  18194. * @returns {Function} Returns `accumulator`.
  18195. */
  18196. function arrayAggregator(array, setter, iteratee, accumulator) {
  18197. var index = -1,
  18198. length = array == null ? 0 : array.length;
  18199. while (++index < length) {
  18200. var value = array[index];
  18201. setter(accumulator, value, iteratee(value), array);
  18202. }
  18203. return accumulator;
  18204. }
  18205. /**
  18206. * A specialized version of `_.forEach` for arrays without support for
  18207. * iteratee shorthands.
  18208. *
  18209. * @private
  18210. * @param {Array} [array] The array to iterate over.
  18211. * @param {Function} iteratee The function invoked per iteration.
  18212. * @returns {Array} Returns `array`.
  18213. */
  18214. function arrayEach(array, iteratee) {
  18215. var index = -1,
  18216. length = array == null ? 0 : array.length;
  18217. while (++index < length) {
  18218. if (iteratee(array[index], index, array) === false) {
  18219. break;
  18220. }
  18221. }
  18222. return array;
  18223. }
  18224. /**
  18225. * A specialized version of `_.forEachRight` for arrays without support for
  18226. * iteratee shorthands.
  18227. *
  18228. * @private
  18229. * @param {Array} [array] The array to iterate over.
  18230. * @param {Function} iteratee The function invoked per iteration.
  18231. * @returns {Array} Returns `array`.
  18232. */
  18233. function arrayEachRight(array, iteratee) {
  18234. var length = array == null ? 0 : array.length;
  18235. while (length--) {
  18236. if (iteratee(array[length], length, array) === false) {
  18237. break;
  18238. }
  18239. }
  18240. return array;
  18241. }
  18242. /**
  18243. * A specialized version of `_.every` for arrays without support for
  18244. * iteratee shorthands.
  18245. *
  18246. * @private
  18247. * @param {Array} [array] The array to iterate over.
  18248. * @param {Function} predicate The function invoked per iteration.
  18249. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  18250. * else `false`.
  18251. */
  18252. function arrayEvery(array, predicate) {
  18253. var index = -1,
  18254. length = array == null ? 0 : array.length;
  18255. while (++index < length) {
  18256. if (!predicate(array[index], index, array)) {
  18257. return false;
  18258. }
  18259. }
  18260. return true;
  18261. }
  18262. /**
  18263. * A specialized version of `_.filter` for arrays without support for
  18264. * iteratee shorthands.
  18265. *
  18266. * @private
  18267. * @param {Array} [array] The array to iterate over.
  18268. * @param {Function} predicate The function invoked per iteration.
  18269. * @returns {Array} Returns the new filtered array.
  18270. */
  18271. function arrayFilter(array, predicate) {
  18272. var index = -1,
  18273. length = array == null ? 0 : array.length,
  18274. resIndex = 0,
  18275. result = [];
  18276. while (++index < length) {
  18277. var value = array[index];
  18278. if (predicate(value, index, array)) {
  18279. result[resIndex++] = value;
  18280. }
  18281. }
  18282. return result;
  18283. }
  18284. /**
  18285. * A specialized version of `_.includes` for arrays without support for
  18286. * specifying an index to search from.
  18287. *
  18288. * @private
  18289. * @param {Array} [array] The array to inspect.
  18290. * @param {*} target The value to search for.
  18291. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18292. */
  18293. function arrayIncludes(array, value) {
  18294. var length = array == null ? 0 : array.length;
  18295. return !!length && baseIndexOf(array, value, 0) > -1;
  18296. }
  18297. /**
  18298. * This function is like `arrayIncludes` except that it accepts a comparator.
  18299. *
  18300. * @private
  18301. * @param {Array} [array] The array to inspect.
  18302. * @param {*} target The value to search for.
  18303. * @param {Function} comparator The comparator invoked per element.
  18304. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18305. */
  18306. function arrayIncludesWith(array, value, comparator) {
  18307. var index = -1,
  18308. length = array == null ? 0 : array.length;
  18309. while (++index < length) {
  18310. if (comparator(value, array[index])) {
  18311. return true;
  18312. }
  18313. }
  18314. return false;
  18315. }
  18316. /**
  18317. * A specialized version of `_.map` for arrays without support for iteratee
  18318. * shorthands.
  18319. *
  18320. * @private
  18321. * @param {Array} [array] The array to iterate over.
  18322. * @param {Function} iteratee The function invoked per iteration.
  18323. * @returns {Array} Returns the new mapped array.
  18324. */
  18325. function arrayMap(array, iteratee) {
  18326. var index = -1,
  18327. length = array == null ? 0 : array.length,
  18328. result = Array(length);
  18329. while (++index < length) {
  18330. result[index] = iteratee(array[index], index, array);
  18331. }
  18332. return result;
  18333. }
  18334. /**
  18335. * Appends the elements of `values` to `array`.
  18336. *
  18337. * @private
  18338. * @param {Array} array The array to modify.
  18339. * @param {Array} values The values to append.
  18340. * @returns {Array} Returns `array`.
  18341. */
  18342. function arrayPush(array, values) {
  18343. var index = -1,
  18344. length = values.length,
  18345. offset = array.length;
  18346. while (++index < length) {
  18347. array[offset + index] = values[index];
  18348. }
  18349. return array;
  18350. }
  18351. /**
  18352. * A specialized version of `_.reduce` for arrays without support for
  18353. * iteratee shorthands.
  18354. *
  18355. * @private
  18356. * @param {Array} [array] The array to iterate over.
  18357. * @param {Function} iteratee The function invoked per iteration.
  18358. * @param {*} [accumulator] The initial value.
  18359. * @param {boolean} [initAccum] Specify using the first element of `array` as
  18360. * the initial value.
  18361. * @returns {*} Returns the accumulated value.
  18362. */
  18363. function arrayReduce(array, iteratee, accumulator, initAccum) {
  18364. var index = -1,
  18365. length = array == null ? 0 : array.length;
  18366. if (initAccum && length) {
  18367. accumulator = array[++index];
  18368. }
  18369. while (++index < length) {
  18370. accumulator = iteratee(accumulator, array[index], index, array);
  18371. }
  18372. return accumulator;
  18373. }
  18374. /**
  18375. * A specialized version of `_.reduceRight` for arrays without support for
  18376. * iteratee shorthands.
  18377. *
  18378. * @private
  18379. * @param {Array} [array] The array to iterate over.
  18380. * @param {Function} iteratee The function invoked per iteration.
  18381. * @param {*} [accumulator] The initial value.
  18382. * @param {boolean} [initAccum] Specify using the last element of `array` as
  18383. * the initial value.
  18384. * @returns {*} Returns the accumulated value.
  18385. */
  18386. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  18387. var length = array == null ? 0 : array.length;
  18388. if (initAccum && length) {
  18389. accumulator = array[--length];
  18390. }
  18391. while (length--) {
  18392. accumulator = iteratee(accumulator, array[length], length, array);
  18393. }
  18394. return accumulator;
  18395. }
  18396. /**
  18397. * A specialized version of `_.some` for arrays without support for iteratee
  18398. * shorthands.
  18399. *
  18400. * @private
  18401. * @param {Array} [array] The array to iterate over.
  18402. * @param {Function} predicate The function invoked per iteration.
  18403. * @returns {boolean} Returns `true` if any element passes the predicate check,
  18404. * else `false`.
  18405. */
  18406. function arraySome(array, predicate) {
  18407. var index = -1,
  18408. length = array == null ? 0 : array.length;
  18409. while (++index < length) {
  18410. if (predicate(array[index], index, array)) {
  18411. return true;
  18412. }
  18413. }
  18414. return false;
  18415. }
  18416. /**
  18417. * Gets the size of an ASCII `string`.
  18418. *
  18419. * @private
  18420. * @param {string} string The string inspect.
  18421. * @returns {number} Returns the string size.
  18422. */
  18423. var asciiSize = baseProperty('length');
  18424. /**
  18425. * Converts an ASCII `string` to an array.
  18426. *
  18427. * @private
  18428. * @param {string} string The string to convert.
  18429. * @returns {Array} Returns the converted array.
  18430. */
  18431. function asciiToArray(string) {
  18432. return string.split('');
  18433. }
  18434. /**
  18435. * Splits an ASCII `string` into an array of its words.
  18436. *
  18437. * @private
  18438. * @param {string} The string to inspect.
  18439. * @returns {Array} Returns the words of `string`.
  18440. */
  18441. function asciiWords(string) {
  18442. return string.match(reAsciiWord) || [];
  18443. }
  18444. /**
  18445. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  18446. * without support for iteratee shorthands, which iterates over `collection`
  18447. * using `eachFunc`.
  18448. *
  18449. * @private
  18450. * @param {Array|Object} collection The collection to inspect.
  18451. * @param {Function} predicate The function invoked per iteration.
  18452. * @param {Function} eachFunc The function to iterate over `collection`.
  18453. * @returns {*} Returns the found element or its key, else `undefined`.
  18454. */
  18455. function baseFindKey(collection, predicate, eachFunc) {
  18456. var result;
  18457. eachFunc(collection, function(value, key, collection) {
  18458. if (predicate(value, key, collection)) {
  18459. result = key;
  18460. return false;
  18461. }
  18462. });
  18463. return result;
  18464. }
  18465. /**
  18466. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  18467. * support for iteratee shorthands.
  18468. *
  18469. * @private
  18470. * @param {Array} array The array to inspect.
  18471. * @param {Function} predicate The function invoked per iteration.
  18472. * @param {number} fromIndex The index to search from.
  18473. * @param {boolean} [fromRight] Specify iterating from right to left.
  18474. * @returns {number} Returns the index of the matched value, else `-1`.
  18475. */
  18476. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  18477. var length = array.length,
  18478. index = fromIndex + (fromRight ? 1 : -1);
  18479. while ((fromRight ? index-- : ++index < length)) {
  18480. if (predicate(array[index], index, array)) {
  18481. return index;
  18482. }
  18483. }
  18484. return -1;
  18485. }
  18486. /**
  18487. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  18488. *
  18489. * @private
  18490. * @param {Array} array The array to inspect.
  18491. * @param {*} value The value to search for.
  18492. * @param {number} fromIndex The index to search from.
  18493. * @returns {number} Returns the index of the matched value, else `-1`.
  18494. */
  18495. function baseIndexOf(array, value, fromIndex) {
  18496. return value === value
  18497. ? strictIndexOf(array, value, fromIndex)
  18498. : baseFindIndex(array, baseIsNaN, fromIndex);
  18499. }
  18500. /**
  18501. * This function is like `baseIndexOf` except that it accepts a comparator.
  18502. *
  18503. * @private
  18504. * @param {Array} array The array to inspect.
  18505. * @param {*} value The value to search for.
  18506. * @param {number} fromIndex The index to search from.
  18507. * @param {Function} comparator The comparator invoked per element.
  18508. * @returns {number} Returns the index of the matched value, else `-1`.
  18509. */
  18510. function baseIndexOfWith(array, value, fromIndex, comparator) {
  18511. var index = fromIndex - 1,
  18512. length = array.length;
  18513. while (++index < length) {
  18514. if (comparator(array[index], value)) {
  18515. return index;
  18516. }
  18517. }
  18518. return -1;
  18519. }
  18520. /**
  18521. * The base implementation of `_.isNaN` without support for number objects.
  18522. *
  18523. * @private
  18524. * @param {*} value The value to check.
  18525. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  18526. */
  18527. function baseIsNaN(value) {
  18528. return value !== value;
  18529. }
  18530. /**
  18531. * The base implementation of `_.mean` and `_.meanBy` without support for
  18532. * iteratee shorthands.
  18533. *
  18534. * @private
  18535. * @param {Array} array The array to iterate over.
  18536. * @param {Function} iteratee The function invoked per iteration.
  18537. * @returns {number} Returns the mean.
  18538. */
  18539. function baseMean(array, iteratee) {
  18540. var length = array == null ? 0 : array.length;
  18541. return length ? (baseSum(array, iteratee) / length) : NAN;
  18542. }
  18543. /**
  18544. * The base implementation of `_.property` without support for deep paths.
  18545. *
  18546. * @private
  18547. * @param {string} key The key of the property to get.
  18548. * @returns {Function} Returns the new accessor function.
  18549. */
  18550. function baseProperty(key) {
  18551. return function(object) {
  18552. return object == null ? undefined : object[key];
  18553. };
  18554. }
  18555. /**
  18556. * The base implementation of `_.propertyOf` without support for deep paths.
  18557. *
  18558. * @private
  18559. * @param {Object} object The object to query.
  18560. * @returns {Function} Returns the new accessor function.
  18561. */
  18562. function basePropertyOf(object) {
  18563. return function(key) {
  18564. return object == null ? undefined : object[key];
  18565. };
  18566. }
  18567. /**
  18568. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  18569. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  18570. *
  18571. * @private
  18572. * @param {Array|Object} collection The collection to iterate over.
  18573. * @param {Function} iteratee The function invoked per iteration.
  18574. * @param {*} accumulator The initial value.
  18575. * @param {boolean} initAccum Specify using the first or last element of
  18576. * `collection` as the initial value.
  18577. * @param {Function} eachFunc The function to iterate over `collection`.
  18578. * @returns {*} Returns the accumulated value.
  18579. */
  18580. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  18581. eachFunc(collection, function(value, index, collection) {
  18582. accumulator = initAccum
  18583. ? (initAccum = false, value)
  18584. : iteratee(accumulator, value, index, collection);
  18585. });
  18586. return accumulator;
  18587. }
  18588. /**
  18589. * The base implementation of `_.sortBy` which uses `comparer` to define the
  18590. * sort order of `array` and replaces criteria objects with their corresponding
  18591. * values.
  18592. *
  18593. * @private
  18594. * @param {Array} array The array to sort.
  18595. * @param {Function} comparer The function to define sort order.
  18596. * @returns {Array} Returns `array`.
  18597. */
  18598. function baseSortBy(array, comparer) {
  18599. var length = array.length;
  18600. array.sort(comparer);
  18601. while (length--) {
  18602. array[length] = array[length].value;
  18603. }
  18604. return array;
  18605. }
  18606. /**
  18607. * The base implementation of `_.sum` and `_.sumBy` without support for
  18608. * iteratee shorthands.
  18609. *
  18610. * @private
  18611. * @param {Array} array The array to iterate over.
  18612. * @param {Function} iteratee The function invoked per iteration.
  18613. * @returns {number} Returns the sum.
  18614. */
  18615. function baseSum(array, iteratee) {
  18616. var result,
  18617. index = -1,
  18618. length = array.length;
  18619. while (++index < length) {
  18620. var current = iteratee(array[index]);
  18621. if (current !== undefined) {
  18622. result = result === undefined ? current : (result + current);
  18623. }
  18624. }
  18625. return result;
  18626. }
  18627. /**
  18628. * The base implementation of `_.times` without support for iteratee shorthands
  18629. * or max array length checks.
  18630. *
  18631. * @private
  18632. * @param {number} n The number of times to invoke `iteratee`.
  18633. * @param {Function} iteratee The function invoked per iteration.
  18634. * @returns {Array} Returns the array of results.
  18635. */
  18636. function baseTimes(n, iteratee) {
  18637. var index = -1,
  18638. result = Array(n);
  18639. while (++index < n) {
  18640. result[index] = iteratee(index);
  18641. }
  18642. return result;
  18643. }
  18644. /**
  18645. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  18646. * of key-value pairs for `object` corresponding to the property names of `props`.
  18647. *
  18648. * @private
  18649. * @param {Object} object The object to query.
  18650. * @param {Array} props The property names to get values for.
  18651. * @returns {Object} Returns the key-value pairs.
  18652. */
  18653. function baseToPairs(object, props) {
  18654. return arrayMap(props, function(key) {
  18655. return [key, object[key]];
  18656. });
  18657. }
  18658. /**
  18659. * The base implementation of `_.unary` without support for storing metadata.
  18660. *
  18661. * @private
  18662. * @param {Function} func The function to cap arguments for.
  18663. * @returns {Function} Returns the new capped function.
  18664. */
  18665. function baseUnary(func) {
  18666. return function(value) {
  18667. return func(value);
  18668. };
  18669. }
  18670. /**
  18671. * The base implementation of `_.values` and `_.valuesIn` which creates an
  18672. * array of `object` property values corresponding to the property names
  18673. * of `props`.
  18674. *
  18675. * @private
  18676. * @param {Object} object The object to query.
  18677. * @param {Array} props The property names to get values for.
  18678. * @returns {Object} Returns the array of property values.
  18679. */
  18680. function baseValues(object, props) {
  18681. return arrayMap(props, function(key) {
  18682. return object[key];
  18683. });
  18684. }
  18685. /**
  18686. * Checks if a `cache` value for `key` exists.
  18687. *
  18688. * @private
  18689. * @param {Object} cache The cache to query.
  18690. * @param {string} key The key of the entry to check.
  18691. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18692. */
  18693. function cacheHas(cache, key) {
  18694. return cache.has(key);
  18695. }
  18696. /**
  18697. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  18698. * that is not found in the character symbols.
  18699. *
  18700. * @private
  18701. * @param {Array} strSymbols The string symbols to inspect.
  18702. * @param {Array} chrSymbols The character symbols to find.
  18703. * @returns {number} Returns the index of the first unmatched string symbol.
  18704. */
  18705. function charsStartIndex(strSymbols, chrSymbols) {
  18706. var index = -1,
  18707. length = strSymbols.length;
  18708. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18709. return index;
  18710. }
  18711. /**
  18712. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  18713. * that is not found in the character symbols.
  18714. *
  18715. * @private
  18716. * @param {Array} strSymbols The string symbols to inspect.
  18717. * @param {Array} chrSymbols The character symbols to find.
  18718. * @returns {number} Returns the index of the last unmatched string symbol.
  18719. */
  18720. function charsEndIndex(strSymbols, chrSymbols) {
  18721. var index = strSymbols.length;
  18722. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18723. return index;
  18724. }
  18725. /**
  18726. * Gets the number of `placeholder` occurrences in `array`.
  18727. *
  18728. * @private
  18729. * @param {Array} array The array to inspect.
  18730. * @param {*} placeholder The placeholder to search for.
  18731. * @returns {number} Returns the placeholder count.
  18732. */
  18733. function countHolders(array, placeholder) {
  18734. var length = array.length,
  18735. result = 0;
  18736. while (length--) {
  18737. if (array[length] === placeholder) {
  18738. ++result;
  18739. }
  18740. }
  18741. return result;
  18742. }
  18743. /**
  18744. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  18745. * letters to basic Latin letters.
  18746. *
  18747. * @private
  18748. * @param {string} letter The matched letter to deburr.
  18749. * @returns {string} Returns the deburred letter.
  18750. */
  18751. var deburrLetter = basePropertyOf(deburredLetters);
  18752. /**
  18753. * Used by `_.escape` to convert characters to HTML entities.
  18754. *
  18755. * @private
  18756. * @param {string} chr The matched character to escape.
  18757. * @returns {string} Returns the escaped character.
  18758. */
  18759. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  18760. /**
  18761. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  18762. *
  18763. * @private
  18764. * @param {string} chr The matched character to escape.
  18765. * @returns {string} Returns the escaped character.
  18766. */
  18767. function escapeStringChar(chr) {
  18768. return '\\' + stringEscapes[chr];
  18769. }
  18770. /**
  18771. * Gets the value at `key` of `object`.
  18772. *
  18773. * @private
  18774. * @param {Object} [object] The object to query.
  18775. * @param {string} key The key of the property to get.
  18776. * @returns {*} Returns the property value.
  18777. */
  18778. function getValue(object, key) {
  18779. return object == null ? undefined : object[key];
  18780. }
  18781. /**
  18782. * Checks if `string` contains Unicode symbols.
  18783. *
  18784. * @private
  18785. * @param {string} string The string to inspect.
  18786. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  18787. */
  18788. function hasUnicode(string) {
  18789. return reHasUnicode.test(string);
  18790. }
  18791. /**
  18792. * Checks if `string` contains a word composed of Unicode symbols.
  18793. *
  18794. * @private
  18795. * @param {string} string The string to inspect.
  18796. * @returns {boolean} Returns `true` if a word is found, else `false`.
  18797. */
  18798. function hasUnicodeWord(string) {
  18799. return reHasUnicodeWord.test(string);
  18800. }
  18801. /**
  18802. * Converts `iterator` to an array.
  18803. *
  18804. * @private
  18805. * @param {Object} iterator The iterator to convert.
  18806. * @returns {Array} Returns the converted array.
  18807. */
  18808. function iteratorToArray(iterator) {
  18809. var data,
  18810. result = [];
  18811. while (!(data = iterator.next()).done) {
  18812. result.push(data.value);
  18813. }
  18814. return result;
  18815. }
  18816. /**
  18817. * Converts `map` to its key-value pairs.
  18818. *
  18819. * @private
  18820. * @param {Object} map The map to convert.
  18821. * @returns {Array} Returns the key-value pairs.
  18822. */
  18823. function mapToArray(map) {
  18824. var index = -1,
  18825. result = Array(map.size);
  18826. map.forEach(function(value, key) {
  18827. result[++index] = [key, value];
  18828. });
  18829. return result;
  18830. }
  18831. /**
  18832. * Creates a unary function that invokes `func` with its argument transformed.
  18833. *
  18834. * @private
  18835. * @param {Function} func The function to wrap.
  18836. * @param {Function} transform The argument transform.
  18837. * @returns {Function} Returns the new function.
  18838. */
  18839. function overArg(func, transform) {
  18840. return function(arg) {
  18841. return func(transform(arg));
  18842. };
  18843. }
  18844. /**
  18845. * Replaces all `placeholder` elements in `array` with an internal placeholder
  18846. * and returns an array of their indexes.
  18847. *
  18848. * @private
  18849. * @param {Array} array The array to modify.
  18850. * @param {*} placeholder The placeholder to replace.
  18851. * @returns {Array} Returns the new array of placeholder indexes.
  18852. */
  18853. function replaceHolders(array, placeholder) {
  18854. var index = -1,
  18855. length = array.length,
  18856. resIndex = 0,
  18857. result = [];
  18858. while (++index < length) {
  18859. var value = array[index];
  18860. if (value === placeholder || value === PLACEHOLDER) {
  18861. array[index] = PLACEHOLDER;
  18862. result[resIndex++] = index;
  18863. }
  18864. }
  18865. return result;
  18866. }
  18867. /**
  18868. * Converts `set` to an array of its values.
  18869. *
  18870. * @private
  18871. * @param {Object} set The set to convert.
  18872. * @returns {Array} Returns the values.
  18873. */
  18874. function setToArray(set) {
  18875. var index = -1,
  18876. result = Array(set.size);
  18877. set.forEach(function(value) {
  18878. result[++index] = value;
  18879. });
  18880. return result;
  18881. }
  18882. /**
  18883. * Converts `set` to its value-value pairs.
  18884. *
  18885. * @private
  18886. * @param {Object} set The set to convert.
  18887. * @returns {Array} Returns the value-value pairs.
  18888. */
  18889. function setToPairs(set) {
  18890. var index = -1,
  18891. result = Array(set.size);
  18892. set.forEach(function(value) {
  18893. result[++index] = [value, value];
  18894. });
  18895. return result;
  18896. }
  18897. /**
  18898. * A specialized version of `_.indexOf` which performs strict equality
  18899. * comparisons of values, i.e. `===`.
  18900. *
  18901. * @private
  18902. * @param {Array} array The array to inspect.
  18903. * @param {*} value The value to search for.
  18904. * @param {number} fromIndex The index to search from.
  18905. * @returns {number} Returns the index of the matched value, else `-1`.
  18906. */
  18907. function strictIndexOf(array, value, fromIndex) {
  18908. var index = fromIndex - 1,
  18909. length = array.length;
  18910. while (++index < length) {
  18911. if (array[index] === value) {
  18912. return index;
  18913. }
  18914. }
  18915. return -1;
  18916. }
  18917. /**
  18918. * A specialized version of `_.lastIndexOf` which performs strict equality
  18919. * comparisons of values, i.e. `===`.
  18920. *
  18921. * @private
  18922. * @param {Array} array The array to inspect.
  18923. * @param {*} value The value to search for.
  18924. * @param {number} fromIndex The index to search from.
  18925. * @returns {number} Returns the index of the matched value, else `-1`.
  18926. */
  18927. function strictLastIndexOf(array, value, fromIndex) {
  18928. var index = fromIndex + 1;
  18929. while (index--) {
  18930. if (array[index] === value) {
  18931. return index;
  18932. }
  18933. }
  18934. return index;
  18935. }
  18936. /**
  18937. * Gets the number of symbols in `string`.
  18938. *
  18939. * @private
  18940. * @param {string} string The string to inspect.
  18941. * @returns {number} Returns the string size.
  18942. */
  18943. function stringSize(string) {
  18944. return hasUnicode(string)
  18945. ? unicodeSize(string)
  18946. : asciiSize(string);
  18947. }
  18948. /**
  18949. * Converts `string` to an array.
  18950. *
  18951. * @private
  18952. * @param {string} string The string to convert.
  18953. * @returns {Array} Returns the converted array.
  18954. */
  18955. function stringToArray(string) {
  18956. return hasUnicode(string)
  18957. ? unicodeToArray(string)
  18958. : asciiToArray(string);
  18959. }
  18960. /**
  18961. * Used by `_.unescape` to convert HTML entities to characters.
  18962. *
  18963. * @private
  18964. * @param {string} chr The matched character to unescape.
  18965. * @returns {string} Returns the unescaped character.
  18966. */
  18967. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  18968. /**
  18969. * Gets the size of a Unicode `string`.
  18970. *
  18971. * @private
  18972. * @param {string} string The string inspect.
  18973. * @returns {number} Returns the string size.
  18974. */
  18975. function unicodeSize(string) {
  18976. var result = reUnicode.lastIndex = 0;
  18977. while (reUnicode.test(string)) {
  18978. ++result;
  18979. }
  18980. return result;
  18981. }
  18982. /**
  18983. * Converts a Unicode `string` to an array.
  18984. *
  18985. * @private
  18986. * @param {string} string The string to convert.
  18987. * @returns {Array} Returns the converted array.
  18988. */
  18989. function unicodeToArray(string) {
  18990. return string.match(reUnicode) || [];
  18991. }
  18992. /**
  18993. * Splits a Unicode `string` into an array of its words.
  18994. *
  18995. * @private
  18996. * @param {string} The string to inspect.
  18997. * @returns {Array} Returns the words of `string`.
  18998. */
  18999. function unicodeWords(string) {
  19000. return string.match(reUnicodeWord) || [];
  19001. }
  19002. /*--------------------------------------------------------------------------*/
  19003. /**
  19004. * Create a new pristine `lodash` function using the `context` object.
  19005. *
  19006. * @static
  19007. * @memberOf _
  19008. * @since 1.1.0
  19009. * @category Util
  19010. * @param {Object} [context=root] The context object.
  19011. * @returns {Function} Returns a new `lodash` function.
  19012. * @example
  19013. *
  19014. * _.mixin({ 'foo': _.constant('foo') });
  19015. *
  19016. * var lodash = _.runInContext();
  19017. * lodash.mixin({ 'bar': lodash.constant('bar') });
  19018. *
  19019. * _.isFunction(_.foo);
  19020. * // => true
  19021. * _.isFunction(_.bar);
  19022. * // => false
  19023. *
  19024. * lodash.isFunction(lodash.foo);
  19025. * // => false
  19026. * lodash.isFunction(lodash.bar);
  19027. * // => true
  19028. *
  19029. * // Create a suped-up `defer` in Node.js.
  19030. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  19031. */
  19032. var runInContext = (function runInContext(context) {
  19033. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  19034. /** Built-in constructor references. */
  19035. var Array = context.Array,
  19036. Date = context.Date,
  19037. Error = context.Error,
  19038. Function = context.Function,
  19039. Math = context.Math,
  19040. Object = context.Object,
  19041. RegExp = context.RegExp,
  19042. String = context.String,
  19043. TypeError = context.TypeError;
  19044. /** Used for built-in method references. */
  19045. var arrayProto = Array.prototype,
  19046. funcProto = Function.prototype,
  19047. objectProto = Object.prototype;
  19048. /** Used to detect overreaching core-js shims. */
  19049. var coreJsData = context['__core-js_shared__'];
  19050. /** Used to resolve the decompiled source of functions. */
  19051. var funcToString = funcProto.toString;
  19052. /** Used to check objects for own properties. */
  19053. var hasOwnProperty = objectProto.hasOwnProperty;
  19054. /** Used to generate unique IDs. */
  19055. var idCounter = 0;
  19056. /** Used to detect methods masquerading as native. */
  19057. var maskSrcKey = (function() {
  19058. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  19059. return uid ? ('Symbol(src)_1.' + uid) : '';
  19060. }());
  19061. /**
  19062. * Used to resolve the
  19063. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  19064. * of values.
  19065. */
  19066. var nativeObjectToString = objectProto.toString;
  19067. /** Used to infer the `Object` constructor. */
  19068. var objectCtorString = funcToString.call(Object);
  19069. /** Used to restore the original `_` reference in `_.noConflict`. */
  19070. var oldDash = root._;
  19071. /** Used to detect if a method is native. */
  19072. var reIsNative = RegExp('^' +
  19073. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  19074. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  19075. );
  19076. /** Built-in value references. */
  19077. var Buffer = moduleExports ? context.Buffer : undefined,
  19078. Symbol = context.Symbol,
  19079. Uint8Array = context.Uint8Array,
  19080. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  19081. getPrototype = overArg(Object.getPrototypeOf, Object),
  19082. objectCreate = Object.create,
  19083. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  19084. splice = arrayProto.splice,
  19085. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  19086. symIterator = Symbol ? Symbol.iterator : undefined,
  19087. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  19088. var defineProperty = (function() {
  19089. try {
  19090. var func = getNative(Object, 'defineProperty');
  19091. func({}, '', {});
  19092. return func;
  19093. } catch (e) {}
  19094. }());
  19095. /** Mocked built-ins. */
  19096. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  19097. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  19098. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  19099. /* Built-in method references for those with the same name as other `lodash` methods. */
  19100. var nativeCeil = Math.ceil,
  19101. nativeFloor = Math.floor,
  19102. nativeGetSymbols = Object.getOwnPropertySymbols,
  19103. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  19104. nativeIsFinite = context.isFinite,
  19105. nativeJoin = arrayProto.join,
  19106. nativeKeys = overArg(Object.keys, Object),
  19107. nativeMax = Math.max,
  19108. nativeMin = Math.min,
  19109. nativeNow = Date.now,
  19110. nativeParseInt = context.parseInt,
  19111. nativeRandom = Math.random,
  19112. nativeReverse = arrayProto.reverse;
  19113. /* Built-in method references that are verified to be native. */
  19114. var DataView = getNative(context, 'DataView'),
  19115. Map = getNative(context, 'Map'),
  19116. Promise = getNative(context, 'Promise'),
  19117. Set = getNative(context, 'Set'),
  19118. WeakMap = getNative(context, 'WeakMap'),
  19119. nativeCreate = getNative(Object, 'create');
  19120. /** Used to store function metadata. */
  19121. var metaMap = WeakMap && new WeakMap;
  19122. /** Used to lookup unminified function names. */
  19123. var realNames = {};
  19124. /** Used to detect maps, sets, and weakmaps. */
  19125. var dataViewCtorString = toSource(DataView),
  19126. mapCtorString = toSource(Map),
  19127. promiseCtorString = toSource(Promise),
  19128. setCtorString = toSource(Set),
  19129. weakMapCtorString = toSource(WeakMap);
  19130. /** Used to convert symbols to primitives and strings. */
  19131. var symbolProto = Symbol ? Symbol.prototype : undefined,
  19132. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  19133. symbolToString = symbolProto ? symbolProto.toString : undefined;
  19134. /*------------------------------------------------------------------------*/
  19135. /**
  19136. * Creates a `lodash` object which wraps `value` to enable implicit method
  19137. * chain sequences. Methods that operate on and return arrays, collections,
  19138. * and functions can be chained together. Methods that retrieve a single value
  19139. * or may return a primitive value will automatically end the chain sequence
  19140. * and return the unwrapped value. Otherwise, the value must be unwrapped
  19141. * with `_#value`.
  19142. *
  19143. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  19144. * enabled using `_.chain`.
  19145. *
  19146. * The execution of chained methods is lazy, that is, it's deferred until
  19147. * `_#value` is implicitly or explicitly called.
  19148. *
  19149. * Lazy evaluation allows several methods to support shortcut fusion.
  19150. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  19151. * the creation of intermediate arrays and can greatly reduce the number of
  19152. * iteratee executions. Sections of a chain sequence qualify for shortcut
  19153. * fusion if the section is applied to an array and iteratees accept only
  19154. * one argument. The heuristic for whether a section qualifies for shortcut
  19155. * fusion is subject to change.
  19156. *
  19157. * Chaining is supported in custom builds as long as the `_#value` method is
  19158. * directly or indirectly included in the build.
  19159. *
  19160. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  19161. *
  19162. * The wrapper `Array` methods are:
  19163. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  19164. *
  19165. * The wrapper `String` methods are:
  19166. * `replace` and `split`
  19167. *
  19168. * The wrapper methods that support shortcut fusion are:
  19169. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  19170. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  19171. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  19172. *
  19173. * The chainable wrapper methods are:
  19174. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  19175. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  19176. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  19177. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  19178. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  19179. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  19180. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  19181. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  19182. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  19183. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  19184. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  19185. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  19186. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  19187. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  19188. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  19189. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  19190. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  19191. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  19192. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  19193. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  19194. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  19195. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  19196. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  19197. * `zipObject`, `zipObjectDeep`, and `zipWith`
  19198. *
  19199. * The wrapper methods that are **not** chainable by default are:
  19200. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  19201. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  19202. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  19203. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  19204. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  19205. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  19206. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  19207. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  19208. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  19209. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  19210. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  19211. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  19212. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  19213. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  19214. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  19215. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  19216. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  19217. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  19218. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  19219. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  19220. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  19221. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  19222. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  19223. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  19224. * `upperFirst`, `value`, and `words`
  19225. *
  19226. * @name _
  19227. * @constructor
  19228. * @category Seq
  19229. * @param {*} value The value to wrap in a `lodash` instance.
  19230. * @returns {Object} Returns the new `lodash` wrapper instance.
  19231. * @example
  19232. *
  19233. * function square(n) {
  19234. * return n * n;
  19235. * }
  19236. *
  19237. * var wrapped = _([1, 2, 3]);
  19238. *
  19239. * // Returns an unwrapped value.
  19240. * wrapped.reduce(_.add);
  19241. * // => 6
  19242. *
  19243. * // Returns a wrapped value.
  19244. * var squares = wrapped.map(square);
  19245. *
  19246. * _.isArray(squares);
  19247. * // => false
  19248. *
  19249. * _.isArray(squares.value());
  19250. * // => true
  19251. */
  19252. function lodash(value) {
  19253. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  19254. if (value instanceof LodashWrapper) {
  19255. return value;
  19256. }
  19257. if (hasOwnProperty.call(value, '__wrapped__')) {
  19258. return wrapperClone(value);
  19259. }
  19260. }
  19261. return new LodashWrapper(value);
  19262. }
  19263. /**
  19264. * The base implementation of `_.create` without support for assigning
  19265. * properties to the created object.
  19266. *
  19267. * @private
  19268. * @param {Object} proto The object to inherit from.
  19269. * @returns {Object} Returns the new object.
  19270. */
  19271. var baseCreate = (function() {
  19272. function object() {}
  19273. return function(proto) {
  19274. if (!isObject(proto)) {
  19275. return {};
  19276. }
  19277. if (objectCreate) {
  19278. return objectCreate(proto);
  19279. }
  19280. object.prototype = proto;
  19281. var result = new object;
  19282. object.prototype = undefined;
  19283. return result;
  19284. };
  19285. }());
  19286. /**
  19287. * The function whose prototype chain sequence wrappers inherit from.
  19288. *
  19289. * @private
  19290. */
  19291. function baseLodash() {
  19292. // No operation performed.
  19293. }
  19294. /**
  19295. * The base constructor for creating `lodash` wrapper objects.
  19296. *
  19297. * @private
  19298. * @param {*} value The value to wrap.
  19299. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  19300. */
  19301. function LodashWrapper(value, chainAll) {
  19302. this.__wrapped__ = value;
  19303. this.__actions__ = [];
  19304. this.__chain__ = !!chainAll;
  19305. this.__index__ = 0;
  19306. this.__values__ = undefined;
  19307. }
  19308. /**
  19309. * By default, the template delimiters used by lodash are like those in
  19310. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  19311. * following template settings to use alternative delimiters.
  19312. *
  19313. * @static
  19314. * @memberOf _
  19315. * @type {Object}
  19316. */
  19317. lodash.templateSettings = {
  19318. /**
  19319. * Used to detect `data` property values to be HTML-escaped.
  19320. *
  19321. * @memberOf _.templateSettings
  19322. * @type {RegExp}
  19323. */
  19324. 'escape': reEscape,
  19325. /**
  19326. * Used to detect code to be evaluated.
  19327. *
  19328. * @memberOf _.templateSettings
  19329. * @type {RegExp}
  19330. */
  19331. 'evaluate': reEvaluate,
  19332. /**
  19333. * Used to detect `data` property values to inject.
  19334. *
  19335. * @memberOf _.templateSettings
  19336. * @type {RegExp}
  19337. */
  19338. 'interpolate': reInterpolate,
  19339. /**
  19340. * Used to reference the data object in the template text.
  19341. *
  19342. * @memberOf _.templateSettings
  19343. * @type {string}
  19344. */
  19345. 'variable': '',
  19346. /**
  19347. * Used to import variables into the compiled template.
  19348. *
  19349. * @memberOf _.templateSettings
  19350. * @type {Object}
  19351. */
  19352. 'imports': {
  19353. /**
  19354. * A reference to the `lodash` function.
  19355. *
  19356. * @memberOf _.templateSettings.imports
  19357. * @type {Function}
  19358. */
  19359. '_': lodash
  19360. }
  19361. };
  19362. // Ensure wrappers are instances of `baseLodash`.
  19363. lodash.prototype = baseLodash.prototype;
  19364. lodash.prototype.constructor = lodash;
  19365. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  19366. LodashWrapper.prototype.constructor = LodashWrapper;
  19367. /*------------------------------------------------------------------------*/
  19368. /**
  19369. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  19370. *
  19371. * @private
  19372. * @constructor
  19373. * @param {*} value The value to wrap.
  19374. */
  19375. function LazyWrapper(value) {
  19376. this.__wrapped__ = value;
  19377. this.__actions__ = [];
  19378. this.__dir__ = 1;
  19379. this.__filtered__ = false;
  19380. this.__iteratees__ = [];
  19381. this.__takeCount__ = MAX_ARRAY_LENGTH;
  19382. this.__views__ = [];
  19383. }
  19384. /**
  19385. * Creates a clone of the lazy wrapper object.
  19386. *
  19387. * @private
  19388. * @name clone
  19389. * @memberOf LazyWrapper
  19390. * @returns {Object} Returns the cloned `LazyWrapper` object.
  19391. */
  19392. function lazyClone() {
  19393. var result = new LazyWrapper(this.__wrapped__);
  19394. result.__actions__ = copyArray(this.__actions__);
  19395. result.__dir__ = this.__dir__;
  19396. result.__filtered__ = this.__filtered__;
  19397. result.__iteratees__ = copyArray(this.__iteratees__);
  19398. result.__takeCount__ = this.__takeCount__;
  19399. result.__views__ = copyArray(this.__views__);
  19400. return result;
  19401. }
  19402. /**
  19403. * Reverses the direction of lazy iteration.
  19404. *
  19405. * @private
  19406. * @name reverse
  19407. * @memberOf LazyWrapper
  19408. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  19409. */
  19410. function lazyReverse() {
  19411. if (this.__filtered__) {
  19412. var result = new LazyWrapper(this);
  19413. result.__dir__ = -1;
  19414. result.__filtered__ = true;
  19415. } else {
  19416. result = this.clone();
  19417. result.__dir__ *= -1;
  19418. }
  19419. return result;
  19420. }
  19421. /**
  19422. * Extracts the unwrapped value from its lazy wrapper.
  19423. *
  19424. * @private
  19425. * @name value
  19426. * @memberOf LazyWrapper
  19427. * @returns {*} Returns the unwrapped value.
  19428. */
  19429. function lazyValue() {
  19430. var array = this.__wrapped__.value(),
  19431. dir = this.__dir__,
  19432. isArr = isArray(array),
  19433. isRight = dir < 0,
  19434. arrLength = isArr ? array.length : 0,
  19435. view = getView(0, arrLength, this.__views__),
  19436. start = view.start,
  19437. end = view.end,
  19438. length = end - start,
  19439. index = isRight ? end : (start - 1),
  19440. iteratees = this.__iteratees__,
  19441. iterLength = iteratees.length,
  19442. resIndex = 0,
  19443. takeCount = nativeMin(length, this.__takeCount__);
  19444. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  19445. return baseWrapperValue(array, this.__actions__);
  19446. }
  19447. var result = [];
  19448. outer:
  19449. while (length-- && resIndex < takeCount) {
  19450. index += dir;
  19451. var iterIndex = -1,
  19452. value = array[index];
  19453. while (++iterIndex < iterLength) {
  19454. var data = iteratees[iterIndex],
  19455. iteratee = data.iteratee,
  19456. type = data.type,
  19457. computed = iteratee(value);
  19458. if (type == LAZY_MAP_FLAG) {
  19459. value = computed;
  19460. } else if (!computed) {
  19461. if (type == LAZY_FILTER_FLAG) {
  19462. continue outer;
  19463. } else {
  19464. break outer;
  19465. }
  19466. }
  19467. }
  19468. result[resIndex++] = value;
  19469. }
  19470. return result;
  19471. }
  19472. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  19473. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  19474. LazyWrapper.prototype.constructor = LazyWrapper;
  19475. /*------------------------------------------------------------------------*/
  19476. /**
  19477. * Creates a hash object.
  19478. *
  19479. * @private
  19480. * @constructor
  19481. * @param {Array} [entries] The key-value pairs to cache.
  19482. */
  19483. function Hash(entries) {
  19484. var index = -1,
  19485. length = entries == null ? 0 : entries.length;
  19486. this.clear();
  19487. while (++index < length) {
  19488. var entry = entries[index];
  19489. this.set(entry[0], entry[1]);
  19490. }
  19491. }
  19492. /**
  19493. * Removes all key-value entries from the hash.
  19494. *
  19495. * @private
  19496. * @name clear
  19497. * @memberOf Hash
  19498. */
  19499. function hashClear() {
  19500. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  19501. this.size = 0;
  19502. }
  19503. /**
  19504. * Removes `key` and its value from the hash.
  19505. *
  19506. * @private
  19507. * @name delete
  19508. * @memberOf Hash
  19509. * @param {Object} hash The hash to modify.
  19510. * @param {string} key The key of the value to remove.
  19511. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19512. */
  19513. function hashDelete(key) {
  19514. var result = this.has(key) && delete this.__data__[key];
  19515. this.size -= result ? 1 : 0;
  19516. return result;
  19517. }
  19518. /**
  19519. * Gets the hash value for `key`.
  19520. *
  19521. * @private
  19522. * @name get
  19523. * @memberOf Hash
  19524. * @param {string} key The key of the value to get.
  19525. * @returns {*} Returns the entry value.
  19526. */
  19527. function hashGet(key) {
  19528. var data = this.__data__;
  19529. if (nativeCreate) {
  19530. var result = data[key];
  19531. return result === HASH_UNDEFINED ? undefined : result;
  19532. }
  19533. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  19534. }
  19535. /**
  19536. * Checks if a hash value for `key` exists.
  19537. *
  19538. * @private
  19539. * @name has
  19540. * @memberOf Hash
  19541. * @param {string} key The key of the entry to check.
  19542. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19543. */
  19544. function hashHas(key) {
  19545. var data = this.__data__;
  19546. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  19547. }
  19548. /**
  19549. * Sets the hash `key` to `value`.
  19550. *
  19551. * @private
  19552. * @name set
  19553. * @memberOf Hash
  19554. * @param {string} key The key of the value to set.
  19555. * @param {*} value The value to set.
  19556. * @returns {Object} Returns the hash instance.
  19557. */
  19558. function hashSet(key, value) {
  19559. var data = this.__data__;
  19560. this.size += this.has(key) ? 0 : 1;
  19561. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  19562. return this;
  19563. }
  19564. // Add methods to `Hash`.
  19565. Hash.prototype.clear = hashClear;
  19566. Hash.prototype['delete'] = hashDelete;
  19567. Hash.prototype.get = hashGet;
  19568. Hash.prototype.has = hashHas;
  19569. Hash.prototype.set = hashSet;
  19570. /*------------------------------------------------------------------------*/
  19571. /**
  19572. * Creates an list cache object.
  19573. *
  19574. * @private
  19575. * @constructor
  19576. * @param {Array} [entries] The key-value pairs to cache.
  19577. */
  19578. function ListCache(entries) {
  19579. var index = -1,
  19580. length = entries == null ? 0 : entries.length;
  19581. this.clear();
  19582. while (++index < length) {
  19583. var entry = entries[index];
  19584. this.set(entry[0], entry[1]);
  19585. }
  19586. }
  19587. /**
  19588. * Removes all key-value entries from the list cache.
  19589. *
  19590. * @private
  19591. * @name clear
  19592. * @memberOf ListCache
  19593. */
  19594. function listCacheClear() {
  19595. this.__data__ = [];
  19596. this.size = 0;
  19597. }
  19598. /**
  19599. * Removes `key` and its value from the list cache.
  19600. *
  19601. * @private
  19602. * @name delete
  19603. * @memberOf ListCache
  19604. * @param {string} key The key of the value to remove.
  19605. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19606. */
  19607. function listCacheDelete(key) {
  19608. var data = this.__data__,
  19609. index = assocIndexOf(data, key);
  19610. if (index < 0) {
  19611. return false;
  19612. }
  19613. var lastIndex = data.length - 1;
  19614. if (index == lastIndex) {
  19615. data.pop();
  19616. } else {
  19617. splice.call(data, index, 1);
  19618. }
  19619. --this.size;
  19620. return true;
  19621. }
  19622. /**
  19623. * Gets the list cache value for `key`.
  19624. *
  19625. * @private
  19626. * @name get
  19627. * @memberOf ListCache
  19628. * @param {string} key The key of the value to get.
  19629. * @returns {*} Returns the entry value.
  19630. */
  19631. function listCacheGet(key) {
  19632. var data = this.__data__,
  19633. index = assocIndexOf(data, key);
  19634. return index < 0 ? undefined : data[index][1];
  19635. }
  19636. /**
  19637. * Checks if a list cache value for `key` exists.
  19638. *
  19639. * @private
  19640. * @name has
  19641. * @memberOf ListCache
  19642. * @param {string} key The key of the entry to check.
  19643. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19644. */
  19645. function listCacheHas(key) {
  19646. return assocIndexOf(this.__data__, key) > -1;
  19647. }
  19648. /**
  19649. * Sets the list cache `key` to `value`.
  19650. *
  19651. * @private
  19652. * @name set
  19653. * @memberOf ListCache
  19654. * @param {string} key The key of the value to set.
  19655. * @param {*} value The value to set.
  19656. * @returns {Object} Returns the list cache instance.
  19657. */
  19658. function listCacheSet(key, value) {
  19659. var data = this.__data__,
  19660. index = assocIndexOf(data, key);
  19661. if (index < 0) {
  19662. ++this.size;
  19663. data.push([key, value]);
  19664. } else {
  19665. data[index][1] = value;
  19666. }
  19667. return this;
  19668. }
  19669. // Add methods to `ListCache`.
  19670. ListCache.prototype.clear = listCacheClear;
  19671. ListCache.prototype['delete'] = listCacheDelete;
  19672. ListCache.prototype.get = listCacheGet;
  19673. ListCache.prototype.has = listCacheHas;
  19674. ListCache.prototype.set = listCacheSet;
  19675. /*------------------------------------------------------------------------*/
  19676. /**
  19677. * Creates a map cache object to store key-value pairs.
  19678. *
  19679. * @private
  19680. * @constructor
  19681. * @param {Array} [entries] The key-value pairs to cache.
  19682. */
  19683. function MapCache(entries) {
  19684. var index = -1,
  19685. length = entries == null ? 0 : entries.length;
  19686. this.clear();
  19687. while (++index < length) {
  19688. var entry = entries[index];
  19689. this.set(entry[0], entry[1]);
  19690. }
  19691. }
  19692. /**
  19693. * Removes all key-value entries from the map.
  19694. *
  19695. * @private
  19696. * @name clear
  19697. * @memberOf MapCache
  19698. */
  19699. function mapCacheClear() {
  19700. this.size = 0;
  19701. this.__data__ = {
  19702. 'hash': new Hash,
  19703. 'map': new (Map || ListCache),
  19704. 'string': new Hash
  19705. };
  19706. }
  19707. /**
  19708. * Removes `key` and its value from the map.
  19709. *
  19710. * @private
  19711. * @name delete
  19712. * @memberOf MapCache
  19713. * @param {string} key The key of the value to remove.
  19714. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19715. */
  19716. function mapCacheDelete(key) {
  19717. var result = getMapData(this, key)['delete'](key);
  19718. this.size -= result ? 1 : 0;
  19719. return result;
  19720. }
  19721. /**
  19722. * Gets the map value for `key`.
  19723. *
  19724. * @private
  19725. * @name get
  19726. * @memberOf MapCache
  19727. * @param {string} key The key of the value to get.
  19728. * @returns {*} Returns the entry value.
  19729. */
  19730. function mapCacheGet(key) {
  19731. return getMapData(this, key).get(key);
  19732. }
  19733. /**
  19734. * Checks if a map value for `key` exists.
  19735. *
  19736. * @private
  19737. * @name has
  19738. * @memberOf MapCache
  19739. * @param {string} key The key of the entry to check.
  19740. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19741. */
  19742. function mapCacheHas(key) {
  19743. return getMapData(this, key).has(key);
  19744. }
  19745. /**
  19746. * Sets the map `key` to `value`.
  19747. *
  19748. * @private
  19749. * @name set
  19750. * @memberOf MapCache
  19751. * @param {string} key The key of the value to set.
  19752. * @param {*} value The value to set.
  19753. * @returns {Object} Returns the map cache instance.
  19754. */
  19755. function mapCacheSet(key, value) {
  19756. var data = getMapData(this, key),
  19757. size = data.size;
  19758. data.set(key, value);
  19759. this.size += data.size == size ? 0 : 1;
  19760. return this;
  19761. }
  19762. // Add methods to `MapCache`.
  19763. MapCache.prototype.clear = mapCacheClear;
  19764. MapCache.prototype['delete'] = mapCacheDelete;
  19765. MapCache.prototype.get = mapCacheGet;
  19766. MapCache.prototype.has = mapCacheHas;
  19767. MapCache.prototype.set = mapCacheSet;
  19768. /*------------------------------------------------------------------------*/
  19769. /**
  19770. *
  19771. * Creates an array cache object to store unique values.
  19772. *
  19773. * @private
  19774. * @constructor
  19775. * @param {Array} [values] The values to cache.
  19776. */
  19777. function SetCache(values) {
  19778. var index = -1,
  19779. length = values == null ? 0 : values.length;
  19780. this.__data__ = new MapCache;
  19781. while (++index < length) {
  19782. this.add(values[index]);
  19783. }
  19784. }
  19785. /**
  19786. * Adds `value` to the array cache.
  19787. *
  19788. * @private
  19789. * @name add
  19790. * @memberOf SetCache
  19791. * @alias push
  19792. * @param {*} value The value to cache.
  19793. * @returns {Object} Returns the cache instance.
  19794. */
  19795. function setCacheAdd(value) {
  19796. this.__data__.set(value, HASH_UNDEFINED);
  19797. return this;
  19798. }
  19799. /**
  19800. * Checks if `value` is in the array cache.
  19801. *
  19802. * @private
  19803. * @name has
  19804. * @memberOf SetCache
  19805. * @param {*} value The value to search for.
  19806. * @returns {number} Returns `true` if `value` is found, else `false`.
  19807. */
  19808. function setCacheHas(value) {
  19809. return this.__data__.has(value);
  19810. }
  19811. // Add methods to `SetCache`.
  19812. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  19813. SetCache.prototype.has = setCacheHas;
  19814. /*------------------------------------------------------------------------*/
  19815. /**
  19816. * Creates a stack cache object to store key-value pairs.
  19817. *
  19818. * @private
  19819. * @constructor
  19820. * @param {Array} [entries] The key-value pairs to cache.
  19821. */
  19822. function Stack(entries) {
  19823. var data = this.__data__ = new ListCache(entries);
  19824. this.size = data.size;
  19825. }
  19826. /**
  19827. * Removes all key-value entries from the stack.
  19828. *
  19829. * @private
  19830. * @name clear
  19831. * @memberOf Stack
  19832. */
  19833. function stackClear() {
  19834. this.__data__ = new ListCache;
  19835. this.size = 0;
  19836. }
  19837. /**
  19838. * Removes `key` and its value from the stack.
  19839. *
  19840. * @private
  19841. * @name delete
  19842. * @memberOf Stack
  19843. * @param {string} key The key of the value to remove.
  19844. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19845. */
  19846. function stackDelete(key) {
  19847. var data = this.__data__,
  19848. result = data['delete'](key);
  19849. this.size = data.size;
  19850. return result;
  19851. }
  19852. /**
  19853. * Gets the stack value for `key`.
  19854. *
  19855. * @private
  19856. * @name get
  19857. * @memberOf Stack
  19858. * @param {string} key The key of the value to get.
  19859. * @returns {*} Returns the entry value.
  19860. */
  19861. function stackGet(key) {
  19862. return this.__data__.get(key);
  19863. }
  19864. /**
  19865. * Checks if a stack value for `key` exists.
  19866. *
  19867. * @private
  19868. * @name has
  19869. * @memberOf Stack
  19870. * @param {string} key The key of the entry to check.
  19871. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19872. */
  19873. function stackHas(key) {
  19874. return this.__data__.has(key);
  19875. }
  19876. /**
  19877. * Sets the stack `key` to `value`.
  19878. *
  19879. * @private
  19880. * @name set
  19881. * @memberOf Stack
  19882. * @param {string} key The key of the value to set.
  19883. * @param {*} value The value to set.
  19884. * @returns {Object} Returns the stack cache instance.
  19885. */
  19886. function stackSet(key, value) {
  19887. var data = this.__data__;
  19888. if (data instanceof ListCache) {
  19889. var pairs = data.__data__;
  19890. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  19891. pairs.push([key, value]);
  19892. this.size = ++data.size;
  19893. return this;
  19894. }
  19895. data = this.__data__ = new MapCache(pairs);
  19896. }
  19897. data.set(key, value);
  19898. this.size = data.size;
  19899. return this;
  19900. }
  19901. // Add methods to `Stack`.
  19902. Stack.prototype.clear = stackClear;
  19903. Stack.prototype['delete'] = stackDelete;
  19904. Stack.prototype.get = stackGet;
  19905. Stack.prototype.has = stackHas;
  19906. Stack.prototype.set = stackSet;
  19907. /*------------------------------------------------------------------------*/
  19908. /**
  19909. * Creates an array of the enumerable property names of the array-like `value`.
  19910. *
  19911. * @private
  19912. * @param {*} value The value to query.
  19913. * @param {boolean} inherited Specify returning inherited property names.
  19914. * @returns {Array} Returns the array of property names.
  19915. */
  19916. function arrayLikeKeys(value, inherited) {
  19917. var isArr = isArray(value),
  19918. isArg = !isArr && isArguments(value),
  19919. isBuff = !isArr && !isArg && isBuffer(value),
  19920. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  19921. skipIndexes = isArr || isArg || isBuff || isType,
  19922. result = skipIndexes ? baseTimes(value.length, String) : [],
  19923. length = result.length;
  19924. for (var key in value) {
  19925. if ((inherited || hasOwnProperty.call(value, key)) &&
  19926. !(skipIndexes && (
  19927. // Safari 9 has enumerable `arguments.length` in strict mode.
  19928. key == 'length' ||
  19929. // Node.js 0.10 has enumerable non-index properties on buffers.
  19930. (isBuff && (key == 'offset' || key == 'parent')) ||
  19931. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  19932. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  19933. // Skip index properties.
  19934. isIndex(key, length)
  19935. ))) {
  19936. result.push(key);
  19937. }
  19938. }
  19939. return result;
  19940. }
  19941. /**
  19942. * A specialized version of `_.sample` for arrays.
  19943. *
  19944. * @private
  19945. * @param {Array} array The array to sample.
  19946. * @returns {*} Returns the random element.
  19947. */
  19948. function arraySample(array) {
  19949. var length = array.length;
  19950. return length ? array[baseRandom(0, length - 1)] : undefined;
  19951. }
  19952. /**
  19953. * A specialized version of `_.sampleSize` for arrays.
  19954. *
  19955. * @private
  19956. * @param {Array} array The array to sample.
  19957. * @param {number} n The number of elements to sample.
  19958. * @returns {Array} Returns the random elements.
  19959. */
  19960. function arraySampleSize(array, n) {
  19961. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  19962. }
  19963. /**
  19964. * A specialized version of `_.shuffle` for arrays.
  19965. *
  19966. * @private
  19967. * @param {Array} array The array to shuffle.
  19968. * @returns {Array} Returns the new shuffled array.
  19969. */
  19970. function arrayShuffle(array) {
  19971. return shuffleSelf(copyArray(array));
  19972. }
  19973. /**
  19974. * This function is like `assignValue` except that it doesn't assign
  19975. * `undefined` values.
  19976. *
  19977. * @private
  19978. * @param {Object} object The object to modify.
  19979. * @param {string} key The key of the property to assign.
  19980. * @param {*} value The value to assign.
  19981. */
  19982. function assignMergeValue(object, key, value) {
  19983. if ((value !== undefined && !eq(object[key], value)) ||
  19984. (value === undefined && !(key in object))) {
  19985. baseAssignValue(object, key, value);
  19986. }
  19987. }
  19988. /**
  19989. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  19990. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  19991. * for equality comparisons.
  19992. *
  19993. * @private
  19994. * @param {Object} object The object to modify.
  19995. * @param {string} key The key of the property to assign.
  19996. * @param {*} value The value to assign.
  19997. */
  19998. function assignValue(object, key, value) {
  19999. var objValue = object[key];
  20000. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  20001. (value === undefined && !(key in object))) {
  20002. baseAssignValue(object, key, value);
  20003. }
  20004. }
  20005. /**
  20006. * Gets the index at which the `key` is found in `array` of key-value pairs.
  20007. *
  20008. * @private
  20009. * @param {Array} array The array to inspect.
  20010. * @param {*} key The key to search for.
  20011. * @returns {number} Returns the index of the matched value, else `-1`.
  20012. */
  20013. function assocIndexOf(array, key) {
  20014. var length = array.length;
  20015. while (length--) {
  20016. if (eq(array[length][0], key)) {
  20017. return length;
  20018. }
  20019. }
  20020. return -1;
  20021. }
  20022. /**
  20023. * Aggregates elements of `collection` on `accumulator` with keys transformed
  20024. * by `iteratee` and values set by `setter`.
  20025. *
  20026. * @private
  20027. * @param {Array|Object} collection The collection to iterate over.
  20028. * @param {Function} setter The function to set `accumulator` values.
  20029. * @param {Function} iteratee The iteratee to transform keys.
  20030. * @param {Object} accumulator The initial aggregated object.
  20031. * @returns {Function} Returns `accumulator`.
  20032. */
  20033. function baseAggregator(collection, setter, iteratee, accumulator) {
  20034. baseEach(collection, function(value, key, collection) {
  20035. setter(accumulator, value, iteratee(value), collection);
  20036. });
  20037. return accumulator;
  20038. }
  20039. /**
  20040. * The base implementation of `_.assign` without support for multiple sources
  20041. * or `customizer` functions.
  20042. *
  20043. * @private
  20044. * @param {Object} object The destination object.
  20045. * @param {Object} source The source object.
  20046. * @returns {Object} Returns `object`.
  20047. */
  20048. function baseAssign(object, source) {
  20049. return object && copyObject(source, keys(source), object);
  20050. }
  20051. /**
  20052. * The base implementation of `_.assignIn` without support for multiple sources
  20053. * or `customizer` functions.
  20054. *
  20055. * @private
  20056. * @param {Object} object The destination object.
  20057. * @param {Object} source The source object.
  20058. * @returns {Object} Returns `object`.
  20059. */
  20060. function baseAssignIn(object, source) {
  20061. return object && copyObject(source, keysIn(source), object);
  20062. }
  20063. /**
  20064. * The base implementation of `assignValue` and `assignMergeValue` without
  20065. * value checks.
  20066. *
  20067. * @private
  20068. * @param {Object} object The object to modify.
  20069. * @param {string} key The key of the property to assign.
  20070. * @param {*} value The value to assign.
  20071. */
  20072. function baseAssignValue(object, key, value) {
  20073. if (key == '__proto__' && defineProperty) {
  20074. defineProperty(object, key, {
  20075. 'configurable': true,
  20076. 'enumerable': true,
  20077. 'value': value,
  20078. 'writable': true
  20079. });
  20080. } else {
  20081. object[key] = value;
  20082. }
  20083. }
  20084. /**
  20085. * The base implementation of `_.at` without support for individual paths.
  20086. *
  20087. * @private
  20088. * @param {Object} object The object to iterate over.
  20089. * @param {string[]} paths The property paths to pick.
  20090. * @returns {Array} Returns the picked elements.
  20091. */
  20092. function baseAt(object, paths) {
  20093. var index = -1,
  20094. length = paths.length,
  20095. result = Array(length),
  20096. skip = object == null;
  20097. while (++index < length) {
  20098. result[index] = skip ? undefined : get(object, paths[index]);
  20099. }
  20100. return result;
  20101. }
  20102. /**
  20103. * The base implementation of `_.clamp` which doesn't coerce arguments.
  20104. *
  20105. * @private
  20106. * @param {number} number The number to clamp.
  20107. * @param {number} [lower] The lower bound.
  20108. * @param {number} upper The upper bound.
  20109. * @returns {number} Returns the clamped number.
  20110. */
  20111. function baseClamp(number, lower, upper) {
  20112. if (number === number) {
  20113. if (upper !== undefined) {
  20114. number = number <= upper ? number : upper;
  20115. }
  20116. if (lower !== undefined) {
  20117. number = number >= lower ? number : lower;
  20118. }
  20119. }
  20120. return number;
  20121. }
  20122. /**
  20123. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  20124. * traversed objects.
  20125. *
  20126. * @private
  20127. * @param {*} value The value to clone.
  20128. * @param {boolean} bitmask The bitmask flags.
  20129. * 1 - Deep clone
  20130. * 2 - Flatten inherited properties
  20131. * 4 - Clone symbols
  20132. * @param {Function} [customizer] The function to customize cloning.
  20133. * @param {string} [key] The key of `value`.
  20134. * @param {Object} [object] The parent object of `value`.
  20135. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  20136. * @returns {*} Returns the cloned value.
  20137. */
  20138. function baseClone(value, bitmask, customizer, key, object, stack) {
  20139. var result,
  20140. isDeep = bitmask & CLONE_DEEP_FLAG,
  20141. isFlat = bitmask & CLONE_FLAT_FLAG,
  20142. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  20143. if (customizer) {
  20144. result = object ? customizer(value, key, object, stack) : customizer(value);
  20145. }
  20146. if (result !== undefined) {
  20147. return result;
  20148. }
  20149. if (!isObject(value)) {
  20150. return value;
  20151. }
  20152. var isArr = isArray(value);
  20153. if (isArr) {
  20154. result = initCloneArray(value);
  20155. if (!isDeep) {
  20156. return copyArray(value, result);
  20157. }
  20158. } else {
  20159. var tag = getTag(value),
  20160. isFunc = tag == funcTag || tag == genTag;
  20161. if (isBuffer(value)) {
  20162. return cloneBuffer(value, isDeep);
  20163. }
  20164. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  20165. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  20166. if (!isDeep) {
  20167. return isFlat
  20168. ? copySymbolsIn(value, baseAssignIn(result, value))
  20169. : copySymbols(value, baseAssign(result, value));
  20170. }
  20171. } else {
  20172. if (!cloneableTags[tag]) {
  20173. return object ? value : {};
  20174. }
  20175. result = initCloneByTag(value, tag, isDeep);
  20176. }
  20177. }
  20178. // Check for circular references and return its corresponding clone.
  20179. stack || (stack = new Stack);
  20180. var stacked = stack.get(value);
  20181. if (stacked) {
  20182. return stacked;
  20183. }
  20184. stack.set(value, result);
  20185. if (isSet(value)) {
  20186. value.forEach(function(subValue) {
  20187. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  20188. });
  20189. } else if (isMap(value)) {
  20190. value.forEach(function(subValue, key) {
  20191. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20192. });
  20193. }
  20194. var keysFunc = isFull
  20195. ? (isFlat ? getAllKeysIn : getAllKeys)
  20196. : (isFlat ? keysIn : keys);
  20197. var props = isArr ? undefined : keysFunc(value);
  20198. arrayEach(props || value, function(subValue, key) {
  20199. if (props) {
  20200. key = subValue;
  20201. subValue = value[key];
  20202. }
  20203. // Recursively populate clone (susceptible to call stack limits).
  20204. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20205. });
  20206. return result;
  20207. }
  20208. /**
  20209. * The base implementation of `_.conforms` which doesn't clone `source`.
  20210. *
  20211. * @private
  20212. * @param {Object} source The object of property predicates to conform to.
  20213. * @returns {Function} Returns the new spec function.
  20214. */
  20215. function baseConforms(source) {
  20216. var props = keys(source);
  20217. return function(object) {
  20218. return baseConformsTo(object, source, props);
  20219. };
  20220. }
  20221. /**
  20222. * The base implementation of `_.conformsTo` which accepts `props` to check.
  20223. *
  20224. * @private
  20225. * @param {Object} object The object to inspect.
  20226. * @param {Object} source The object of property predicates to conform to.
  20227. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  20228. */
  20229. function baseConformsTo(object, source, props) {
  20230. var length = props.length;
  20231. if (object == null) {
  20232. return !length;
  20233. }
  20234. object = Object(object);
  20235. while (length--) {
  20236. var key = props[length],
  20237. predicate = source[key],
  20238. value = object[key];
  20239. if ((value === undefined && !(key in object)) || !predicate(value)) {
  20240. return false;
  20241. }
  20242. }
  20243. return true;
  20244. }
  20245. /**
  20246. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  20247. * to provide to `func`.
  20248. *
  20249. * @private
  20250. * @param {Function} func The function to delay.
  20251. * @param {number} wait The number of milliseconds to delay invocation.
  20252. * @param {Array} args The arguments to provide to `func`.
  20253. * @returns {number|Object} Returns the timer id or timeout object.
  20254. */
  20255. function baseDelay(func, wait, args) {
  20256. if (typeof func != 'function') {
  20257. throw new TypeError(FUNC_ERROR_TEXT);
  20258. }
  20259. return setTimeout(function() { func.apply(undefined, args); }, wait);
  20260. }
  20261. /**
  20262. * The base implementation of methods like `_.difference` without support
  20263. * for excluding multiple arrays or iteratee shorthands.
  20264. *
  20265. * @private
  20266. * @param {Array} array The array to inspect.
  20267. * @param {Array} values The values to exclude.
  20268. * @param {Function} [iteratee] The iteratee invoked per element.
  20269. * @param {Function} [comparator] The comparator invoked per element.
  20270. * @returns {Array} Returns the new array of filtered values.
  20271. */
  20272. function baseDifference(array, values, iteratee, comparator) {
  20273. var index = -1,
  20274. includes = arrayIncludes,
  20275. isCommon = true,
  20276. length = array.length,
  20277. result = [],
  20278. valuesLength = values.length;
  20279. if (!length) {
  20280. return result;
  20281. }
  20282. if (iteratee) {
  20283. values = arrayMap(values, baseUnary(iteratee));
  20284. }
  20285. if (comparator) {
  20286. includes = arrayIncludesWith;
  20287. isCommon = false;
  20288. }
  20289. else if (values.length >= LARGE_ARRAY_SIZE) {
  20290. includes = cacheHas;
  20291. isCommon = false;
  20292. values = new SetCache(values);
  20293. }
  20294. outer:
  20295. while (++index < length) {
  20296. var value = array[index],
  20297. computed = iteratee == null ? value : iteratee(value);
  20298. value = (comparator || value !== 0) ? value : 0;
  20299. if (isCommon && computed === computed) {
  20300. var valuesIndex = valuesLength;
  20301. while (valuesIndex--) {
  20302. if (values[valuesIndex] === computed) {
  20303. continue outer;
  20304. }
  20305. }
  20306. result.push(value);
  20307. }
  20308. else if (!includes(values, computed, comparator)) {
  20309. result.push(value);
  20310. }
  20311. }
  20312. return result;
  20313. }
  20314. /**
  20315. * The base implementation of `_.forEach` without support for iteratee shorthands.
  20316. *
  20317. * @private
  20318. * @param {Array|Object} collection The collection to iterate over.
  20319. * @param {Function} iteratee The function invoked per iteration.
  20320. * @returns {Array|Object} Returns `collection`.
  20321. */
  20322. var baseEach = createBaseEach(baseForOwn);
  20323. /**
  20324. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  20325. *
  20326. * @private
  20327. * @param {Array|Object} collection The collection to iterate over.
  20328. * @param {Function} iteratee The function invoked per iteration.
  20329. * @returns {Array|Object} Returns `collection`.
  20330. */
  20331. var baseEachRight = createBaseEach(baseForOwnRight, true);
  20332. /**
  20333. * The base implementation of `_.every` without support for iteratee shorthands.
  20334. *
  20335. * @private
  20336. * @param {Array|Object} collection The collection to iterate over.
  20337. * @param {Function} predicate The function invoked per iteration.
  20338. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20339. * else `false`
  20340. */
  20341. function baseEvery(collection, predicate) {
  20342. var result = true;
  20343. baseEach(collection, function(value, index, collection) {
  20344. result = !!predicate(value, index, collection);
  20345. return result;
  20346. });
  20347. return result;
  20348. }
  20349. /**
  20350. * The base implementation of methods like `_.max` and `_.min` which accepts a
  20351. * `comparator` to determine the extremum value.
  20352. *
  20353. * @private
  20354. * @param {Array} array The array to iterate over.
  20355. * @param {Function} iteratee The iteratee invoked per iteration.
  20356. * @param {Function} comparator The comparator used to compare values.
  20357. * @returns {*} Returns the extremum value.
  20358. */
  20359. function baseExtremum(array, iteratee, comparator) {
  20360. var index = -1,
  20361. length = array.length;
  20362. while (++index < length) {
  20363. var value = array[index],
  20364. current = iteratee(value);
  20365. if (current != null && (computed === undefined
  20366. ? (current === current && !isSymbol(current))
  20367. : comparator(current, computed)
  20368. )) {
  20369. var computed = current,
  20370. result = value;
  20371. }
  20372. }
  20373. return result;
  20374. }
  20375. /**
  20376. * The base implementation of `_.fill` without an iteratee call guard.
  20377. *
  20378. * @private
  20379. * @param {Array} array The array to fill.
  20380. * @param {*} value The value to fill `array` with.
  20381. * @param {number} [start=0] The start position.
  20382. * @param {number} [end=array.length] The end position.
  20383. * @returns {Array} Returns `array`.
  20384. */
  20385. function baseFill(array, value, start, end) {
  20386. var length = array.length;
  20387. start = toInteger(start);
  20388. if (start < 0) {
  20389. start = -start > length ? 0 : (length + start);
  20390. }
  20391. end = (end === undefined || end > length) ? length : toInteger(end);
  20392. if (end < 0) {
  20393. end += length;
  20394. }
  20395. end = start > end ? 0 : toLength(end);
  20396. while (start < end) {
  20397. array[start++] = value;
  20398. }
  20399. return array;
  20400. }
  20401. /**
  20402. * The base implementation of `_.filter` without support for iteratee shorthands.
  20403. *
  20404. * @private
  20405. * @param {Array|Object} collection The collection to iterate over.
  20406. * @param {Function} predicate The function invoked per iteration.
  20407. * @returns {Array} Returns the new filtered array.
  20408. */
  20409. function baseFilter(collection, predicate) {
  20410. var result = [];
  20411. baseEach(collection, function(value, index, collection) {
  20412. if (predicate(value, index, collection)) {
  20413. result.push(value);
  20414. }
  20415. });
  20416. return result;
  20417. }
  20418. /**
  20419. * The base implementation of `_.flatten` with support for restricting flattening.
  20420. *
  20421. * @private
  20422. * @param {Array} array The array to flatten.
  20423. * @param {number} depth The maximum recursion depth.
  20424. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  20425. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  20426. * @param {Array} [result=[]] The initial result value.
  20427. * @returns {Array} Returns the new flattened array.
  20428. */
  20429. function baseFlatten(array, depth, predicate, isStrict, result) {
  20430. var index = -1,
  20431. length = array.length;
  20432. predicate || (predicate = isFlattenable);
  20433. result || (result = []);
  20434. while (++index < length) {
  20435. var value = array[index];
  20436. if (depth > 0 && predicate(value)) {
  20437. if (depth > 1) {
  20438. // Recursively flatten arrays (susceptible to call stack limits).
  20439. baseFlatten(value, depth - 1, predicate, isStrict, result);
  20440. } else {
  20441. arrayPush(result, value);
  20442. }
  20443. } else if (!isStrict) {
  20444. result[result.length] = value;
  20445. }
  20446. }
  20447. return result;
  20448. }
  20449. /**
  20450. * The base implementation of `baseForOwn` which iterates over `object`
  20451. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  20452. * Iteratee functions may exit iteration early by explicitly returning `false`.
  20453. *
  20454. * @private
  20455. * @param {Object} object The object to iterate over.
  20456. * @param {Function} iteratee The function invoked per iteration.
  20457. * @param {Function} keysFunc The function to get the keys of `object`.
  20458. * @returns {Object} Returns `object`.
  20459. */
  20460. var baseFor = createBaseFor();
  20461. /**
  20462. * This function is like `baseFor` except that it iterates over properties
  20463. * in the opposite order.
  20464. *
  20465. * @private
  20466. * @param {Object} object The object to iterate over.
  20467. * @param {Function} iteratee The function invoked per iteration.
  20468. * @param {Function} keysFunc The function to get the keys of `object`.
  20469. * @returns {Object} Returns `object`.
  20470. */
  20471. var baseForRight = createBaseFor(true);
  20472. /**
  20473. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  20474. *
  20475. * @private
  20476. * @param {Object} object The object to iterate over.
  20477. * @param {Function} iteratee The function invoked per iteration.
  20478. * @returns {Object} Returns `object`.
  20479. */
  20480. function baseForOwn(object, iteratee) {
  20481. return object && baseFor(object, iteratee, keys);
  20482. }
  20483. /**
  20484. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  20485. *
  20486. * @private
  20487. * @param {Object} object The object to iterate over.
  20488. * @param {Function} iteratee The function invoked per iteration.
  20489. * @returns {Object} Returns `object`.
  20490. */
  20491. function baseForOwnRight(object, iteratee) {
  20492. return object && baseForRight(object, iteratee, keys);
  20493. }
  20494. /**
  20495. * The base implementation of `_.functions` which creates an array of
  20496. * `object` function property names filtered from `props`.
  20497. *
  20498. * @private
  20499. * @param {Object} object The object to inspect.
  20500. * @param {Array} props The property names to filter.
  20501. * @returns {Array} Returns the function names.
  20502. */
  20503. function baseFunctions(object, props) {
  20504. return arrayFilter(props, function(key) {
  20505. return isFunction(object[key]);
  20506. });
  20507. }
  20508. /**
  20509. * The base implementation of `_.get` without support for default values.
  20510. *
  20511. * @private
  20512. * @param {Object} object The object to query.
  20513. * @param {Array|string} path The path of the property to get.
  20514. * @returns {*} Returns the resolved value.
  20515. */
  20516. function baseGet(object, path) {
  20517. path = castPath(path, object);
  20518. var index = 0,
  20519. length = path.length;
  20520. while (object != null && index < length) {
  20521. object = object[toKey(path[index++])];
  20522. }
  20523. return (index && index == length) ? object : undefined;
  20524. }
  20525. /**
  20526. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  20527. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  20528. * symbols of `object`.
  20529. *
  20530. * @private
  20531. * @param {Object} object The object to query.
  20532. * @param {Function} keysFunc The function to get the keys of `object`.
  20533. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  20534. * @returns {Array} Returns the array of property names and symbols.
  20535. */
  20536. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  20537. var result = keysFunc(object);
  20538. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  20539. }
  20540. /**
  20541. * The base implementation of `getTag` without fallbacks for buggy environments.
  20542. *
  20543. * @private
  20544. * @param {*} value The value to query.
  20545. * @returns {string} Returns the `toStringTag`.
  20546. */
  20547. function baseGetTag(value) {
  20548. if (value == null) {
  20549. return value === undefined ? undefinedTag : nullTag;
  20550. }
  20551. return (symToStringTag && symToStringTag in Object(value))
  20552. ? getRawTag(value)
  20553. : objectToString(value);
  20554. }
  20555. /**
  20556. * The base implementation of `_.gt` which doesn't coerce arguments.
  20557. *
  20558. * @private
  20559. * @param {*} value The value to compare.
  20560. * @param {*} other The other value to compare.
  20561. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  20562. * else `false`.
  20563. */
  20564. function baseGt(value, other) {
  20565. return value > other;
  20566. }
  20567. /**
  20568. * The base implementation of `_.has` without support for deep paths.
  20569. *
  20570. * @private
  20571. * @param {Object} [object] The object to query.
  20572. * @param {Array|string} key The key to check.
  20573. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20574. */
  20575. function baseHas(object, key) {
  20576. return object != null && hasOwnProperty.call(object, key);
  20577. }
  20578. /**
  20579. * The base implementation of `_.hasIn` without support for deep paths.
  20580. *
  20581. * @private
  20582. * @param {Object} [object] The object to query.
  20583. * @param {Array|string} key The key to check.
  20584. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20585. */
  20586. function baseHasIn(object, key) {
  20587. return object != null && key in Object(object);
  20588. }
  20589. /**
  20590. * The base implementation of `_.inRange` which doesn't coerce arguments.
  20591. *
  20592. * @private
  20593. * @param {number} number The number to check.
  20594. * @param {number} start The start of the range.
  20595. * @param {number} end The end of the range.
  20596. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  20597. */
  20598. function baseInRange(number, start, end) {
  20599. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  20600. }
  20601. /**
  20602. * The base implementation of methods like `_.intersection`, without support
  20603. * for iteratee shorthands, that accepts an array of arrays to inspect.
  20604. *
  20605. * @private
  20606. * @param {Array} arrays The arrays to inspect.
  20607. * @param {Function} [iteratee] The iteratee invoked per element.
  20608. * @param {Function} [comparator] The comparator invoked per element.
  20609. * @returns {Array} Returns the new array of shared values.
  20610. */
  20611. function baseIntersection(arrays, iteratee, comparator) {
  20612. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  20613. length = arrays[0].length,
  20614. othLength = arrays.length,
  20615. othIndex = othLength,
  20616. caches = Array(othLength),
  20617. maxLength = Infinity,
  20618. result = [];
  20619. while (othIndex--) {
  20620. var array = arrays[othIndex];
  20621. if (othIndex && iteratee) {
  20622. array = arrayMap(array, baseUnary(iteratee));
  20623. }
  20624. maxLength = nativeMin(array.length, maxLength);
  20625. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  20626. ? new SetCache(othIndex && array)
  20627. : undefined;
  20628. }
  20629. array = arrays[0];
  20630. var index = -1,
  20631. seen = caches[0];
  20632. outer:
  20633. while (++index < length && result.length < maxLength) {
  20634. var value = array[index],
  20635. computed = iteratee ? iteratee(value) : value;
  20636. value = (comparator || value !== 0) ? value : 0;
  20637. if (!(seen
  20638. ? cacheHas(seen, computed)
  20639. : includes(result, computed, comparator)
  20640. )) {
  20641. othIndex = othLength;
  20642. while (--othIndex) {
  20643. var cache = caches[othIndex];
  20644. if (!(cache
  20645. ? cacheHas(cache, computed)
  20646. : includes(arrays[othIndex], computed, comparator))
  20647. ) {
  20648. continue outer;
  20649. }
  20650. }
  20651. if (seen) {
  20652. seen.push(computed);
  20653. }
  20654. result.push(value);
  20655. }
  20656. }
  20657. return result;
  20658. }
  20659. /**
  20660. * The base implementation of `_.invert` and `_.invertBy` which inverts
  20661. * `object` with values transformed by `iteratee` and set by `setter`.
  20662. *
  20663. * @private
  20664. * @param {Object} object The object to iterate over.
  20665. * @param {Function} setter The function to set `accumulator` values.
  20666. * @param {Function} iteratee The iteratee to transform values.
  20667. * @param {Object} accumulator The initial inverted object.
  20668. * @returns {Function} Returns `accumulator`.
  20669. */
  20670. function baseInverter(object, setter, iteratee, accumulator) {
  20671. baseForOwn(object, function(value, key, object) {
  20672. setter(accumulator, iteratee(value), key, object);
  20673. });
  20674. return accumulator;
  20675. }
  20676. /**
  20677. * The base implementation of `_.invoke` without support for individual
  20678. * method arguments.
  20679. *
  20680. * @private
  20681. * @param {Object} object The object to query.
  20682. * @param {Array|string} path The path of the method to invoke.
  20683. * @param {Array} args The arguments to invoke the method with.
  20684. * @returns {*} Returns the result of the invoked method.
  20685. */
  20686. function baseInvoke(object, path, args) {
  20687. path = castPath(path, object);
  20688. object = parent(object, path);
  20689. var func = object == null ? object : object[toKey(last(path))];
  20690. return func == null ? undefined : apply(func, object, args);
  20691. }
  20692. /**
  20693. * The base implementation of `_.isArguments`.
  20694. *
  20695. * @private
  20696. * @param {*} value The value to check.
  20697. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  20698. */
  20699. function baseIsArguments(value) {
  20700. return isObjectLike(value) && baseGetTag(value) == argsTag;
  20701. }
  20702. /**
  20703. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  20704. *
  20705. * @private
  20706. * @param {*} value The value to check.
  20707. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  20708. */
  20709. function baseIsArrayBuffer(value) {
  20710. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  20711. }
  20712. /**
  20713. * The base implementation of `_.isDate` without Node.js optimizations.
  20714. *
  20715. * @private
  20716. * @param {*} value The value to check.
  20717. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  20718. */
  20719. function baseIsDate(value) {
  20720. return isObjectLike(value) && baseGetTag(value) == dateTag;
  20721. }
  20722. /**
  20723. * The base implementation of `_.isEqual` which supports partial comparisons
  20724. * and tracks traversed objects.
  20725. *
  20726. * @private
  20727. * @param {*} value The value to compare.
  20728. * @param {*} other The other value to compare.
  20729. * @param {boolean} bitmask The bitmask flags.
  20730. * 1 - Unordered comparison
  20731. * 2 - Partial comparison
  20732. * @param {Function} [customizer] The function to customize comparisons.
  20733. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  20734. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  20735. */
  20736. function baseIsEqual(value, other, bitmask, customizer, stack) {
  20737. if (value === other) {
  20738. return true;
  20739. }
  20740. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  20741. return value !== value && other !== other;
  20742. }
  20743. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  20744. }
  20745. /**
  20746. * A specialized version of `baseIsEqual` for arrays and objects which performs
  20747. * deep comparisons and tracks traversed objects enabling objects with circular
  20748. * references to be compared.
  20749. *
  20750. * @private
  20751. * @param {Object} object The object to compare.
  20752. * @param {Object} other The other object to compare.
  20753. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  20754. * @param {Function} customizer The function to customize comparisons.
  20755. * @param {Function} equalFunc The function to determine equivalents of values.
  20756. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  20757. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  20758. */
  20759. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  20760. var objIsArr = isArray(object),
  20761. othIsArr = isArray(other),
  20762. objTag = objIsArr ? arrayTag : getTag(object),
  20763. othTag = othIsArr ? arrayTag : getTag(other);
  20764. objTag = objTag == argsTag ? objectTag : objTag;
  20765. othTag = othTag == argsTag ? objectTag : othTag;
  20766. var objIsObj = objTag == objectTag,
  20767. othIsObj = othTag == objectTag,
  20768. isSameTag = objTag == othTag;
  20769. if (isSameTag && isBuffer(object)) {
  20770. if (!isBuffer(other)) {
  20771. return false;
  20772. }
  20773. objIsArr = true;
  20774. objIsObj = false;
  20775. }
  20776. if (isSameTag && !objIsObj) {
  20777. stack || (stack = new Stack);
  20778. return (objIsArr || isTypedArray(object))
  20779. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  20780. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  20781. }
  20782. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  20783. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  20784. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  20785. if (objIsWrapped || othIsWrapped) {
  20786. var objUnwrapped = objIsWrapped ? object.value() : object,
  20787. othUnwrapped = othIsWrapped ? other.value() : other;
  20788. stack || (stack = new Stack);
  20789. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  20790. }
  20791. }
  20792. if (!isSameTag) {
  20793. return false;
  20794. }
  20795. stack || (stack = new Stack);
  20796. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  20797. }
  20798. /**
  20799. * The base implementation of `_.isMap` without Node.js optimizations.
  20800. *
  20801. * @private
  20802. * @param {*} value The value to check.
  20803. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  20804. */
  20805. function baseIsMap(value) {
  20806. return isObjectLike(value) && getTag(value) == mapTag;
  20807. }
  20808. /**
  20809. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  20810. *
  20811. * @private
  20812. * @param {Object} object The object to inspect.
  20813. * @param {Object} source The object of property values to match.
  20814. * @param {Array} matchData The property names, values, and compare flags to match.
  20815. * @param {Function} [customizer] The function to customize comparisons.
  20816. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  20817. */
  20818. function baseIsMatch(object, source, matchData, customizer) {
  20819. var index = matchData.length,
  20820. length = index,
  20821. noCustomizer = !customizer;
  20822. if (object == null) {
  20823. return !length;
  20824. }
  20825. object = Object(object);
  20826. while (index--) {
  20827. var data = matchData[index];
  20828. if ((noCustomizer && data[2])
  20829. ? data[1] !== object[data[0]]
  20830. : !(data[0] in object)
  20831. ) {
  20832. return false;
  20833. }
  20834. }
  20835. while (++index < length) {
  20836. data = matchData[index];
  20837. var key = data[0],
  20838. objValue = object[key],
  20839. srcValue = data[1];
  20840. if (noCustomizer && data[2]) {
  20841. if (objValue === undefined && !(key in object)) {
  20842. return false;
  20843. }
  20844. } else {
  20845. var stack = new Stack;
  20846. if (customizer) {
  20847. var result = customizer(objValue, srcValue, key, object, source, stack);
  20848. }
  20849. if (!(result === undefined
  20850. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  20851. : result
  20852. )) {
  20853. return false;
  20854. }
  20855. }
  20856. }
  20857. return true;
  20858. }
  20859. /**
  20860. * The base implementation of `_.isNative` without bad shim checks.
  20861. *
  20862. * @private
  20863. * @param {*} value The value to check.
  20864. * @returns {boolean} Returns `true` if `value` is a native function,
  20865. * else `false`.
  20866. */
  20867. function baseIsNative(value) {
  20868. if (!isObject(value) || isMasked(value)) {
  20869. return false;
  20870. }
  20871. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  20872. return pattern.test(toSource(value));
  20873. }
  20874. /**
  20875. * The base implementation of `_.isRegExp` without Node.js optimizations.
  20876. *
  20877. * @private
  20878. * @param {*} value The value to check.
  20879. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  20880. */
  20881. function baseIsRegExp(value) {
  20882. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  20883. }
  20884. /**
  20885. * The base implementation of `_.isSet` without Node.js optimizations.
  20886. *
  20887. * @private
  20888. * @param {*} value The value to check.
  20889. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  20890. */
  20891. function baseIsSet(value) {
  20892. return isObjectLike(value) && getTag(value) == setTag;
  20893. }
  20894. /**
  20895. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  20896. *
  20897. * @private
  20898. * @param {*} value The value to check.
  20899. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  20900. */
  20901. function baseIsTypedArray(value) {
  20902. return isObjectLike(value) &&
  20903. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  20904. }
  20905. /**
  20906. * The base implementation of `_.iteratee`.
  20907. *
  20908. * @private
  20909. * @param {*} [value=_.identity] The value to convert to an iteratee.
  20910. * @returns {Function} Returns the iteratee.
  20911. */
  20912. function baseIteratee(value) {
  20913. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  20914. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  20915. if (typeof value == 'function') {
  20916. return value;
  20917. }
  20918. if (value == null) {
  20919. return identity;
  20920. }
  20921. if (typeof value == 'object') {
  20922. return isArray(value)
  20923. ? baseMatchesProperty(value[0], value[1])
  20924. : baseMatches(value);
  20925. }
  20926. return property(value);
  20927. }
  20928. /**
  20929. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  20930. *
  20931. * @private
  20932. * @param {Object} object The object to query.
  20933. * @returns {Array} Returns the array of property names.
  20934. */
  20935. function baseKeys(object) {
  20936. if (!isPrototype(object)) {
  20937. return nativeKeys(object);
  20938. }
  20939. var result = [];
  20940. for (var key in Object(object)) {
  20941. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  20942. result.push(key);
  20943. }
  20944. }
  20945. return result;
  20946. }
  20947. /**
  20948. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  20949. *
  20950. * @private
  20951. * @param {Object} object The object to query.
  20952. * @returns {Array} Returns the array of property names.
  20953. */
  20954. function baseKeysIn(object) {
  20955. if (!isObject(object)) {
  20956. return nativeKeysIn(object);
  20957. }
  20958. var isProto = isPrototype(object),
  20959. result = [];
  20960. for (var key in object) {
  20961. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  20962. result.push(key);
  20963. }
  20964. }
  20965. return result;
  20966. }
  20967. /**
  20968. * The base implementation of `_.lt` which doesn't coerce arguments.
  20969. *
  20970. * @private
  20971. * @param {*} value The value to compare.
  20972. * @param {*} other The other value to compare.
  20973. * @returns {boolean} Returns `true` if `value` is less than `other`,
  20974. * else `false`.
  20975. */
  20976. function baseLt(value, other) {
  20977. return value < other;
  20978. }
  20979. /**
  20980. * The base implementation of `_.map` without support for iteratee shorthands.
  20981. *
  20982. * @private
  20983. * @param {Array|Object} collection The collection to iterate over.
  20984. * @param {Function} iteratee The function invoked per iteration.
  20985. * @returns {Array} Returns the new mapped array.
  20986. */
  20987. function baseMap(collection, iteratee) {
  20988. var index = -1,
  20989. result = isArrayLike(collection) ? Array(collection.length) : [];
  20990. baseEach(collection, function(value, key, collection) {
  20991. result[++index] = iteratee(value, key, collection);
  20992. });
  20993. return result;
  20994. }
  20995. /**
  20996. * The base implementation of `_.matches` which doesn't clone `source`.
  20997. *
  20998. * @private
  20999. * @param {Object} source The object of property values to match.
  21000. * @returns {Function} Returns the new spec function.
  21001. */
  21002. function baseMatches(source) {
  21003. var matchData = getMatchData(source);
  21004. if (matchData.length == 1 && matchData[0][2]) {
  21005. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  21006. }
  21007. return function(object) {
  21008. return object === source || baseIsMatch(object, source, matchData);
  21009. };
  21010. }
  21011. /**
  21012. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  21013. *
  21014. * @private
  21015. * @param {string} path The path of the property to get.
  21016. * @param {*} srcValue The value to match.
  21017. * @returns {Function} Returns the new spec function.
  21018. */
  21019. function baseMatchesProperty(path, srcValue) {
  21020. if (isKey(path) && isStrictComparable(srcValue)) {
  21021. return matchesStrictComparable(toKey(path), srcValue);
  21022. }
  21023. return function(object) {
  21024. var objValue = get(object, path);
  21025. return (objValue === undefined && objValue === srcValue)
  21026. ? hasIn(object, path)
  21027. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  21028. };
  21029. }
  21030. /**
  21031. * The base implementation of `_.merge` without support for multiple sources.
  21032. *
  21033. * @private
  21034. * @param {Object} object The destination object.
  21035. * @param {Object} source The source object.
  21036. * @param {number} srcIndex The index of `source`.
  21037. * @param {Function} [customizer] The function to customize merged values.
  21038. * @param {Object} [stack] Tracks traversed source values and their merged
  21039. * counterparts.
  21040. */
  21041. function baseMerge(object, source, srcIndex, customizer, stack) {
  21042. if (object === source) {
  21043. return;
  21044. }
  21045. baseFor(source, function(srcValue, key) {
  21046. stack || (stack = new Stack);
  21047. if (isObject(srcValue)) {
  21048. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  21049. }
  21050. else {
  21051. var newValue = customizer
  21052. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  21053. : undefined;
  21054. if (newValue === undefined) {
  21055. newValue = srcValue;
  21056. }
  21057. assignMergeValue(object, key, newValue);
  21058. }
  21059. }, keysIn);
  21060. }
  21061. /**
  21062. * A specialized version of `baseMerge` for arrays and objects which performs
  21063. * deep merges and tracks traversed objects enabling objects with circular
  21064. * references to be merged.
  21065. *
  21066. * @private
  21067. * @param {Object} object The destination object.
  21068. * @param {Object} source The source object.
  21069. * @param {string} key The key of the value to merge.
  21070. * @param {number} srcIndex The index of `source`.
  21071. * @param {Function} mergeFunc The function to merge values.
  21072. * @param {Function} [customizer] The function to customize assigned values.
  21073. * @param {Object} [stack] Tracks traversed source values and their merged
  21074. * counterparts.
  21075. */
  21076. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  21077. var objValue = safeGet(object, key),
  21078. srcValue = safeGet(source, key),
  21079. stacked = stack.get(srcValue);
  21080. if (stacked) {
  21081. assignMergeValue(object, key, stacked);
  21082. return;
  21083. }
  21084. var newValue = customizer
  21085. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  21086. : undefined;
  21087. var isCommon = newValue === undefined;
  21088. if (isCommon) {
  21089. var isArr = isArray(srcValue),
  21090. isBuff = !isArr && isBuffer(srcValue),
  21091. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  21092. newValue = srcValue;
  21093. if (isArr || isBuff || isTyped) {
  21094. if (isArray(objValue)) {
  21095. newValue = objValue;
  21096. }
  21097. else if (isArrayLikeObject(objValue)) {
  21098. newValue = copyArray(objValue);
  21099. }
  21100. else if (isBuff) {
  21101. isCommon = false;
  21102. newValue = cloneBuffer(srcValue, true);
  21103. }
  21104. else if (isTyped) {
  21105. isCommon = false;
  21106. newValue = cloneTypedArray(srcValue, true);
  21107. }
  21108. else {
  21109. newValue = [];
  21110. }
  21111. }
  21112. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  21113. newValue = objValue;
  21114. if (isArguments(objValue)) {
  21115. newValue = toPlainObject(objValue);
  21116. }
  21117. else if (!isObject(objValue) || isFunction(objValue)) {
  21118. newValue = initCloneObject(srcValue);
  21119. }
  21120. }
  21121. else {
  21122. isCommon = false;
  21123. }
  21124. }
  21125. if (isCommon) {
  21126. // Recursively merge objects and arrays (susceptible to call stack limits).
  21127. stack.set(srcValue, newValue);
  21128. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  21129. stack['delete'](srcValue);
  21130. }
  21131. assignMergeValue(object, key, newValue);
  21132. }
  21133. /**
  21134. * The base implementation of `_.nth` which doesn't coerce arguments.
  21135. *
  21136. * @private
  21137. * @param {Array} array The array to query.
  21138. * @param {number} n The index of the element to return.
  21139. * @returns {*} Returns the nth element of `array`.
  21140. */
  21141. function baseNth(array, n) {
  21142. var length = array.length;
  21143. if (!length) {
  21144. return;
  21145. }
  21146. n += n < 0 ? length : 0;
  21147. return isIndex(n, length) ? array[n] : undefined;
  21148. }
  21149. /**
  21150. * The base implementation of `_.orderBy` without param guards.
  21151. *
  21152. * @private
  21153. * @param {Array|Object} collection The collection to iterate over.
  21154. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  21155. * @param {string[]} orders The sort orders of `iteratees`.
  21156. * @returns {Array} Returns the new sorted array.
  21157. */
  21158. function baseOrderBy(collection, iteratees, orders) {
  21159. var index = -1;
  21160. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  21161. var result = baseMap(collection, function(value, key, collection) {
  21162. var criteria = arrayMap(iteratees, function(iteratee) {
  21163. return iteratee(value);
  21164. });
  21165. return { 'criteria': criteria, 'index': ++index, 'value': value };
  21166. });
  21167. return baseSortBy(result, function(object, other) {
  21168. return compareMultiple(object, other, orders);
  21169. });
  21170. }
  21171. /**
  21172. * The base implementation of `_.pick` without support for individual
  21173. * property identifiers.
  21174. *
  21175. * @private
  21176. * @param {Object} object The source object.
  21177. * @param {string[]} paths The property paths to pick.
  21178. * @returns {Object} Returns the new object.
  21179. */
  21180. function basePick(object, paths) {
  21181. return basePickBy(object, paths, function(value, path) {
  21182. return hasIn(object, path);
  21183. });
  21184. }
  21185. /**
  21186. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  21187. *
  21188. * @private
  21189. * @param {Object} object The source object.
  21190. * @param {string[]} paths The property paths to pick.
  21191. * @param {Function} predicate The function invoked per property.
  21192. * @returns {Object} Returns the new object.
  21193. */
  21194. function basePickBy(object, paths, predicate) {
  21195. var index = -1,
  21196. length = paths.length,
  21197. result = {};
  21198. while (++index < length) {
  21199. var path = paths[index],
  21200. value = baseGet(object, path);
  21201. if (predicate(value, path)) {
  21202. baseSet(result, castPath(path, object), value);
  21203. }
  21204. }
  21205. return result;
  21206. }
  21207. /**
  21208. * A specialized version of `baseProperty` which supports deep paths.
  21209. *
  21210. * @private
  21211. * @param {Array|string} path The path of the property to get.
  21212. * @returns {Function} Returns the new accessor function.
  21213. */
  21214. function basePropertyDeep(path) {
  21215. return function(object) {
  21216. return baseGet(object, path);
  21217. };
  21218. }
  21219. /**
  21220. * The base implementation of `_.pullAllBy` without support for iteratee
  21221. * shorthands.
  21222. *
  21223. * @private
  21224. * @param {Array} array The array to modify.
  21225. * @param {Array} values The values to remove.
  21226. * @param {Function} [iteratee] The iteratee invoked per element.
  21227. * @param {Function} [comparator] The comparator invoked per element.
  21228. * @returns {Array} Returns `array`.
  21229. */
  21230. function basePullAll(array, values, iteratee, comparator) {
  21231. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  21232. index = -1,
  21233. length = values.length,
  21234. seen = array;
  21235. if (array === values) {
  21236. values = copyArray(values);
  21237. }
  21238. if (iteratee) {
  21239. seen = arrayMap(array, baseUnary(iteratee));
  21240. }
  21241. while (++index < length) {
  21242. var fromIndex = 0,
  21243. value = values[index],
  21244. computed = iteratee ? iteratee(value) : value;
  21245. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  21246. if (seen !== array) {
  21247. splice.call(seen, fromIndex, 1);
  21248. }
  21249. splice.call(array, fromIndex, 1);
  21250. }
  21251. }
  21252. return array;
  21253. }
  21254. /**
  21255. * The base implementation of `_.pullAt` without support for individual
  21256. * indexes or capturing the removed elements.
  21257. *
  21258. * @private
  21259. * @param {Array} array The array to modify.
  21260. * @param {number[]} indexes The indexes of elements to remove.
  21261. * @returns {Array} Returns `array`.
  21262. */
  21263. function basePullAt(array, indexes) {
  21264. var length = array ? indexes.length : 0,
  21265. lastIndex = length - 1;
  21266. while (length--) {
  21267. var index = indexes[length];
  21268. if (length == lastIndex || index !== previous) {
  21269. var previous = index;
  21270. if (isIndex(index)) {
  21271. splice.call(array, index, 1);
  21272. } else {
  21273. baseUnset(array, index);
  21274. }
  21275. }
  21276. }
  21277. return array;
  21278. }
  21279. /**
  21280. * The base implementation of `_.random` without support for returning
  21281. * floating-point numbers.
  21282. *
  21283. * @private
  21284. * @param {number} lower The lower bound.
  21285. * @param {number} upper The upper bound.
  21286. * @returns {number} Returns the random number.
  21287. */
  21288. function baseRandom(lower, upper) {
  21289. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  21290. }
  21291. /**
  21292. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  21293. * coerce arguments.
  21294. *
  21295. * @private
  21296. * @param {number} start The start of the range.
  21297. * @param {number} end The end of the range.
  21298. * @param {number} step The value to increment or decrement by.
  21299. * @param {boolean} [fromRight] Specify iterating from right to left.
  21300. * @returns {Array} Returns the range of numbers.
  21301. */
  21302. function baseRange(start, end, step, fromRight) {
  21303. var index = -1,
  21304. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  21305. result = Array(length);
  21306. while (length--) {
  21307. result[fromRight ? length : ++index] = start;
  21308. start += step;
  21309. }
  21310. return result;
  21311. }
  21312. /**
  21313. * The base implementation of `_.repeat` which doesn't coerce arguments.
  21314. *
  21315. * @private
  21316. * @param {string} string The string to repeat.
  21317. * @param {number} n The number of times to repeat the string.
  21318. * @returns {string} Returns the repeated string.
  21319. */
  21320. function baseRepeat(string, n) {
  21321. var result = '';
  21322. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  21323. return result;
  21324. }
  21325. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  21326. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  21327. do {
  21328. if (n % 2) {
  21329. result += string;
  21330. }
  21331. n = nativeFloor(n / 2);
  21332. if (n) {
  21333. string += string;
  21334. }
  21335. } while (n);
  21336. return result;
  21337. }
  21338. /**
  21339. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  21340. *
  21341. * @private
  21342. * @param {Function} func The function to apply a rest parameter to.
  21343. * @param {number} [start=func.length-1] The start position of the rest parameter.
  21344. * @returns {Function} Returns the new function.
  21345. */
  21346. function baseRest(func, start) {
  21347. return setToString(overRest(func, start, identity), func + '');
  21348. }
  21349. /**
  21350. * The base implementation of `_.sample`.
  21351. *
  21352. * @private
  21353. * @param {Array|Object} collection The collection to sample.
  21354. * @returns {*} Returns the random element.
  21355. */
  21356. function baseSample(collection) {
  21357. return arraySample(values(collection));
  21358. }
  21359. /**
  21360. * The base implementation of `_.sampleSize` without param guards.
  21361. *
  21362. * @private
  21363. * @param {Array|Object} collection The collection to sample.
  21364. * @param {number} n The number of elements to sample.
  21365. * @returns {Array} Returns the random elements.
  21366. */
  21367. function baseSampleSize(collection, n) {
  21368. var array = values(collection);
  21369. return shuffleSelf(array, baseClamp(n, 0, array.length));
  21370. }
  21371. /**
  21372. * The base implementation of `_.set`.
  21373. *
  21374. * @private
  21375. * @param {Object} object The object to modify.
  21376. * @param {Array|string} path The path of the property to set.
  21377. * @param {*} value The value to set.
  21378. * @param {Function} [customizer] The function to customize path creation.
  21379. * @returns {Object} Returns `object`.
  21380. */
  21381. function baseSet(object, path, value, customizer) {
  21382. if (!isObject(object)) {
  21383. return object;
  21384. }
  21385. path = castPath(path, object);
  21386. var index = -1,
  21387. length = path.length,
  21388. lastIndex = length - 1,
  21389. nested = object;
  21390. while (nested != null && ++index < length) {
  21391. var key = toKey(path[index]),
  21392. newValue = value;
  21393. if (index != lastIndex) {
  21394. var objValue = nested[key];
  21395. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  21396. if (newValue === undefined) {
  21397. newValue = isObject(objValue)
  21398. ? objValue
  21399. : (isIndex(path[index + 1]) ? [] : {});
  21400. }
  21401. }
  21402. assignValue(nested, key, newValue);
  21403. nested = nested[key];
  21404. }
  21405. return object;
  21406. }
  21407. /**
  21408. * The base implementation of `setData` without support for hot loop shorting.
  21409. *
  21410. * @private
  21411. * @param {Function} func The function to associate metadata with.
  21412. * @param {*} data The metadata.
  21413. * @returns {Function} Returns `func`.
  21414. */
  21415. var baseSetData = !metaMap ? identity : function(func, data) {
  21416. metaMap.set(func, data);
  21417. return func;
  21418. };
  21419. /**
  21420. * The base implementation of `setToString` without support for hot loop shorting.
  21421. *
  21422. * @private
  21423. * @param {Function} func The function to modify.
  21424. * @param {Function} string The `toString` result.
  21425. * @returns {Function} Returns `func`.
  21426. */
  21427. var baseSetToString = !defineProperty ? identity : function(func, string) {
  21428. return defineProperty(func, 'toString', {
  21429. 'configurable': true,
  21430. 'enumerable': false,
  21431. 'value': constant(string),
  21432. 'writable': true
  21433. });
  21434. };
  21435. /**
  21436. * The base implementation of `_.shuffle`.
  21437. *
  21438. * @private
  21439. * @param {Array|Object} collection The collection to shuffle.
  21440. * @returns {Array} Returns the new shuffled array.
  21441. */
  21442. function baseShuffle(collection) {
  21443. return shuffleSelf(values(collection));
  21444. }
  21445. /**
  21446. * The base implementation of `_.slice` without an iteratee call guard.
  21447. *
  21448. * @private
  21449. * @param {Array} array The array to slice.
  21450. * @param {number} [start=0] The start position.
  21451. * @param {number} [end=array.length] The end position.
  21452. * @returns {Array} Returns the slice of `array`.
  21453. */
  21454. function baseSlice(array, start, end) {
  21455. var index = -1,
  21456. length = array.length;
  21457. if (start < 0) {
  21458. start = -start > length ? 0 : (length + start);
  21459. }
  21460. end = end > length ? length : end;
  21461. if (end < 0) {
  21462. end += length;
  21463. }
  21464. length = start > end ? 0 : ((end - start) >>> 0);
  21465. start >>>= 0;
  21466. var result = Array(length);
  21467. while (++index < length) {
  21468. result[index] = array[index + start];
  21469. }
  21470. return result;
  21471. }
  21472. /**
  21473. * The base implementation of `_.some` without support for iteratee shorthands.
  21474. *
  21475. * @private
  21476. * @param {Array|Object} collection The collection to iterate over.
  21477. * @param {Function} predicate The function invoked per iteration.
  21478. * @returns {boolean} Returns `true` if any element passes the predicate check,
  21479. * else `false`.
  21480. */
  21481. function baseSome(collection, predicate) {
  21482. var result;
  21483. baseEach(collection, function(value, index, collection) {
  21484. result = predicate(value, index, collection);
  21485. return !result;
  21486. });
  21487. return !!result;
  21488. }
  21489. /**
  21490. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  21491. * performs a binary search of `array` to determine the index at which `value`
  21492. * should be inserted into `array` in order to maintain its sort order.
  21493. *
  21494. * @private
  21495. * @param {Array} array The sorted array to inspect.
  21496. * @param {*} value The value to evaluate.
  21497. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21498. * @returns {number} Returns the index at which `value` should be inserted
  21499. * into `array`.
  21500. */
  21501. function baseSortedIndex(array, value, retHighest) {
  21502. var low = 0,
  21503. high = array == null ? low : array.length;
  21504. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  21505. while (low < high) {
  21506. var mid = (low + high) >>> 1,
  21507. computed = array[mid];
  21508. if (computed !== null && !isSymbol(computed) &&
  21509. (retHighest ? (computed <= value) : (computed < value))) {
  21510. low = mid + 1;
  21511. } else {
  21512. high = mid;
  21513. }
  21514. }
  21515. return high;
  21516. }
  21517. return baseSortedIndexBy(array, value, identity, retHighest);
  21518. }
  21519. /**
  21520. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  21521. * which invokes `iteratee` for `value` and each element of `array` to compute
  21522. * their sort ranking. The iteratee is invoked with one argument; (value).
  21523. *
  21524. * @private
  21525. * @param {Array} array The sorted array to inspect.
  21526. * @param {*} value The value to evaluate.
  21527. * @param {Function} iteratee The iteratee invoked per element.
  21528. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21529. * @returns {number} Returns the index at which `value` should be inserted
  21530. * into `array`.
  21531. */
  21532. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  21533. value = iteratee(value);
  21534. var low = 0,
  21535. high = array == null ? 0 : array.length,
  21536. valIsNaN = value !== value,
  21537. valIsNull = value === null,
  21538. valIsSymbol = isSymbol(value),
  21539. valIsUndefined = value === undefined;
  21540. while (low < high) {
  21541. var mid = nativeFloor((low + high) / 2),
  21542. computed = iteratee(array[mid]),
  21543. othIsDefined = computed !== undefined,
  21544. othIsNull = computed === null,
  21545. othIsReflexive = computed === computed,
  21546. othIsSymbol = isSymbol(computed);
  21547. if (valIsNaN) {
  21548. var setLow = retHighest || othIsReflexive;
  21549. } else if (valIsUndefined) {
  21550. setLow = othIsReflexive && (retHighest || othIsDefined);
  21551. } else if (valIsNull) {
  21552. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  21553. } else if (valIsSymbol) {
  21554. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  21555. } else if (othIsNull || othIsSymbol) {
  21556. setLow = false;
  21557. } else {
  21558. setLow = retHighest ? (computed <= value) : (computed < value);
  21559. }
  21560. if (setLow) {
  21561. low = mid + 1;
  21562. } else {
  21563. high = mid;
  21564. }
  21565. }
  21566. return nativeMin(high, MAX_ARRAY_INDEX);
  21567. }
  21568. /**
  21569. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  21570. * support for iteratee shorthands.
  21571. *
  21572. * @private
  21573. * @param {Array} array The array to inspect.
  21574. * @param {Function} [iteratee] The iteratee invoked per element.
  21575. * @returns {Array} Returns the new duplicate free array.
  21576. */
  21577. function baseSortedUniq(array, iteratee) {
  21578. var index = -1,
  21579. length = array.length,
  21580. resIndex = 0,
  21581. result = [];
  21582. while (++index < length) {
  21583. var value = array[index],
  21584. computed = iteratee ? iteratee(value) : value;
  21585. if (!index || !eq(computed, seen)) {
  21586. var seen = computed;
  21587. result[resIndex++] = value === 0 ? 0 : value;
  21588. }
  21589. }
  21590. return result;
  21591. }
  21592. /**
  21593. * The base implementation of `_.toNumber` which doesn't ensure correct
  21594. * conversions of binary, hexadecimal, or octal string values.
  21595. *
  21596. * @private
  21597. * @param {*} value The value to process.
  21598. * @returns {number} Returns the number.
  21599. */
  21600. function baseToNumber(value) {
  21601. if (typeof value == 'number') {
  21602. return value;
  21603. }
  21604. if (isSymbol(value)) {
  21605. return NAN;
  21606. }
  21607. return +value;
  21608. }
  21609. /**
  21610. * The base implementation of `_.toString` which doesn't convert nullish
  21611. * values to empty strings.
  21612. *
  21613. * @private
  21614. * @param {*} value The value to process.
  21615. * @returns {string} Returns the string.
  21616. */
  21617. function baseToString(value) {
  21618. // Exit early for strings to avoid a performance hit in some environments.
  21619. if (typeof value == 'string') {
  21620. return value;
  21621. }
  21622. if (isArray(value)) {
  21623. // Recursively convert values (susceptible to call stack limits).
  21624. return arrayMap(value, baseToString) + '';
  21625. }
  21626. if (isSymbol(value)) {
  21627. return symbolToString ? symbolToString.call(value) : '';
  21628. }
  21629. var result = (value + '');
  21630. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  21631. }
  21632. /**
  21633. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  21634. *
  21635. * @private
  21636. * @param {Array} array The array to inspect.
  21637. * @param {Function} [iteratee] The iteratee invoked per element.
  21638. * @param {Function} [comparator] The comparator invoked per element.
  21639. * @returns {Array} Returns the new duplicate free array.
  21640. */
  21641. function baseUniq(array, iteratee, comparator) {
  21642. var index = -1,
  21643. includes = arrayIncludes,
  21644. length = array.length,
  21645. isCommon = true,
  21646. result = [],
  21647. seen = result;
  21648. if (comparator) {
  21649. isCommon = false;
  21650. includes = arrayIncludesWith;
  21651. }
  21652. else if (length >= LARGE_ARRAY_SIZE) {
  21653. var set = iteratee ? null : createSet(array);
  21654. if (set) {
  21655. return setToArray(set);
  21656. }
  21657. isCommon = false;
  21658. includes = cacheHas;
  21659. seen = new SetCache;
  21660. }
  21661. else {
  21662. seen = iteratee ? [] : result;
  21663. }
  21664. outer:
  21665. while (++index < length) {
  21666. var value = array[index],
  21667. computed = iteratee ? iteratee(value) : value;
  21668. value = (comparator || value !== 0) ? value : 0;
  21669. if (isCommon && computed === computed) {
  21670. var seenIndex = seen.length;
  21671. while (seenIndex--) {
  21672. if (seen[seenIndex] === computed) {
  21673. continue outer;
  21674. }
  21675. }
  21676. if (iteratee) {
  21677. seen.push(computed);
  21678. }
  21679. result.push(value);
  21680. }
  21681. else if (!includes(seen, computed, comparator)) {
  21682. if (seen !== result) {
  21683. seen.push(computed);
  21684. }
  21685. result.push(value);
  21686. }
  21687. }
  21688. return result;
  21689. }
  21690. /**
  21691. * The base implementation of `_.unset`.
  21692. *
  21693. * @private
  21694. * @param {Object} object The object to modify.
  21695. * @param {Array|string} path The property path to unset.
  21696. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  21697. */
  21698. function baseUnset(object, path) {
  21699. path = castPath(path, object);
  21700. object = parent(object, path);
  21701. return object == null || delete object[toKey(last(path))];
  21702. }
  21703. /**
  21704. * The base implementation of `_.update`.
  21705. *
  21706. * @private
  21707. * @param {Object} object The object to modify.
  21708. * @param {Array|string} path The path of the property to update.
  21709. * @param {Function} updater The function to produce the updated value.
  21710. * @param {Function} [customizer] The function to customize path creation.
  21711. * @returns {Object} Returns `object`.
  21712. */
  21713. function baseUpdate(object, path, updater, customizer) {
  21714. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  21715. }
  21716. /**
  21717. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  21718. * without support for iteratee shorthands.
  21719. *
  21720. * @private
  21721. * @param {Array} array The array to query.
  21722. * @param {Function} predicate The function invoked per iteration.
  21723. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  21724. * @param {boolean} [fromRight] Specify iterating from right to left.
  21725. * @returns {Array} Returns the slice of `array`.
  21726. */
  21727. function baseWhile(array, predicate, isDrop, fromRight) {
  21728. var length = array.length,
  21729. index = fromRight ? length : -1;
  21730. while ((fromRight ? index-- : ++index < length) &&
  21731. predicate(array[index], index, array)) {}
  21732. return isDrop
  21733. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  21734. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  21735. }
  21736. /**
  21737. * The base implementation of `wrapperValue` which returns the result of
  21738. * performing a sequence of actions on the unwrapped `value`, where each
  21739. * successive action is supplied the return value of the previous.
  21740. *
  21741. * @private
  21742. * @param {*} value The unwrapped value.
  21743. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  21744. * @returns {*} Returns the resolved value.
  21745. */
  21746. function baseWrapperValue(value, actions) {
  21747. var result = value;
  21748. if (result instanceof LazyWrapper) {
  21749. result = result.value();
  21750. }
  21751. return arrayReduce(actions, function(result, action) {
  21752. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  21753. }, result);
  21754. }
  21755. /**
  21756. * The base implementation of methods like `_.xor`, without support for
  21757. * iteratee shorthands, that accepts an array of arrays to inspect.
  21758. *
  21759. * @private
  21760. * @param {Array} arrays The arrays to inspect.
  21761. * @param {Function} [iteratee] The iteratee invoked per element.
  21762. * @param {Function} [comparator] The comparator invoked per element.
  21763. * @returns {Array} Returns the new array of values.
  21764. */
  21765. function baseXor(arrays, iteratee, comparator) {
  21766. var length = arrays.length;
  21767. if (length < 2) {
  21768. return length ? baseUniq(arrays[0]) : [];
  21769. }
  21770. var index = -1,
  21771. result = Array(length);
  21772. while (++index < length) {
  21773. var array = arrays[index],
  21774. othIndex = -1;
  21775. while (++othIndex < length) {
  21776. if (othIndex != index) {
  21777. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  21778. }
  21779. }
  21780. }
  21781. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  21782. }
  21783. /**
  21784. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  21785. *
  21786. * @private
  21787. * @param {Array} props The property identifiers.
  21788. * @param {Array} values The property values.
  21789. * @param {Function} assignFunc The function to assign values.
  21790. * @returns {Object} Returns the new object.
  21791. */
  21792. function baseZipObject(props, values, assignFunc) {
  21793. var index = -1,
  21794. length = props.length,
  21795. valsLength = values.length,
  21796. result = {};
  21797. while (++index < length) {
  21798. var value = index < valsLength ? values[index] : undefined;
  21799. assignFunc(result, props[index], value);
  21800. }
  21801. return result;
  21802. }
  21803. /**
  21804. * Casts `value` to an empty array if it's not an array like object.
  21805. *
  21806. * @private
  21807. * @param {*} value The value to inspect.
  21808. * @returns {Array|Object} Returns the cast array-like object.
  21809. */
  21810. function castArrayLikeObject(value) {
  21811. return isArrayLikeObject(value) ? value : [];
  21812. }
  21813. /**
  21814. * Casts `value` to `identity` if it's not a function.
  21815. *
  21816. * @private
  21817. * @param {*} value The value to inspect.
  21818. * @returns {Function} Returns cast function.
  21819. */
  21820. function castFunction(value) {
  21821. return typeof value == 'function' ? value : identity;
  21822. }
  21823. /**
  21824. * Casts `value` to a path array if it's not one.
  21825. *
  21826. * @private
  21827. * @param {*} value The value to inspect.
  21828. * @param {Object} [object] The object to query keys on.
  21829. * @returns {Array} Returns the cast property path array.
  21830. */
  21831. function castPath(value, object) {
  21832. if (isArray(value)) {
  21833. return value;
  21834. }
  21835. return isKey(value, object) ? [value] : stringToPath(toString(value));
  21836. }
  21837. /**
  21838. * A `baseRest` alias which can be replaced with `identity` by module
  21839. * replacement plugins.
  21840. *
  21841. * @private
  21842. * @type {Function}
  21843. * @param {Function} func The function to apply a rest parameter to.
  21844. * @returns {Function} Returns the new function.
  21845. */
  21846. var castRest = baseRest;
  21847. /**
  21848. * Casts `array` to a slice if it's needed.
  21849. *
  21850. * @private
  21851. * @param {Array} array The array to inspect.
  21852. * @param {number} start The start position.
  21853. * @param {number} [end=array.length] The end position.
  21854. * @returns {Array} Returns the cast slice.
  21855. */
  21856. function castSlice(array, start, end) {
  21857. var length = array.length;
  21858. end = end === undefined ? length : end;
  21859. return (!start && end >= length) ? array : baseSlice(array, start, end);
  21860. }
  21861. /**
  21862. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  21863. *
  21864. * @private
  21865. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  21866. */
  21867. var clearTimeout = ctxClearTimeout || function(id) {
  21868. return root.clearTimeout(id);
  21869. };
  21870. /**
  21871. * Creates a clone of `buffer`.
  21872. *
  21873. * @private
  21874. * @param {Buffer} buffer The buffer to clone.
  21875. * @param {boolean} [isDeep] Specify a deep clone.
  21876. * @returns {Buffer} Returns the cloned buffer.
  21877. */
  21878. function cloneBuffer(buffer, isDeep) {
  21879. if (isDeep) {
  21880. return buffer.slice();
  21881. }
  21882. var length = buffer.length,
  21883. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  21884. buffer.copy(result);
  21885. return result;
  21886. }
  21887. /**
  21888. * Creates a clone of `arrayBuffer`.
  21889. *
  21890. * @private
  21891. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  21892. * @returns {ArrayBuffer} Returns the cloned array buffer.
  21893. */
  21894. function cloneArrayBuffer(arrayBuffer) {
  21895. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  21896. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  21897. return result;
  21898. }
  21899. /**
  21900. * Creates a clone of `dataView`.
  21901. *
  21902. * @private
  21903. * @param {Object} dataView The data view to clone.
  21904. * @param {boolean} [isDeep] Specify a deep clone.
  21905. * @returns {Object} Returns the cloned data view.
  21906. */
  21907. function cloneDataView(dataView, isDeep) {
  21908. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  21909. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  21910. }
  21911. /**
  21912. * Creates a clone of `regexp`.
  21913. *
  21914. * @private
  21915. * @param {Object} regexp The regexp to clone.
  21916. * @returns {Object} Returns the cloned regexp.
  21917. */
  21918. function cloneRegExp(regexp) {
  21919. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  21920. result.lastIndex = regexp.lastIndex;
  21921. return result;
  21922. }
  21923. /**
  21924. * Creates a clone of the `symbol` object.
  21925. *
  21926. * @private
  21927. * @param {Object} symbol The symbol object to clone.
  21928. * @returns {Object} Returns the cloned symbol object.
  21929. */
  21930. function cloneSymbol(symbol) {
  21931. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  21932. }
  21933. /**
  21934. * Creates a clone of `typedArray`.
  21935. *
  21936. * @private
  21937. * @param {Object} typedArray The typed array to clone.
  21938. * @param {boolean} [isDeep] Specify a deep clone.
  21939. * @returns {Object} Returns the cloned typed array.
  21940. */
  21941. function cloneTypedArray(typedArray, isDeep) {
  21942. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  21943. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  21944. }
  21945. /**
  21946. * Compares values to sort them in ascending order.
  21947. *
  21948. * @private
  21949. * @param {*} value The value to compare.
  21950. * @param {*} other The other value to compare.
  21951. * @returns {number} Returns the sort order indicator for `value`.
  21952. */
  21953. function compareAscending(value, other) {
  21954. if (value !== other) {
  21955. var valIsDefined = value !== undefined,
  21956. valIsNull = value === null,
  21957. valIsReflexive = value === value,
  21958. valIsSymbol = isSymbol(value);
  21959. var othIsDefined = other !== undefined,
  21960. othIsNull = other === null,
  21961. othIsReflexive = other === other,
  21962. othIsSymbol = isSymbol(other);
  21963. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  21964. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  21965. (valIsNull && othIsDefined && othIsReflexive) ||
  21966. (!valIsDefined && othIsReflexive) ||
  21967. !valIsReflexive) {
  21968. return 1;
  21969. }
  21970. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21971. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21972. (othIsNull && valIsDefined && valIsReflexive) ||
  21973. (!othIsDefined && valIsReflexive) ||
  21974. !othIsReflexive) {
  21975. return -1;
  21976. }
  21977. }
  21978. return 0;
  21979. }
  21980. /**
  21981. * Used by `_.orderBy` to compare multiple properties of a value to another
  21982. * and stable sort them.
  21983. *
  21984. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21985. * specify an order of "desc" for descending or "asc" for ascending sort order
  21986. * of corresponding values.
  21987. *
  21988. * @private
  21989. * @param {Object} object The object to compare.
  21990. * @param {Object} other The other object to compare.
  21991. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21992. * @returns {number} Returns the sort order indicator for `object`.
  21993. */
  21994. function compareMultiple(object, other, orders) {
  21995. var index = -1,
  21996. objCriteria = object.criteria,
  21997. othCriteria = other.criteria,
  21998. length = objCriteria.length,
  21999. ordersLength = orders.length;
  22000. while (++index < length) {
  22001. var result = compareAscending(objCriteria[index], othCriteria[index]);
  22002. if (result) {
  22003. if (index >= ordersLength) {
  22004. return result;
  22005. }
  22006. var order = orders[index];
  22007. return result * (order == 'desc' ? -1 : 1);
  22008. }
  22009. }
  22010. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  22011. // that causes it, under certain circumstances, to provide the same value for
  22012. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  22013. // for more details.
  22014. //
  22015. // This also ensures a stable sort in V8 and other engines.
  22016. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  22017. return object.index - other.index;
  22018. }
  22019. /**
  22020. * Creates an array that is the composition of partially applied arguments,
  22021. * placeholders, and provided arguments into a single array of arguments.
  22022. *
  22023. * @private
  22024. * @param {Array} args The provided arguments.
  22025. * @param {Array} partials The arguments to prepend to those provided.
  22026. * @param {Array} holders The `partials` placeholder indexes.
  22027. * @params {boolean} [isCurried] Specify composing for a curried function.
  22028. * @returns {Array} Returns the new array of composed arguments.
  22029. */
  22030. function composeArgs(args, partials, holders, isCurried) {
  22031. var argsIndex = -1,
  22032. argsLength = args.length,
  22033. holdersLength = holders.length,
  22034. leftIndex = -1,
  22035. leftLength = partials.length,
  22036. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22037. result = Array(leftLength + rangeLength),
  22038. isUncurried = !isCurried;
  22039. while (++leftIndex < leftLength) {
  22040. result[leftIndex] = partials[leftIndex];
  22041. }
  22042. while (++argsIndex < holdersLength) {
  22043. if (isUncurried || argsIndex < argsLength) {
  22044. result[holders[argsIndex]] = args[argsIndex];
  22045. }
  22046. }
  22047. while (rangeLength--) {
  22048. result[leftIndex++] = args[argsIndex++];
  22049. }
  22050. return result;
  22051. }
  22052. /**
  22053. * This function is like `composeArgs` except that the arguments composition
  22054. * is tailored for `_.partialRight`.
  22055. *
  22056. * @private
  22057. * @param {Array} args The provided arguments.
  22058. * @param {Array} partials The arguments to append to those provided.
  22059. * @param {Array} holders The `partials` placeholder indexes.
  22060. * @params {boolean} [isCurried] Specify composing for a curried function.
  22061. * @returns {Array} Returns the new array of composed arguments.
  22062. */
  22063. function composeArgsRight(args, partials, holders, isCurried) {
  22064. var argsIndex = -1,
  22065. argsLength = args.length,
  22066. holdersIndex = -1,
  22067. holdersLength = holders.length,
  22068. rightIndex = -1,
  22069. rightLength = partials.length,
  22070. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22071. result = Array(rangeLength + rightLength),
  22072. isUncurried = !isCurried;
  22073. while (++argsIndex < rangeLength) {
  22074. result[argsIndex] = args[argsIndex];
  22075. }
  22076. var offset = argsIndex;
  22077. while (++rightIndex < rightLength) {
  22078. result[offset + rightIndex] = partials[rightIndex];
  22079. }
  22080. while (++holdersIndex < holdersLength) {
  22081. if (isUncurried || argsIndex < argsLength) {
  22082. result[offset + holders[holdersIndex]] = args[argsIndex++];
  22083. }
  22084. }
  22085. return result;
  22086. }
  22087. /**
  22088. * Copies the values of `source` to `array`.
  22089. *
  22090. * @private
  22091. * @param {Array} source The array to copy values from.
  22092. * @param {Array} [array=[]] The array to copy values to.
  22093. * @returns {Array} Returns `array`.
  22094. */
  22095. function copyArray(source, array) {
  22096. var index = -1,
  22097. length = source.length;
  22098. array || (array = Array(length));
  22099. while (++index < length) {
  22100. array[index] = source[index];
  22101. }
  22102. return array;
  22103. }
  22104. /**
  22105. * Copies properties of `source` to `object`.
  22106. *
  22107. * @private
  22108. * @param {Object} source The object to copy properties from.
  22109. * @param {Array} props The property identifiers to copy.
  22110. * @param {Object} [object={}] The object to copy properties to.
  22111. * @param {Function} [customizer] The function to customize copied values.
  22112. * @returns {Object} Returns `object`.
  22113. */
  22114. function copyObject(source, props, object, customizer) {
  22115. var isNew = !object;
  22116. object || (object = {});
  22117. var index = -1,
  22118. length = props.length;
  22119. while (++index < length) {
  22120. var key = props[index];
  22121. var newValue = customizer
  22122. ? customizer(object[key], source[key], key, object, source)
  22123. : undefined;
  22124. if (newValue === undefined) {
  22125. newValue = source[key];
  22126. }
  22127. if (isNew) {
  22128. baseAssignValue(object, key, newValue);
  22129. } else {
  22130. assignValue(object, key, newValue);
  22131. }
  22132. }
  22133. return object;
  22134. }
  22135. /**
  22136. * Copies own symbols of `source` to `object`.
  22137. *
  22138. * @private
  22139. * @param {Object} source The object to copy symbols from.
  22140. * @param {Object} [object={}] The object to copy symbols to.
  22141. * @returns {Object} Returns `object`.
  22142. */
  22143. function copySymbols(source, object) {
  22144. return copyObject(source, getSymbols(source), object);
  22145. }
  22146. /**
  22147. * Copies own and inherited symbols of `source` to `object`.
  22148. *
  22149. * @private
  22150. * @param {Object} source The object to copy symbols from.
  22151. * @param {Object} [object={}] The object to copy symbols to.
  22152. * @returns {Object} Returns `object`.
  22153. */
  22154. function copySymbolsIn(source, object) {
  22155. return copyObject(source, getSymbolsIn(source), object);
  22156. }
  22157. /**
  22158. * Creates a function like `_.groupBy`.
  22159. *
  22160. * @private
  22161. * @param {Function} setter The function to set accumulator values.
  22162. * @param {Function} [initializer] The accumulator object initializer.
  22163. * @returns {Function} Returns the new aggregator function.
  22164. */
  22165. function createAggregator(setter, initializer) {
  22166. return function(collection, iteratee) {
  22167. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  22168. accumulator = initializer ? initializer() : {};
  22169. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  22170. };
  22171. }
  22172. /**
  22173. * Creates a function like `_.assign`.
  22174. *
  22175. * @private
  22176. * @param {Function} assigner The function to assign values.
  22177. * @returns {Function} Returns the new assigner function.
  22178. */
  22179. function createAssigner(assigner) {
  22180. return baseRest(function(object, sources) {
  22181. var index = -1,
  22182. length = sources.length,
  22183. customizer = length > 1 ? sources[length - 1] : undefined,
  22184. guard = length > 2 ? sources[2] : undefined;
  22185. customizer = (assigner.length > 3 && typeof customizer == 'function')
  22186. ? (length--, customizer)
  22187. : undefined;
  22188. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  22189. customizer = length < 3 ? undefined : customizer;
  22190. length = 1;
  22191. }
  22192. object = Object(object);
  22193. while (++index < length) {
  22194. var source = sources[index];
  22195. if (source) {
  22196. assigner(object, source, index, customizer);
  22197. }
  22198. }
  22199. return object;
  22200. });
  22201. }
  22202. /**
  22203. * Creates a `baseEach` or `baseEachRight` function.
  22204. *
  22205. * @private
  22206. * @param {Function} eachFunc The function to iterate over a collection.
  22207. * @param {boolean} [fromRight] Specify iterating from right to left.
  22208. * @returns {Function} Returns the new base function.
  22209. */
  22210. function createBaseEach(eachFunc, fromRight) {
  22211. return function(collection, iteratee) {
  22212. if (collection == null) {
  22213. return collection;
  22214. }
  22215. if (!isArrayLike(collection)) {
  22216. return eachFunc(collection, iteratee);
  22217. }
  22218. var length = collection.length,
  22219. index = fromRight ? length : -1,
  22220. iterable = Object(collection);
  22221. while ((fromRight ? index-- : ++index < length)) {
  22222. if (iteratee(iterable[index], index, iterable) === false) {
  22223. break;
  22224. }
  22225. }
  22226. return collection;
  22227. };
  22228. }
  22229. /**
  22230. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  22231. *
  22232. * @private
  22233. * @param {boolean} [fromRight] Specify iterating from right to left.
  22234. * @returns {Function} Returns the new base function.
  22235. */
  22236. function createBaseFor(fromRight) {
  22237. return function(object, iteratee, keysFunc) {
  22238. var index = -1,
  22239. iterable = Object(object),
  22240. props = keysFunc(object),
  22241. length = props.length;
  22242. while (length--) {
  22243. var key = props[fromRight ? length : ++index];
  22244. if (iteratee(iterable[key], key, iterable) === false) {
  22245. break;
  22246. }
  22247. }
  22248. return object;
  22249. };
  22250. }
  22251. /**
  22252. * Creates a function that wraps `func` to invoke it with the optional `this`
  22253. * binding of `thisArg`.
  22254. *
  22255. * @private
  22256. * @param {Function} func The function to wrap.
  22257. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22258. * @param {*} [thisArg] The `this` binding of `func`.
  22259. * @returns {Function} Returns the new wrapped function.
  22260. */
  22261. function createBind(func, bitmask, thisArg) {
  22262. var isBind = bitmask & WRAP_BIND_FLAG,
  22263. Ctor = createCtor(func);
  22264. function wrapper() {
  22265. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22266. return fn.apply(isBind ? thisArg : this, arguments);
  22267. }
  22268. return wrapper;
  22269. }
  22270. /**
  22271. * Creates a function like `_.lowerFirst`.
  22272. *
  22273. * @private
  22274. * @param {string} methodName The name of the `String` case method to use.
  22275. * @returns {Function} Returns the new case function.
  22276. */
  22277. function createCaseFirst(methodName) {
  22278. return function(string) {
  22279. string = toString(string);
  22280. var strSymbols = hasUnicode(string)
  22281. ? stringToArray(string)
  22282. : undefined;
  22283. var chr = strSymbols
  22284. ? strSymbols[0]
  22285. : string.charAt(0);
  22286. var trailing = strSymbols
  22287. ? castSlice(strSymbols, 1).join('')
  22288. : string.slice(1);
  22289. return chr[methodName]() + trailing;
  22290. };
  22291. }
  22292. /**
  22293. * Creates a function like `_.camelCase`.
  22294. *
  22295. * @private
  22296. * @param {Function} callback The function to combine each word.
  22297. * @returns {Function} Returns the new compounder function.
  22298. */
  22299. function createCompounder(callback) {
  22300. return function(string) {
  22301. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  22302. };
  22303. }
  22304. /**
  22305. * Creates a function that produces an instance of `Ctor` regardless of
  22306. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  22307. *
  22308. * @private
  22309. * @param {Function} Ctor The constructor to wrap.
  22310. * @returns {Function} Returns the new wrapped function.
  22311. */
  22312. function createCtor(Ctor) {
  22313. return function() {
  22314. // Use a `switch` statement to work with class constructors. See
  22315. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  22316. // for more details.
  22317. var args = arguments;
  22318. switch (args.length) {
  22319. case 0: return new Ctor;
  22320. case 1: return new Ctor(args[0]);
  22321. case 2: return new Ctor(args[0], args[1]);
  22322. case 3: return new Ctor(args[0], args[1], args[2]);
  22323. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  22324. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  22325. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  22326. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  22327. }
  22328. var thisBinding = baseCreate(Ctor.prototype),
  22329. result = Ctor.apply(thisBinding, args);
  22330. // Mimic the constructor's `return` behavior.
  22331. // See https://es5.github.io/#x13.2.2 for more details.
  22332. return isObject(result) ? result : thisBinding;
  22333. };
  22334. }
  22335. /**
  22336. * Creates a function that wraps `func` to enable currying.
  22337. *
  22338. * @private
  22339. * @param {Function} func The function to wrap.
  22340. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22341. * @param {number} arity The arity of `func`.
  22342. * @returns {Function} Returns the new wrapped function.
  22343. */
  22344. function createCurry(func, bitmask, arity) {
  22345. var Ctor = createCtor(func);
  22346. function wrapper() {
  22347. var length = arguments.length,
  22348. args = Array(length),
  22349. index = length,
  22350. placeholder = getHolder(wrapper);
  22351. while (index--) {
  22352. args[index] = arguments[index];
  22353. }
  22354. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  22355. ? []
  22356. : replaceHolders(args, placeholder);
  22357. length -= holders.length;
  22358. if (length < arity) {
  22359. return createRecurry(
  22360. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  22361. args, holders, undefined, undefined, arity - length);
  22362. }
  22363. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22364. return apply(fn, this, args);
  22365. }
  22366. return wrapper;
  22367. }
  22368. /**
  22369. * Creates a `_.find` or `_.findLast` function.
  22370. *
  22371. * @private
  22372. * @param {Function} findIndexFunc The function to find the collection index.
  22373. * @returns {Function} Returns the new find function.
  22374. */
  22375. function createFind(findIndexFunc) {
  22376. return function(collection, predicate, fromIndex) {
  22377. var iterable = Object(collection);
  22378. if (!isArrayLike(collection)) {
  22379. var iteratee = getIteratee(predicate, 3);
  22380. collection = keys(collection);
  22381. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  22382. }
  22383. var index = findIndexFunc(collection, predicate, fromIndex);
  22384. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  22385. };
  22386. }
  22387. /**
  22388. * Creates a `_.flow` or `_.flowRight` function.
  22389. *
  22390. * @private
  22391. * @param {boolean} [fromRight] Specify iterating from right to left.
  22392. * @returns {Function} Returns the new flow function.
  22393. */
  22394. function createFlow(fromRight) {
  22395. return flatRest(function(funcs) {
  22396. var length = funcs.length,
  22397. index = length,
  22398. prereq = LodashWrapper.prototype.thru;
  22399. if (fromRight) {
  22400. funcs.reverse();
  22401. }
  22402. while (index--) {
  22403. var func = funcs[index];
  22404. if (typeof func != 'function') {
  22405. throw new TypeError(FUNC_ERROR_TEXT);
  22406. }
  22407. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  22408. var wrapper = new LodashWrapper([], true);
  22409. }
  22410. }
  22411. index = wrapper ? index : length;
  22412. while (++index < length) {
  22413. func = funcs[index];
  22414. var funcName = getFuncName(func),
  22415. data = funcName == 'wrapper' ? getData(func) : undefined;
  22416. if (data && isLaziable(data[0]) &&
  22417. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  22418. !data[4].length && data[9] == 1
  22419. ) {
  22420. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  22421. } else {
  22422. wrapper = (func.length == 1 && isLaziable(func))
  22423. ? wrapper[funcName]()
  22424. : wrapper.thru(func);
  22425. }
  22426. }
  22427. return function() {
  22428. var args = arguments,
  22429. value = args[0];
  22430. if (wrapper && args.length == 1 && isArray(value)) {
  22431. return wrapper.plant(value).value();
  22432. }
  22433. var index = 0,
  22434. result = length ? funcs[index].apply(this, args) : value;
  22435. while (++index < length) {
  22436. result = funcs[index].call(this, result);
  22437. }
  22438. return result;
  22439. };
  22440. });
  22441. }
  22442. /**
  22443. * Creates a function that wraps `func` to invoke it with optional `this`
  22444. * binding of `thisArg`, partial application, and currying.
  22445. *
  22446. * @private
  22447. * @param {Function|string} func The function or method name to wrap.
  22448. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22449. * @param {*} [thisArg] The `this` binding of `func`.
  22450. * @param {Array} [partials] The arguments to prepend to those provided to
  22451. * the new function.
  22452. * @param {Array} [holders] The `partials` placeholder indexes.
  22453. * @param {Array} [partialsRight] The arguments to append to those provided
  22454. * to the new function.
  22455. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  22456. * @param {Array} [argPos] The argument positions of the new function.
  22457. * @param {number} [ary] The arity cap of `func`.
  22458. * @param {number} [arity] The arity of `func`.
  22459. * @returns {Function} Returns the new wrapped function.
  22460. */
  22461. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  22462. var isAry = bitmask & WRAP_ARY_FLAG,
  22463. isBind = bitmask & WRAP_BIND_FLAG,
  22464. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  22465. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  22466. isFlip = bitmask & WRAP_FLIP_FLAG,
  22467. Ctor = isBindKey ? undefined : createCtor(func);
  22468. function wrapper() {
  22469. var length = arguments.length,
  22470. args = Array(length),
  22471. index = length;
  22472. while (index--) {
  22473. args[index] = arguments[index];
  22474. }
  22475. if (isCurried) {
  22476. var placeholder = getHolder(wrapper),
  22477. holdersCount = countHolders(args, placeholder);
  22478. }
  22479. if (partials) {
  22480. args = composeArgs(args, partials, holders, isCurried);
  22481. }
  22482. if (partialsRight) {
  22483. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  22484. }
  22485. length -= holdersCount;
  22486. if (isCurried && length < arity) {
  22487. var newHolders = replaceHolders(args, placeholder);
  22488. return createRecurry(
  22489. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  22490. args, newHolders, argPos, ary, arity - length
  22491. );
  22492. }
  22493. var thisBinding = isBind ? thisArg : this,
  22494. fn = isBindKey ? thisBinding[func] : func;
  22495. length = args.length;
  22496. if (argPos) {
  22497. args = reorder(args, argPos);
  22498. } else if (isFlip && length > 1) {
  22499. args.reverse();
  22500. }
  22501. if (isAry && ary < length) {
  22502. args.length = ary;
  22503. }
  22504. if (this && this !== root && this instanceof wrapper) {
  22505. fn = Ctor || createCtor(fn);
  22506. }
  22507. return fn.apply(thisBinding, args);
  22508. }
  22509. return wrapper;
  22510. }
  22511. /**
  22512. * Creates a function like `_.invertBy`.
  22513. *
  22514. * @private
  22515. * @param {Function} setter The function to set accumulator values.
  22516. * @param {Function} toIteratee The function to resolve iteratees.
  22517. * @returns {Function} Returns the new inverter function.
  22518. */
  22519. function createInverter(setter, toIteratee) {
  22520. return function(object, iteratee) {
  22521. return baseInverter(object, setter, toIteratee(iteratee), {});
  22522. };
  22523. }
  22524. /**
  22525. * Creates a function that performs a mathematical operation on two values.
  22526. *
  22527. * @private
  22528. * @param {Function} operator The function to perform the operation.
  22529. * @param {number} [defaultValue] The value used for `undefined` arguments.
  22530. * @returns {Function} Returns the new mathematical operation function.
  22531. */
  22532. function createMathOperation(operator, defaultValue) {
  22533. return function(value, other) {
  22534. var result;
  22535. if (value === undefined && other === undefined) {
  22536. return defaultValue;
  22537. }
  22538. if (value !== undefined) {
  22539. result = value;
  22540. }
  22541. if (other !== undefined) {
  22542. if (result === undefined) {
  22543. return other;
  22544. }
  22545. if (typeof value == 'string' || typeof other == 'string') {
  22546. value = baseToString(value);
  22547. other = baseToString(other);
  22548. } else {
  22549. value = baseToNumber(value);
  22550. other = baseToNumber(other);
  22551. }
  22552. result = operator(value, other);
  22553. }
  22554. return result;
  22555. };
  22556. }
  22557. /**
  22558. * Creates a function like `_.over`.
  22559. *
  22560. * @private
  22561. * @param {Function} arrayFunc The function to iterate over iteratees.
  22562. * @returns {Function} Returns the new over function.
  22563. */
  22564. function createOver(arrayFunc) {
  22565. return flatRest(function(iteratees) {
  22566. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  22567. return baseRest(function(args) {
  22568. var thisArg = this;
  22569. return arrayFunc(iteratees, function(iteratee) {
  22570. return apply(iteratee, thisArg, args);
  22571. });
  22572. });
  22573. });
  22574. }
  22575. /**
  22576. * Creates the padding for `string` based on `length`. The `chars` string
  22577. * is truncated if the number of characters exceeds `length`.
  22578. *
  22579. * @private
  22580. * @param {number} length The padding length.
  22581. * @param {string} [chars=' '] The string used as padding.
  22582. * @returns {string} Returns the padding for `string`.
  22583. */
  22584. function createPadding(length, chars) {
  22585. chars = chars === undefined ? ' ' : baseToString(chars);
  22586. var charsLength = chars.length;
  22587. if (charsLength < 2) {
  22588. return charsLength ? baseRepeat(chars, length) : chars;
  22589. }
  22590. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  22591. return hasUnicode(chars)
  22592. ? castSlice(stringToArray(result), 0, length).join('')
  22593. : result.slice(0, length);
  22594. }
  22595. /**
  22596. * Creates a function that wraps `func` to invoke it with the `this` binding
  22597. * of `thisArg` and `partials` prepended to the arguments it receives.
  22598. *
  22599. * @private
  22600. * @param {Function} func The function to wrap.
  22601. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22602. * @param {*} thisArg The `this` binding of `func`.
  22603. * @param {Array} partials The arguments to prepend to those provided to
  22604. * the new function.
  22605. * @returns {Function} Returns the new wrapped function.
  22606. */
  22607. function createPartial(func, bitmask, thisArg, partials) {
  22608. var isBind = bitmask & WRAP_BIND_FLAG,
  22609. Ctor = createCtor(func);
  22610. function wrapper() {
  22611. var argsIndex = -1,
  22612. argsLength = arguments.length,
  22613. leftIndex = -1,
  22614. leftLength = partials.length,
  22615. args = Array(leftLength + argsLength),
  22616. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22617. while (++leftIndex < leftLength) {
  22618. args[leftIndex] = partials[leftIndex];
  22619. }
  22620. while (argsLength--) {
  22621. args[leftIndex++] = arguments[++argsIndex];
  22622. }
  22623. return apply(fn, isBind ? thisArg : this, args);
  22624. }
  22625. return wrapper;
  22626. }
  22627. /**
  22628. * Creates a `_.range` or `_.rangeRight` function.
  22629. *
  22630. * @private
  22631. * @param {boolean} [fromRight] Specify iterating from right to left.
  22632. * @returns {Function} Returns the new range function.
  22633. */
  22634. function createRange(fromRight) {
  22635. return function(start, end, step) {
  22636. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  22637. end = step = undefined;
  22638. }
  22639. // Ensure the sign of `-0` is preserved.
  22640. start = toFinite(start);
  22641. if (end === undefined) {
  22642. end = start;
  22643. start = 0;
  22644. } else {
  22645. end = toFinite(end);
  22646. }
  22647. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  22648. return baseRange(start, end, step, fromRight);
  22649. };
  22650. }
  22651. /**
  22652. * Creates a function that performs a relational operation on two values.
  22653. *
  22654. * @private
  22655. * @param {Function} operator The function to perform the operation.
  22656. * @returns {Function} Returns the new relational operation function.
  22657. */
  22658. function createRelationalOperation(operator) {
  22659. return function(value, other) {
  22660. if (!(typeof value == 'string' && typeof other == 'string')) {
  22661. value = toNumber(value);
  22662. other = toNumber(other);
  22663. }
  22664. return operator(value, other);
  22665. };
  22666. }
  22667. /**
  22668. * Creates a function that wraps `func` to continue currying.
  22669. *
  22670. * @private
  22671. * @param {Function} func The function to wrap.
  22672. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22673. * @param {Function} wrapFunc The function to create the `func` wrapper.
  22674. * @param {*} placeholder The placeholder value.
  22675. * @param {*} [thisArg] The `this` binding of `func`.
  22676. * @param {Array} [partials] The arguments to prepend to those provided to
  22677. * the new function.
  22678. * @param {Array} [holders] The `partials` placeholder indexes.
  22679. * @param {Array} [argPos] The argument positions of the new function.
  22680. * @param {number} [ary] The arity cap of `func`.
  22681. * @param {number} [arity] The arity of `func`.
  22682. * @returns {Function} Returns the new wrapped function.
  22683. */
  22684. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  22685. var isCurry = bitmask & WRAP_CURRY_FLAG,
  22686. newHolders = isCurry ? holders : undefined,
  22687. newHoldersRight = isCurry ? undefined : holders,
  22688. newPartials = isCurry ? partials : undefined,
  22689. newPartialsRight = isCurry ? undefined : partials;
  22690. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  22691. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  22692. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  22693. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  22694. }
  22695. var newData = [
  22696. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  22697. newHoldersRight, argPos, ary, arity
  22698. ];
  22699. var result = wrapFunc.apply(undefined, newData);
  22700. if (isLaziable(func)) {
  22701. setData(result, newData);
  22702. }
  22703. result.placeholder = placeholder;
  22704. return setWrapToString(result, func, bitmask);
  22705. }
  22706. /**
  22707. * Creates a function like `_.round`.
  22708. *
  22709. * @private
  22710. * @param {string} methodName The name of the `Math` method to use when rounding.
  22711. * @returns {Function} Returns the new round function.
  22712. */
  22713. function createRound(methodName) {
  22714. var func = Math[methodName];
  22715. return function(number, precision) {
  22716. number = toNumber(number);
  22717. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  22718. if (precision && nativeIsFinite(number)) {
  22719. // Shift with exponential notation to avoid floating-point issues.
  22720. // See [MDN](https://mdn.io/round#Examples) for more details.
  22721. var pair = (toString(number) + 'e').split('e'),
  22722. value = func(pair[0] + 'e' + (+pair[1] + precision));
  22723. pair = (toString(value) + 'e').split('e');
  22724. return +(pair[0] + 'e' + (+pair[1] - precision));
  22725. }
  22726. return func(number);
  22727. };
  22728. }
  22729. /**
  22730. * Creates a set object of `values`.
  22731. *
  22732. * @private
  22733. * @param {Array} values The values to add to the set.
  22734. * @returns {Object} Returns the new set.
  22735. */
  22736. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  22737. return new Set(values);
  22738. };
  22739. /**
  22740. * Creates a `_.toPairs` or `_.toPairsIn` function.
  22741. *
  22742. * @private
  22743. * @param {Function} keysFunc The function to get the keys of a given object.
  22744. * @returns {Function} Returns the new pairs function.
  22745. */
  22746. function createToPairs(keysFunc) {
  22747. return function(object) {
  22748. var tag = getTag(object);
  22749. if (tag == mapTag) {
  22750. return mapToArray(object);
  22751. }
  22752. if (tag == setTag) {
  22753. return setToPairs(object);
  22754. }
  22755. return baseToPairs(object, keysFunc(object));
  22756. };
  22757. }
  22758. /**
  22759. * Creates a function that either curries or invokes `func` with optional
  22760. * `this` binding and partially applied arguments.
  22761. *
  22762. * @private
  22763. * @param {Function|string} func The function or method name to wrap.
  22764. * @param {number} bitmask The bitmask flags.
  22765. * 1 - `_.bind`
  22766. * 2 - `_.bindKey`
  22767. * 4 - `_.curry` or `_.curryRight` of a bound function
  22768. * 8 - `_.curry`
  22769. * 16 - `_.curryRight`
  22770. * 32 - `_.partial`
  22771. * 64 - `_.partialRight`
  22772. * 128 - `_.rearg`
  22773. * 256 - `_.ary`
  22774. * 512 - `_.flip`
  22775. * @param {*} [thisArg] The `this` binding of `func`.
  22776. * @param {Array} [partials] The arguments to be partially applied.
  22777. * @param {Array} [holders] The `partials` placeholder indexes.
  22778. * @param {Array} [argPos] The argument positions of the new function.
  22779. * @param {number} [ary] The arity cap of `func`.
  22780. * @param {number} [arity] The arity of `func`.
  22781. * @returns {Function} Returns the new wrapped function.
  22782. */
  22783. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  22784. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  22785. if (!isBindKey && typeof func != 'function') {
  22786. throw new TypeError(FUNC_ERROR_TEXT);
  22787. }
  22788. var length = partials ? partials.length : 0;
  22789. if (!length) {
  22790. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  22791. partials = holders = undefined;
  22792. }
  22793. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  22794. arity = arity === undefined ? arity : toInteger(arity);
  22795. length -= holders ? holders.length : 0;
  22796. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  22797. var partialsRight = partials,
  22798. holdersRight = holders;
  22799. partials = holders = undefined;
  22800. }
  22801. var data = isBindKey ? undefined : getData(func);
  22802. var newData = [
  22803. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  22804. argPos, ary, arity
  22805. ];
  22806. if (data) {
  22807. mergeData(newData, data);
  22808. }
  22809. func = newData[0];
  22810. bitmask = newData[1];
  22811. thisArg = newData[2];
  22812. partials = newData[3];
  22813. holders = newData[4];
  22814. arity = newData[9] = newData[9] === undefined
  22815. ? (isBindKey ? 0 : func.length)
  22816. : nativeMax(newData[9] - length, 0);
  22817. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  22818. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  22819. }
  22820. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  22821. var result = createBind(func, bitmask, thisArg);
  22822. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  22823. result = createCurry(func, bitmask, arity);
  22824. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  22825. result = createPartial(func, bitmask, thisArg, partials);
  22826. } else {
  22827. result = createHybrid.apply(undefined, newData);
  22828. }
  22829. var setter = data ? baseSetData : setData;
  22830. return setWrapToString(setter(result, newData), func, bitmask);
  22831. }
  22832. /**
  22833. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  22834. * of source objects to the destination object for all destination properties
  22835. * that resolve to `undefined`.
  22836. *
  22837. * @private
  22838. * @param {*} objValue The destination value.
  22839. * @param {*} srcValue The source value.
  22840. * @param {string} key The key of the property to assign.
  22841. * @param {Object} object The parent object of `objValue`.
  22842. * @returns {*} Returns the value to assign.
  22843. */
  22844. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  22845. if (objValue === undefined ||
  22846. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  22847. return srcValue;
  22848. }
  22849. return objValue;
  22850. }
  22851. /**
  22852. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  22853. * objects into destination objects that are passed thru.
  22854. *
  22855. * @private
  22856. * @param {*} objValue The destination value.
  22857. * @param {*} srcValue The source value.
  22858. * @param {string} key The key of the property to merge.
  22859. * @param {Object} object The parent object of `objValue`.
  22860. * @param {Object} source The parent object of `srcValue`.
  22861. * @param {Object} [stack] Tracks traversed source values and their merged
  22862. * counterparts.
  22863. * @returns {*} Returns the value to assign.
  22864. */
  22865. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  22866. if (isObject(objValue) && isObject(srcValue)) {
  22867. // Recursively merge objects and arrays (susceptible to call stack limits).
  22868. stack.set(srcValue, objValue);
  22869. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  22870. stack['delete'](srcValue);
  22871. }
  22872. return objValue;
  22873. }
  22874. /**
  22875. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  22876. * objects.
  22877. *
  22878. * @private
  22879. * @param {*} value The value to inspect.
  22880. * @param {string} key The key of the property to inspect.
  22881. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  22882. */
  22883. function customOmitClone(value) {
  22884. return isPlainObject(value) ? undefined : value;
  22885. }
  22886. /**
  22887. * A specialized version of `baseIsEqualDeep` for arrays with support for
  22888. * partial deep comparisons.
  22889. *
  22890. * @private
  22891. * @param {Array} array The array to compare.
  22892. * @param {Array} other The other array to compare.
  22893. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22894. * @param {Function} customizer The function to customize comparisons.
  22895. * @param {Function} equalFunc The function to determine equivalents of values.
  22896. * @param {Object} stack Tracks traversed `array` and `other` objects.
  22897. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  22898. */
  22899. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  22900. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22901. arrLength = array.length,
  22902. othLength = other.length;
  22903. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  22904. return false;
  22905. }
  22906. // Assume cyclic values are equal.
  22907. var stacked = stack.get(array);
  22908. if (stacked && stack.get(other)) {
  22909. return stacked == other;
  22910. }
  22911. var index = -1,
  22912. result = true,
  22913. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  22914. stack.set(array, other);
  22915. stack.set(other, array);
  22916. // Ignore non-index properties.
  22917. while (++index < arrLength) {
  22918. var arrValue = array[index],
  22919. othValue = other[index];
  22920. if (customizer) {
  22921. var compared = isPartial
  22922. ? customizer(othValue, arrValue, index, other, array, stack)
  22923. : customizer(arrValue, othValue, index, array, other, stack);
  22924. }
  22925. if (compared !== undefined) {
  22926. if (compared) {
  22927. continue;
  22928. }
  22929. result = false;
  22930. break;
  22931. }
  22932. // Recursively compare arrays (susceptible to call stack limits).
  22933. if (seen) {
  22934. if (!arraySome(other, function(othValue, othIndex) {
  22935. if (!cacheHas(seen, othIndex) &&
  22936. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22937. return seen.push(othIndex);
  22938. }
  22939. })) {
  22940. result = false;
  22941. break;
  22942. }
  22943. } else if (!(
  22944. arrValue === othValue ||
  22945. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  22946. )) {
  22947. result = false;
  22948. break;
  22949. }
  22950. }
  22951. stack['delete'](array);
  22952. stack['delete'](other);
  22953. return result;
  22954. }
  22955. /**
  22956. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22957. * the same `toStringTag`.
  22958. *
  22959. * **Note:** This function only supports comparing values with tags of
  22960. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22961. *
  22962. * @private
  22963. * @param {Object} object The object to compare.
  22964. * @param {Object} other The other object to compare.
  22965. * @param {string} tag The `toStringTag` of the objects to compare.
  22966. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22967. * @param {Function} customizer The function to customize comparisons.
  22968. * @param {Function} equalFunc The function to determine equivalents of values.
  22969. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22970. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22971. */
  22972. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22973. switch (tag) {
  22974. case dataViewTag:
  22975. if ((object.byteLength != other.byteLength) ||
  22976. (object.byteOffset != other.byteOffset)) {
  22977. return false;
  22978. }
  22979. object = object.buffer;
  22980. other = other.buffer;
  22981. case arrayBufferTag:
  22982. if ((object.byteLength != other.byteLength) ||
  22983. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22984. return false;
  22985. }
  22986. return true;
  22987. case boolTag:
  22988. case dateTag:
  22989. case numberTag:
  22990. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22991. // Invalid dates are coerced to `NaN`.
  22992. return eq(+object, +other);
  22993. case errorTag:
  22994. return object.name == other.name && object.message == other.message;
  22995. case regexpTag:
  22996. case stringTag:
  22997. // Coerce regexes to strings and treat strings, primitives and objects,
  22998. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22999. // for more details.
  23000. return object == (other + '');
  23001. case mapTag:
  23002. var convert = mapToArray;
  23003. case setTag:
  23004. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  23005. convert || (convert = setToArray);
  23006. if (object.size != other.size && !isPartial) {
  23007. return false;
  23008. }
  23009. // Assume cyclic values are equal.
  23010. var stacked = stack.get(object);
  23011. if (stacked) {
  23012. return stacked == other;
  23013. }
  23014. bitmask |= COMPARE_UNORDERED_FLAG;
  23015. // Recursively compare objects (susceptible to call stack limits).
  23016. stack.set(object, other);
  23017. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  23018. stack['delete'](object);
  23019. return result;
  23020. case symbolTag:
  23021. if (symbolValueOf) {
  23022. return symbolValueOf.call(object) == symbolValueOf.call(other);
  23023. }
  23024. }
  23025. return false;
  23026. }
  23027. /**
  23028. * A specialized version of `baseIsEqualDeep` for objects with support for
  23029. * partial deep comparisons.
  23030. *
  23031. * @private
  23032. * @param {Object} object The object to compare.
  23033. * @param {Object} other The other object to compare.
  23034. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23035. * @param {Function} customizer The function to customize comparisons.
  23036. * @param {Function} equalFunc The function to determine equivalents of values.
  23037. * @param {Object} stack Tracks traversed `object` and `other` objects.
  23038. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23039. */
  23040. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  23041. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  23042. objProps = getAllKeys(object),
  23043. objLength = objProps.length,
  23044. othProps = getAllKeys(other),
  23045. othLength = othProps.length;
  23046. if (objLength != othLength && !isPartial) {
  23047. return false;
  23048. }
  23049. var index = objLength;
  23050. while (index--) {
  23051. var key = objProps[index];
  23052. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  23053. return false;
  23054. }
  23055. }
  23056. // Assume cyclic values are equal.
  23057. var stacked = stack.get(object);
  23058. if (stacked && stack.get(other)) {
  23059. return stacked == other;
  23060. }
  23061. var result = true;
  23062. stack.set(object, other);
  23063. stack.set(other, object);
  23064. var skipCtor = isPartial;
  23065. while (++index < objLength) {
  23066. key = objProps[index];
  23067. var objValue = object[key],
  23068. othValue = other[key];
  23069. if (customizer) {
  23070. var compared = isPartial
  23071. ? customizer(othValue, objValue, key, other, object, stack)
  23072. : customizer(objValue, othValue, key, object, other, stack);
  23073. }
  23074. // Recursively compare objects (susceptible to call stack limits).
  23075. if (!(compared === undefined
  23076. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  23077. : compared
  23078. )) {
  23079. result = false;
  23080. break;
  23081. }
  23082. skipCtor || (skipCtor = key == 'constructor');
  23083. }
  23084. if (result && !skipCtor) {
  23085. var objCtor = object.constructor,
  23086. othCtor = other.constructor;
  23087. // Non `Object` object instances with different constructors are not equal.
  23088. if (objCtor != othCtor &&
  23089. ('constructor' in object && 'constructor' in other) &&
  23090. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  23091. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  23092. result = false;
  23093. }
  23094. }
  23095. stack['delete'](object);
  23096. stack['delete'](other);
  23097. return result;
  23098. }
  23099. /**
  23100. * A specialized version of `baseRest` which flattens the rest array.
  23101. *
  23102. * @private
  23103. * @param {Function} func The function to apply a rest parameter to.
  23104. * @returns {Function} Returns the new function.
  23105. */
  23106. function flatRest(func) {
  23107. return setToString(overRest(func, undefined, flatten), func + '');
  23108. }
  23109. /**
  23110. * Creates an array of own enumerable property names and symbols of `object`.
  23111. *
  23112. * @private
  23113. * @param {Object} object The object to query.
  23114. * @returns {Array} Returns the array of property names and symbols.
  23115. */
  23116. function getAllKeys(object) {
  23117. return baseGetAllKeys(object, keys, getSymbols);
  23118. }
  23119. /**
  23120. * Creates an array of own and inherited enumerable property names and
  23121. * symbols of `object`.
  23122. *
  23123. * @private
  23124. * @param {Object} object The object to query.
  23125. * @returns {Array} Returns the array of property names and symbols.
  23126. */
  23127. function getAllKeysIn(object) {
  23128. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  23129. }
  23130. /**
  23131. * Gets metadata for `func`.
  23132. *
  23133. * @private
  23134. * @param {Function} func The function to query.
  23135. * @returns {*} Returns the metadata for `func`.
  23136. */
  23137. var getData = !metaMap ? noop : function(func) {
  23138. return metaMap.get(func);
  23139. };
  23140. /**
  23141. * Gets the name of `func`.
  23142. *
  23143. * @private
  23144. * @param {Function} func The function to query.
  23145. * @returns {string} Returns the function name.
  23146. */
  23147. function getFuncName(func) {
  23148. var result = (func.name + ''),
  23149. array = realNames[result],
  23150. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  23151. while (length--) {
  23152. var data = array[length],
  23153. otherFunc = data.func;
  23154. if (otherFunc == null || otherFunc == func) {
  23155. return data.name;
  23156. }
  23157. }
  23158. return result;
  23159. }
  23160. /**
  23161. * Gets the argument placeholder value for `func`.
  23162. *
  23163. * @private
  23164. * @param {Function} func The function to inspect.
  23165. * @returns {*} Returns the placeholder value.
  23166. */
  23167. function getHolder(func) {
  23168. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  23169. return object.placeholder;
  23170. }
  23171. /**
  23172. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  23173. * this function returns the custom method, otherwise it returns `baseIteratee`.
  23174. * If arguments are provided, the chosen function is invoked with them and
  23175. * its result is returned.
  23176. *
  23177. * @private
  23178. * @param {*} [value] The value to convert to an iteratee.
  23179. * @param {number} [arity] The arity of the created iteratee.
  23180. * @returns {Function} Returns the chosen function or its result.
  23181. */
  23182. function getIteratee() {
  23183. var result = lodash.iteratee || iteratee;
  23184. result = result === iteratee ? baseIteratee : result;
  23185. return arguments.length ? result(arguments[0], arguments[1]) : result;
  23186. }
  23187. /**
  23188. * Gets the data for `map`.
  23189. *
  23190. * @private
  23191. * @param {Object} map The map to query.
  23192. * @param {string} key The reference key.
  23193. * @returns {*} Returns the map data.
  23194. */
  23195. function getMapData(map, key) {
  23196. var data = map.__data__;
  23197. return isKeyable(key)
  23198. ? data[typeof key == 'string' ? 'string' : 'hash']
  23199. : data.map;
  23200. }
  23201. /**
  23202. * Gets the property names, values, and compare flags of `object`.
  23203. *
  23204. * @private
  23205. * @param {Object} object The object to query.
  23206. * @returns {Array} Returns the match data of `object`.
  23207. */
  23208. function getMatchData(object) {
  23209. var result = keys(object),
  23210. length = result.length;
  23211. while (length--) {
  23212. var key = result[length],
  23213. value = object[key];
  23214. result[length] = [key, value, isStrictComparable(value)];
  23215. }
  23216. return result;
  23217. }
  23218. /**
  23219. * Gets the native function at `key` of `object`.
  23220. *
  23221. * @private
  23222. * @param {Object} object The object to query.
  23223. * @param {string} key The key of the method to get.
  23224. * @returns {*} Returns the function if it's native, else `undefined`.
  23225. */
  23226. function getNative(object, key) {
  23227. var value = getValue(object, key);
  23228. return baseIsNative(value) ? value : undefined;
  23229. }
  23230. /**
  23231. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  23232. *
  23233. * @private
  23234. * @param {*} value The value to query.
  23235. * @returns {string} Returns the raw `toStringTag`.
  23236. */
  23237. function getRawTag(value) {
  23238. var isOwn = hasOwnProperty.call(value, symToStringTag),
  23239. tag = value[symToStringTag];
  23240. try {
  23241. value[symToStringTag] = undefined;
  23242. var unmasked = true;
  23243. } catch (e) {}
  23244. var result = nativeObjectToString.call(value);
  23245. if (unmasked) {
  23246. if (isOwn) {
  23247. value[symToStringTag] = tag;
  23248. } else {
  23249. delete value[symToStringTag];
  23250. }
  23251. }
  23252. return result;
  23253. }
  23254. /**
  23255. * Creates an array of the own enumerable symbols of `object`.
  23256. *
  23257. * @private
  23258. * @param {Object} object The object to query.
  23259. * @returns {Array} Returns the array of symbols.
  23260. */
  23261. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  23262. if (object == null) {
  23263. return [];
  23264. }
  23265. object = Object(object);
  23266. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  23267. return propertyIsEnumerable.call(object, symbol);
  23268. });
  23269. };
  23270. /**
  23271. * Creates an array of the own and inherited enumerable symbols of `object`.
  23272. *
  23273. * @private
  23274. * @param {Object} object The object to query.
  23275. * @returns {Array} Returns the array of symbols.
  23276. */
  23277. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  23278. var result = [];
  23279. while (object) {
  23280. arrayPush(result, getSymbols(object));
  23281. object = getPrototype(object);
  23282. }
  23283. return result;
  23284. };
  23285. /**
  23286. * Gets the `toStringTag` of `value`.
  23287. *
  23288. * @private
  23289. * @param {*} value The value to query.
  23290. * @returns {string} Returns the `toStringTag`.
  23291. */
  23292. var getTag = baseGetTag;
  23293. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  23294. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  23295. (Map && getTag(new Map) != mapTag) ||
  23296. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  23297. (Set && getTag(new Set) != setTag) ||
  23298. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  23299. getTag = function(value) {
  23300. var result = baseGetTag(value),
  23301. Ctor = result == objectTag ? value.constructor : undefined,
  23302. ctorString = Ctor ? toSource(Ctor) : '';
  23303. if (ctorString) {
  23304. switch (ctorString) {
  23305. case dataViewCtorString: return dataViewTag;
  23306. case mapCtorString: return mapTag;
  23307. case promiseCtorString: return promiseTag;
  23308. case setCtorString: return setTag;
  23309. case weakMapCtorString: return weakMapTag;
  23310. }
  23311. }
  23312. return result;
  23313. };
  23314. }
  23315. /**
  23316. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  23317. *
  23318. * @private
  23319. * @param {number} start The start of the view.
  23320. * @param {number} end The end of the view.
  23321. * @param {Array} transforms The transformations to apply to the view.
  23322. * @returns {Object} Returns an object containing the `start` and `end`
  23323. * positions of the view.
  23324. */
  23325. function getView(start, end, transforms) {
  23326. var index = -1,
  23327. length = transforms.length;
  23328. while (++index < length) {
  23329. var data = transforms[index],
  23330. size = data.size;
  23331. switch (data.type) {
  23332. case 'drop': start += size; break;
  23333. case 'dropRight': end -= size; break;
  23334. case 'take': end = nativeMin(end, start + size); break;
  23335. case 'takeRight': start = nativeMax(start, end - size); break;
  23336. }
  23337. }
  23338. return { 'start': start, 'end': end };
  23339. }
  23340. /**
  23341. * Extracts wrapper details from the `source` body comment.
  23342. *
  23343. * @private
  23344. * @param {string} source The source to inspect.
  23345. * @returns {Array} Returns the wrapper details.
  23346. */
  23347. function getWrapDetails(source) {
  23348. var match = source.match(reWrapDetails);
  23349. return match ? match[1].split(reSplitDetails) : [];
  23350. }
  23351. /**
  23352. * Checks if `path` exists on `object`.
  23353. *
  23354. * @private
  23355. * @param {Object} object The object to query.
  23356. * @param {Array|string} path The path to check.
  23357. * @param {Function} hasFunc The function to check properties.
  23358. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  23359. */
  23360. function hasPath(object, path, hasFunc) {
  23361. path = castPath(path, object);
  23362. var index = -1,
  23363. length = path.length,
  23364. result = false;
  23365. while (++index < length) {
  23366. var key = toKey(path[index]);
  23367. if (!(result = object != null && hasFunc(object, key))) {
  23368. break;
  23369. }
  23370. object = object[key];
  23371. }
  23372. if (result || ++index != length) {
  23373. return result;
  23374. }
  23375. length = object == null ? 0 : object.length;
  23376. return !!length && isLength(length) && isIndex(key, length) &&
  23377. (isArray(object) || isArguments(object));
  23378. }
  23379. /**
  23380. * Initializes an array clone.
  23381. *
  23382. * @private
  23383. * @param {Array} array The array to clone.
  23384. * @returns {Array} Returns the initialized clone.
  23385. */
  23386. function initCloneArray(array) {
  23387. var length = array.length,
  23388. result = new array.constructor(length);
  23389. // Add properties assigned by `RegExp#exec`.
  23390. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  23391. result.index = array.index;
  23392. result.input = array.input;
  23393. }
  23394. return result;
  23395. }
  23396. /**
  23397. * Initializes an object clone.
  23398. *
  23399. * @private
  23400. * @param {Object} object The object to clone.
  23401. * @returns {Object} Returns the initialized clone.
  23402. */
  23403. function initCloneObject(object) {
  23404. return (typeof object.constructor == 'function' && !isPrototype(object))
  23405. ? baseCreate(getPrototype(object))
  23406. : {};
  23407. }
  23408. /**
  23409. * Initializes an object clone based on its `toStringTag`.
  23410. *
  23411. * **Note:** This function only supports cloning values with tags of
  23412. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  23413. *
  23414. * @private
  23415. * @param {Object} object The object to clone.
  23416. * @param {string} tag The `toStringTag` of the object to clone.
  23417. * @param {boolean} [isDeep] Specify a deep clone.
  23418. * @returns {Object} Returns the initialized clone.
  23419. */
  23420. function initCloneByTag(object, tag, isDeep) {
  23421. var Ctor = object.constructor;
  23422. switch (tag) {
  23423. case arrayBufferTag:
  23424. return cloneArrayBuffer(object);
  23425. case boolTag:
  23426. case dateTag:
  23427. return new Ctor(+object);
  23428. case dataViewTag:
  23429. return cloneDataView(object, isDeep);
  23430. case float32Tag: case float64Tag:
  23431. case int8Tag: case int16Tag: case int32Tag:
  23432. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  23433. return cloneTypedArray(object, isDeep);
  23434. case mapTag:
  23435. return new Ctor;
  23436. case numberTag:
  23437. case stringTag:
  23438. return new Ctor(object);
  23439. case regexpTag:
  23440. return cloneRegExp(object);
  23441. case setTag:
  23442. return new Ctor;
  23443. case symbolTag:
  23444. return cloneSymbol(object);
  23445. }
  23446. }
  23447. /**
  23448. * Inserts wrapper `details` in a comment at the top of the `source` body.
  23449. *
  23450. * @private
  23451. * @param {string} source The source to modify.
  23452. * @returns {Array} details The details to insert.
  23453. * @returns {string} Returns the modified source.
  23454. */
  23455. function insertWrapDetails(source, details) {
  23456. var length = details.length;
  23457. if (!length) {
  23458. return source;
  23459. }
  23460. var lastIndex = length - 1;
  23461. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  23462. details = details.join(length > 2 ? ', ' : ' ');
  23463. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  23464. }
  23465. /**
  23466. * Checks if `value` is a flattenable `arguments` object or array.
  23467. *
  23468. * @private
  23469. * @param {*} value The value to check.
  23470. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  23471. */
  23472. function isFlattenable(value) {
  23473. return isArray(value) || isArguments(value) ||
  23474. !!(spreadableSymbol && value && value[spreadableSymbol]);
  23475. }
  23476. /**
  23477. * Checks if `value` is a valid array-like index.
  23478. *
  23479. * @private
  23480. * @param {*} value The value to check.
  23481. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  23482. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  23483. */
  23484. function isIndex(value, length) {
  23485. var type = typeof value;
  23486. length = length == null ? MAX_SAFE_INTEGER : length;
  23487. return !!length &&
  23488. (type == 'number' ||
  23489. (type != 'symbol' && reIsUint.test(value))) &&
  23490. (value > -1 && value % 1 == 0 && value < length);
  23491. }
  23492. /**
  23493. * Checks if the given arguments are from an iteratee call.
  23494. *
  23495. * @private
  23496. * @param {*} value The potential iteratee value argument.
  23497. * @param {*} index The potential iteratee index or key argument.
  23498. * @param {*} object The potential iteratee object argument.
  23499. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  23500. * else `false`.
  23501. */
  23502. function isIterateeCall(value, index, object) {
  23503. if (!isObject(object)) {
  23504. return false;
  23505. }
  23506. var type = typeof index;
  23507. if (type == 'number'
  23508. ? (isArrayLike(object) && isIndex(index, object.length))
  23509. : (type == 'string' && index in object)
  23510. ) {
  23511. return eq(object[index], value);
  23512. }
  23513. return false;
  23514. }
  23515. /**
  23516. * Checks if `value` is a property name and not a property path.
  23517. *
  23518. * @private
  23519. * @param {*} value The value to check.
  23520. * @param {Object} [object] The object to query keys on.
  23521. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  23522. */
  23523. function isKey(value, object) {
  23524. if (isArray(value)) {
  23525. return false;
  23526. }
  23527. var type = typeof value;
  23528. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  23529. value == null || isSymbol(value)) {
  23530. return true;
  23531. }
  23532. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  23533. (object != null && value in Object(object));
  23534. }
  23535. /**
  23536. * Checks if `value` is suitable for use as unique object key.
  23537. *
  23538. * @private
  23539. * @param {*} value The value to check.
  23540. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  23541. */
  23542. function isKeyable(value) {
  23543. var type = typeof value;
  23544. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  23545. ? (value !== '__proto__')
  23546. : (value === null);
  23547. }
  23548. /**
  23549. * Checks if `func` has a lazy counterpart.
  23550. *
  23551. * @private
  23552. * @param {Function} func The function to check.
  23553. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  23554. * else `false`.
  23555. */
  23556. function isLaziable(func) {
  23557. var funcName = getFuncName(func),
  23558. other = lodash[funcName];
  23559. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  23560. return false;
  23561. }
  23562. if (func === other) {
  23563. return true;
  23564. }
  23565. var data = getData(other);
  23566. return !!data && func === data[0];
  23567. }
  23568. /**
  23569. * Checks if `func` has its source masked.
  23570. *
  23571. * @private
  23572. * @param {Function} func The function to check.
  23573. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  23574. */
  23575. function isMasked(func) {
  23576. return !!maskSrcKey && (maskSrcKey in func);
  23577. }
  23578. /**
  23579. * Checks if `func` is capable of being masked.
  23580. *
  23581. * @private
  23582. * @param {*} value The value to check.
  23583. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  23584. */
  23585. var isMaskable = coreJsData ? isFunction : stubFalse;
  23586. /**
  23587. * Checks if `value` is likely a prototype object.
  23588. *
  23589. * @private
  23590. * @param {*} value The value to check.
  23591. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  23592. */
  23593. function isPrototype(value) {
  23594. var Ctor = value && value.constructor,
  23595. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  23596. return value === proto;
  23597. }
  23598. /**
  23599. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  23600. *
  23601. * @private
  23602. * @param {*} value The value to check.
  23603. * @returns {boolean} Returns `true` if `value` if suitable for strict
  23604. * equality comparisons, else `false`.
  23605. */
  23606. function isStrictComparable(value) {
  23607. return value === value && !isObject(value);
  23608. }
  23609. /**
  23610. * A specialized version of `matchesProperty` for source values suitable
  23611. * for strict equality comparisons, i.e. `===`.
  23612. *
  23613. * @private
  23614. * @param {string} key The key of the property to get.
  23615. * @param {*} srcValue The value to match.
  23616. * @returns {Function} Returns the new spec function.
  23617. */
  23618. function matchesStrictComparable(key, srcValue) {
  23619. return function(object) {
  23620. if (object == null) {
  23621. return false;
  23622. }
  23623. return object[key] === srcValue &&
  23624. (srcValue !== undefined || (key in Object(object)));
  23625. };
  23626. }
  23627. /**
  23628. * A specialized version of `_.memoize` which clears the memoized function's
  23629. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  23630. *
  23631. * @private
  23632. * @param {Function} func The function to have its output memoized.
  23633. * @returns {Function} Returns the new memoized function.
  23634. */
  23635. function memoizeCapped(func) {
  23636. var result = memoize(func, function(key) {
  23637. if (cache.size === MAX_MEMOIZE_SIZE) {
  23638. cache.clear();
  23639. }
  23640. return key;
  23641. });
  23642. var cache = result.cache;
  23643. return result;
  23644. }
  23645. /**
  23646. * Merges the function metadata of `source` into `data`.
  23647. *
  23648. * Merging metadata reduces the number of wrappers used to invoke a function.
  23649. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  23650. * may be applied regardless of execution order. Methods like `_.ary` and
  23651. * `_.rearg` modify function arguments, making the order in which they are
  23652. * executed important, preventing the merging of metadata. However, we make
  23653. * an exception for a safe combined case where curried functions have `_.ary`
  23654. * and or `_.rearg` applied.
  23655. *
  23656. * @private
  23657. * @param {Array} data The destination metadata.
  23658. * @param {Array} source The source metadata.
  23659. * @returns {Array} Returns `data`.
  23660. */
  23661. function mergeData(data, source) {
  23662. var bitmask = data[1],
  23663. srcBitmask = source[1],
  23664. newBitmask = bitmask | srcBitmask,
  23665. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  23666. var isCombo =
  23667. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  23668. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  23669. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  23670. // Exit early if metadata can't be merged.
  23671. if (!(isCommon || isCombo)) {
  23672. return data;
  23673. }
  23674. // Use source `thisArg` if available.
  23675. if (srcBitmask & WRAP_BIND_FLAG) {
  23676. data[2] = source[2];
  23677. // Set when currying a bound function.
  23678. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  23679. }
  23680. // Compose partial arguments.
  23681. var value = source[3];
  23682. if (value) {
  23683. var partials = data[3];
  23684. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  23685. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  23686. }
  23687. // Compose partial right arguments.
  23688. value = source[5];
  23689. if (value) {
  23690. partials = data[5];
  23691. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  23692. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  23693. }
  23694. // Use source `argPos` if available.
  23695. value = source[7];
  23696. if (value) {
  23697. data[7] = value;
  23698. }
  23699. // Use source `ary` if it's smaller.
  23700. if (srcBitmask & WRAP_ARY_FLAG) {
  23701. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  23702. }
  23703. // Use source `arity` if one is not provided.
  23704. if (data[9] == null) {
  23705. data[9] = source[9];
  23706. }
  23707. // Use source `func` and merge bitmasks.
  23708. data[0] = source[0];
  23709. data[1] = newBitmask;
  23710. return data;
  23711. }
  23712. /**
  23713. * This function is like
  23714. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  23715. * except that it includes inherited enumerable properties.
  23716. *
  23717. * @private
  23718. * @param {Object} object The object to query.
  23719. * @returns {Array} Returns the array of property names.
  23720. */
  23721. function nativeKeysIn(object) {
  23722. var result = [];
  23723. if (object != null) {
  23724. for (var key in Object(object)) {
  23725. result.push(key);
  23726. }
  23727. }
  23728. return result;
  23729. }
  23730. /**
  23731. * Converts `value` to a string using `Object.prototype.toString`.
  23732. *
  23733. * @private
  23734. * @param {*} value The value to convert.
  23735. * @returns {string} Returns the converted string.
  23736. */
  23737. function objectToString(value) {
  23738. return nativeObjectToString.call(value);
  23739. }
  23740. /**
  23741. * A specialized version of `baseRest` which transforms the rest array.
  23742. *
  23743. * @private
  23744. * @param {Function} func The function to apply a rest parameter to.
  23745. * @param {number} [start=func.length-1] The start position of the rest parameter.
  23746. * @param {Function} transform The rest array transform.
  23747. * @returns {Function} Returns the new function.
  23748. */
  23749. function overRest(func, start, transform) {
  23750. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  23751. return function() {
  23752. var args = arguments,
  23753. index = -1,
  23754. length = nativeMax(args.length - start, 0),
  23755. array = Array(length);
  23756. while (++index < length) {
  23757. array[index] = args[start + index];
  23758. }
  23759. index = -1;
  23760. var otherArgs = Array(start + 1);
  23761. while (++index < start) {
  23762. otherArgs[index] = args[index];
  23763. }
  23764. otherArgs[start] = transform(array);
  23765. return apply(func, this, otherArgs);
  23766. };
  23767. }
  23768. /**
  23769. * Gets the parent value at `path` of `object`.
  23770. *
  23771. * @private
  23772. * @param {Object} object The object to query.
  23773. * @param {Array} path The path to get the parent value of.
  23774. * @returns {*} Returns the parent value.
  23775. */
  23776. function parent(object, path) {
  23777. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  23778. }
  23779. /**
  23780. * Reorder `array` according to the specified indexes where the element at
  23781. * the first index is assigned as the first element, the element at
  23782. * the second index is assigned as the second element, and so on.
  23783. *
  23784. * @private
  23785. * @param {Array} array The array to reorder.
  23786. * @param {Array} indexes The arranged array indexes.
  23787. * @returns {Array} Returns `array`.
  23788. */
  23789. function reorder(array, indexes) {
  23790. var arrLength = array.length,
  23791. length = nativeMin(indexes.length, arrLength),
  23792. oldArray = copyArray(array);
  23793. while (length--) {
  23794. var index = indexes[length];
  23795. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  23796. }
  23797. return array;
  23798. }
  23799. /**
  23800. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  23801. *
  23802. * @private
  23803. * @param {Object} object The object to query.
  23804. * @param {string} key The key of the property to get.
  23805. * @returns {*} Returns the property value.
  23806. */
  23807. function safeGet(object, key) {
  23808. if (key === 'constructor' && typeof object[key] === 'function') {
  23809. return;
  23810. }
  23811. if (key == '__proto__') {
  23812. return;
  23813. }
  23814. return object[key];
  23815. }
  23816. /**
  23817. * Sets metadata for `func`.
  23818. *
  23819. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  23820. * period of time, it will trip its breaker and transition to an identity
  23821. * function to avoid garbage collection pauses in V8. See
  23822. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  23823. * for more details.
  23824. *
  23825. * @private
  23826. * @param {Function} func The function to associate metadata with.
  23827. * @param {*} data The metadata.
  23828. * @returns {Function} Returns `func`.
  23829. */
  23830. var setData = shortOut(baseSetData);
  23831. /**
  23832. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  23833. *
  23834. * @private
  23835. * @param {Function} func The function to delay.
  23836. * @param {number} wait The number of milliseconds to delay invocation.
  23837. * @returns {number|Object} Returns the timer id or timeout object.
  23838. */
  23839. var setTimeout = ctxSetTimeout || function(func, wait) {
  23840. return root.setTimeout(func, wait);
  23841. };
  23842. /**
  23843. * Sets the `toString` method of `func` to return `string`.
  23844. *
  23845. * @private
  23846. * @param {Function} func The function to modify.
  23847. * @param {Function} string The `toString` result.
  23848. * @returns {Function} Returns `func`.
  23849. */
  23850. var setToString = shortOut(baseSetToString);
  23851. /**
  23852. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  23853. * with wrapper details in a comment at the top of the source body.
  23854. *
  23855. * @private
  23856. * @param {Function} wrapper The function to modify.
  23857. * @param {Function} reference The reference function.
  23858. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23859. * @returns {Function} Returns `wrapper`.
  23860. */
  23861. function setWrapToString(wrapper, reference, bitmask) {
  23862. var source = (reference + '');
  23863. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  23864. }
  23865. /**
  23866. * Creates a function that'll short out and invoke `identity` instead
  23867. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  23868. * milliseconds.
  23869. *
  23870. * @private
  23871. * @param {Function} func The function to restrict.
  23872. * @returns {Function} Returns the new shortable function.
  23873. */
  23874. function shortOut(func) {
  23875. var count = 0,
  23876. lastCalled = 0;
  23877. return function() {
  23878. var stamp = nativeNow(),
  23879. remaining = HOT_SPAN - (stamp - lastCalled);
  23880. lastCalled = stamp;
  23881. if (remaining > 0) {
  23882. if (++count >= HOT_COUNT) {
  23883. return arguments[0];
  23884. }
  23885. } else {
  23886. count = 0;
  23887. }
  23888. return func.apply(undefined, arguments);
  23889. };
  23890. }
  23891. /**
  23892. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  23893. *
  23894. * @private
  23895. * @param {Array} array The array to shuffle.
  23896. * @param {number} [size=array.length] The size of `array`.
  23897. * @returns {Array} Returns `array`.
  23898. */
  23899. function shuffleSelf(array, size) {
  23900. var index = -1,
  23901. length = array.length,
  23902. lastIndex = length - 1;
  23903. size = size === undefined ? length : size;
  23904. while (++index < size) {
  23905. var rand = baseRandom(index, lastIndex),
  23906. value = array[rand];
  23907. array[rand] = array[index];
  23908. array[index] = value;
  23909. }
  23910. array.length = size;
  23911. return array;
  23912. }
  23913. /**
  23914. * Converts `string` to a property path array.
  23915. *
  23916. * @private
  23917. * @param {string} string The string to convert.
  23918. * @returns {Array} Returns the property path array.
  23919. */
  23920. var stringToPath = memoizeCapped(function(string) {
  23921. var result = [];
  23922. if (string.charCodeAt(0) === 46 /* . */) {
  23923. result.push('');
  23924. }
  23925. string.replace(rePropName, function(match, number, quote, subString) {
  23926. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  23927. });
  23928. return result;
  23929. });
  23930. /**
  23931. * Converts `value` to a string key if it's not a string or symbol.
  23932. *
  23933. * @private
  23934. * @param {*} value The value to inspect.
  23935. * @returns {string|symbol} Returns the key.
  23936. */
  23937. function toKey(value) {
  23938. if (typeof value == 'string' || isSymbol(value)) {
  23939. return value;
  23940. }
  23941. var result = (value + '');
  23942. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  23943. }
  23944. /**
  23945. * Converts `func` to its source code.
  23946. *
  23947. * @private
  23948. * @param {Function} func The function to convert.
  23949. * @returns {string} Returns the source code.
  23950. */
  23951. function toSource(func) {
  23952. if (func != null) {
  23953. try {
  23954. return funcToString.call(func);
  23955. } catch (e) {}
  23956. try {
  23957. return (func + '');
  23958. } catch (e) {}
  23959. }
  23960. return '';
  23961. }
  23962. /**
  23963. * Updates wrapper `details` based on `bitmask` flags.
  23964. *
  23965. * @private
  23966. * @returns {Array} details The details to modify.
  23967. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23968. * @returns {Array} Returns `details`.
  23969. */
  23970. function updateWrapDetails(details, bitmask) {
  23971. arrayEach(wrapFlags, function(pair) {
  23972. var value = '_.' + pair[0];
  23973. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  23974. details.push(value);
  23975. }
  23976. });
  23977. return details.sort();
  23978. }
  23979. /**
  23980. * Creates a clone of `wrapper`.
  23981. *
  23982. * @private
  23983. * @param {Object} wrapper The wrapper to clone.
  23984. * @returns {Object} Returns the cloned wrapper.
  23985. */
  23986. function wrapperClone(wrapper) {
  23987. if (wrapper instanceof LazyWrapper) {
  23988. return wrapper.clone();
  23989. }
  23990. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  23991. result.__actions__ = copyArray(wrapper.__actions__);
  23992. result.__index__ = wrapper.__index__;
  23993. result.__values__ = wrapper.__values__;
  23994. return result;
  23995. }
  23996. /*------------------------------------------------------------------------*/
  23997. /**
  23998. * Creates an array of elements split into groups the length of `size`.
  23999. * If `array` can't be split evenly, the final chunk will be the remaining
  24000. * elements.
  24001. *
  24002. * @static
  24003. * @memberOf _
  24004. * @since 3.0.0
  24005. * @category Array
  24006. * @param {Array} array The array to process.
  24007. * @param {number} [size=1] The length of each chunk
  24008. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24009. * @returns {Array} Returns the new array of chunks.
  24010. * @example
  24011. *
  24012. * _.chunk(['a', 'b', 'c', 'd'], 2);
  24013. * // => [['a', 'b'], ['c', 'd']]
  24014. *
  24015. * _.chunk(['a', 'b', 'c', 'd'], 3);
  24016. * // => [['a', 'b', 'c'], ['d']]
  24017. */
  24018. function chunk(array, size, guard) {
  24019. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  24020. size = 1;
  24021. } else {
  24022. size = nativeMax(toInteger(size), 0);
  24023. }
  24024. var length = array == null ? 0 : array.length;
  24025. if (!length || size < 1) {
  24026. return [];
  24027. }
  24028. var index = 0,
  24029. resIndex = 0,
  24030. result = Array(nativeCeil(length / size));
  24031. while (index < length) {
  24032. result[resIndex++] = baseSlice(array, index, (index += size));
  24033. }
  24034. return result;
  24035. }
  24036. /**
  24037. * Creates an array with all falsey values removed. The values `false`, `null`,
  24038. * `0`, `""`, `undefined`, and `NaN` are falsey.
  24039. *
  24040. * @static
  24041. * @memberOf _
  24042. * @since 0.1.0
  24043. * @category Array
  24044. * @param {Array} array The array to compact.
  24045. * @returns {Array} Returns the new array of filtered values.
  24046. * @example
  24047. *
  24048. * _.compact([0, 1, false, 2, '', 3]);
  24049. * // => [1, 2, 3]
  24050. */
  24051. function compact(array) {
  24052. var index = -1,
  24053. length = array == null ? 0 : array.length,
  24054. resIndex = 0,
  24055. result = [];
  24056. while (++index < length) {
  24057. var value = array[index];
  24058. if (value) {
  24059. result[resIndex++] = value;
  24060. }
  24061. }
  24062. return result;
  24063. }
  24064. /**
  24065. * Creates a new array concatenating `array` with any additional arrays
  24066. * and/or values.
  24067. *
  24068. * @static
  24069. * @memberOf _
  24070. * @since 4.0.0
  24071. * @category Array
  24072. * @param {Array} array The array to concatenate.
  24073. * @param {...*} [values] The values to concatenate.
  24074. * @returns {Array} Returns the new concatenated array.
  24075. * @example
  24076. *
  24077. * var array = [1];
  24078. * var other = _.concat(array, 2, [3], [[4]]);
  24079. *
  24080. * console.log(other);
  24081. * // => [1, 2, 3, [4]]
  24082. *
  24083. * console.log(array);
  24084. * // => [1]
  24085. */
  24086. function concat() {
  24087. var length = arguments.length;
  24088. if (!length) {
  24089. return [];
  24090. }
  24091. var args = Array(length - 1),
  24092. array = arguments[0],
  24093. index = length;
  24094. while (index--) {
  24095. args[index - 1] = arguments[index];
  24096. }
  24097. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  24098. }
  24099. /**
  24100. * Creates an array of `array` values not included in the other given arrays
  24101. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24102. * for equality comparisons. The order and references of result values are
  24103. * determined by the first array.
  24104. *
  24105. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  24106. *
  24107. * @static
  24108. * @memberOf _
  24109. * @since 0.1.0
  24110. * @category Array
  24111. * @param {Array} array The array to inspect.
  24112. * @param {...Array} [values] The values to exclude.
  24113. * @returns {Array} Returns the new array of filtered values.
  24114. * @see _.without, _.xor
  24115. * @example
  24116. *
  24117. * _.difference([2, 1], [2, 3]);
  24118. * // => [1]
  24119. */
  24120. var difference = baseRest(function(array, values) {
  24121. return isArrayLikeObject(array)
  24122. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  24123. : [];
  24124. });
  24125. /**
  24126. * This method is like `_.difference` except that it accepts `iteratee` which
  24127. * is invoked for each element of `array` and `values` to generate the criterion
  24128. * by which they're compared. The order and references of result values are
  24129. * determined by the first array. The iteratee is invoked with one argument:
  24130. * (value).
  24131. *
  24132. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  24133. *
  24134. * @static
  24135. * @memberOf _
  24136. * @since 4.0.0
  24137. * @category Array
  24138. * @param {Array} array The array to inspect.
  24139. * @param {...Array} [values] The values to exclude.
  24140. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24141. * @returns {Array} Returns the new array of filtered values.
  24142. * @example
  24143. *
  24144. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24145. * // => [1.2]
  24146. *
  24147. * // The `_.property` iteratee shorthand.
  24148. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  24149. * // => [{ 'x': 2 }]
  24150. */
  24151. var differenceBy = baseRest(function(array, values) {
  24152. var iteratee = last(values);
  24153. if (isArrayLikeObject(iteratee)) {
  24154. iteratee = undefined;
  24155. }
  24156. return isArrayLikeObject(array)
  24157. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  24158. : [];
  24159. });
  24160. /**
  24161. * This method is like `_.difference` except that it accepts `comparator`
  24162. * which is invoked to compare elements of `array` to `values`. The order and
  24163. * references of result values are determined by the first array. The comparator
  24164. * is invoked with two arguments: (arrVal, othVal).
  24165. *
  24166. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  24167. *
  24168. * @static
  24169. * @memberOf _
  24170. * @since 4.0.0
  24171. * @category Array
  24172. * @param {Array} array The array to inspect.
  24173. * @param {...Array} [values] The values to exclude.
  24174. * @param {Function} [comparator] The comparator invoked per element.
  24175. * @returns {Array} Returns the new array of filtered values.
  24176. * @example
  24177. *
  24178. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24179. *
  24180. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  24181. * // => [{ 'x': 2, 'y': 1 }]
  24182. */
  24183. var differenceWith = baseRest(function(array, values) {
  24184. var comparator = last(values);
  24185. if (isArrayLikeObject(comparator)) {
  24186. comparator = undefined;
  24187. }
  24188. return isArrayLikeObject(array)
  24189. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  24190. : [];
  24191. });
  24192. /**
  24193. * Creates a slice of `array` with `n` elements dropped from the beginning.
  24194. *
  24195. * @static
  24196. * @memberOf _
  24197. * @since 0.5.0
  24198. * @category Array
  24199. * @param {Array} array The array to query.
  24200. * @param {number} [n=1] The number of elements to drop.
  24201. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24202. * @returns {Array} Returns the slice of `array`.
  24203. * @example
  24204. *
  24205. * _.drop([1, 2, 3]);
  24206. * // => [2, 3]
  24207. *
  24208. * _.drop([1, 2, 3], 2);
  24209. * // => [3]
  24210. *
  24211. * _.drop([1, 2, 3], 5);
  24212. * // => []
  24213. *
  24214. * _.drop([1, 2, 3], 0);
  24215. * // => [1, 2, 3]
  24216. */
  24217. function drop(array, n, guard) {
  24218. var length = array == null ? 0 : array.length;
  24219. if (!length) {
  24220. return [];
  24221. }
  24222. n = (guard || n === undefined) ? 1 : toInteger(n);
  24223. return baseSlice(array, n < 0 ? 0 : n, length);
  24224. }
  24225. /**
  24226. * Creates a slice of `array` with `n` elements dropped from the end.
  24227. *
  24228. * @static
  24229. * @memberOf _
  24230. * @since 3.0.0
  24231. * @category Array
  24232. * @param {Array} array The array to query.
  24233. * @param {number} [n=1] The number of elements to drop.
  24234. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24235. * @returns {Array} Returns the slice of `array`.
  24236. * @example
  24237. *
  24238. * _.dropRight([1, 2, 3]);
  24239. * // => [1, 2]
  24240. *
  24241. * _.dropRight([1, 2, 3], 2);
  24242. * // => [1]
  24243. *
  24244. * _.dropRight([1, 2, 3], 5);
  24245. * // => []
  24246. *
  24247. * _.dropRight([1, 2, 3], 0);
  24248. * // => [1, 2, 3]
  24249. */
  24250. function dropRight(array, n, guard) {
  24251. var length = array == null ? 0 : array.length;
  24252. if (!length) {
  24253. return [];
  24254. }
  24255. n = (guard || n === undefined) ? 1 : toInteger(n);
  24256. n = length - n;
  24257. return baseSlice(array, 0, n < 0 ? 0 : n);
  24258. }
  24259. /**
  24260. * Creates a slice of `array` excluding elements dropped from the end.
  24261. * Elements are dropped until `predicate` returns falsey. The predicate is
  24262. * invoked with three arguments: (value, index, array).
  24263. *
  24264. * @static
  24265. * @memberOf _
  24266. * @since 3.0.0
  24267. * @category Array
  24268. * @param {Array} array The array to query.
  24269. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24270. * @returns {Array} Returns the slice of `array`.
  24271. * @example
  24272. *
  24273. * var users = [
  24274. * { 'user': 'barney', 'active': true },
  24275. * { 'user': 'fred', 'active': false },
  24276. * { 'user': 'pebbles', 'active': false }
  24277. * ];
  24278. *
  24279. * _.dropRightWhile(users, function(o) { return !o.active; });
  24280. * // => objects for ['barney']
  24281. *
  24282. * // The `_.matches` iteratee shorthand.
  24283. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  24284. * // => objects for ['barney', 'fred']
  24285. *
  24286. * // The `_.matchesProperty` iteratee shorthand.
  24287. * _.dropRightWhile(users, ['active', false]);
  24288. * // => objects for ['barney']
  24289. *
  24290. * // The `_.property` iteratee shorthand.
  24291. * _.dropRightWhile(users, 'active');
  24292. * // => objects for ['barney', 'fred', 'pebbles']
  24293. */
  24294. function dropRightWhile(array, predicate) {
  24295. return (array && array.length)
  24296. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  24297. : [];
  24298. }
  24299. /**
  24300. * Creates a slice of `array` excluding elements dropped from the beginning.
  24301. * Elements are dropped until `predicate` returns falsey. The predicate is
  24302. * invoked with three arguments: (value, index, array).
  24303. *
  24304. * @static
  24305. * @memberOf _
  24306. * @since 3.0.0
  24307. * @category Array
  24308. * @param {Array} array The array to query.
  24309. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24310. * @returns {Array} Returns the slice of `array`.
  24311. * @example
  24312. *
  24313. * var users = [
  24314. * { 'user': 'barney', 'active': false },
  24315. * { 'user': 'fred', 'active': false },
  24316. * { 'user': 'pebbles', 'active': true }
  24317. * ];
  24318. *
  24319. * _.dropWhile(users, function(o) { return !o.active; });
  24320. * // => objects for ['pebbles']
  24321. *
  24322. * // The `_.matches` iteratee shorthand.
  24323. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  24324. * // => objects for ['fred', 'pebbles']
  24325. *
  24326. * // The `_.matchesProperty` iteratee shorthand.
  24327. * _.dropWhile(users, ['active', false]);
  24328. * // => objects for ['pebbles']
  24329. *
  24330. * // The `_.property` iteratee shorthand.
  24331. * _.dropWhile(users, 'active');
  24332. * // => objects for ['barney', 'fred', 'pebbles']
  24333. */
  24334. function dropWhile(array, predicate) {
  24335. return (array && array.length)
  24336. ? baseWhile(array, getIteratee(predicate, 3), true)
  24337. : [];
  24338. }
  24339. /**
  24340. * Fills elements of `array` with `value` from `start` up to, but not
  24341. * including, `end`.
  24342. *
  24343. * **Note:** This method mutates `array`.
  24344. *
  24345. * @static
  24346. * @memberOf _
  24347. * @since 3.2.0
  24348. * @category Array
  24349. * @param {Array} array The array to fill.
  24350. * @param {*} value The value to fill `array` with.
  24351. * @param {number} [start=0] The start position.
  24352. * @param {number} [end=array.length] The end position.
  24353. * @returns {Array} Returns `array`.
  24354. * @example
  24355. *
  24356. * var array = [1, 2, 3];
  24357. *
  24358. * _.fill(array, 'a');
  24359. * console.log(array);
  24360. * // => ['a', 'a', 'a']
  24361. *
  24362. * _.fill(Array(3), 2);
  24363. * // => [2, 2, 2]
  24364. *
  24365. * _.fill([4, 6, 8, 10], '*', 1, 3);
  24366. * // => [4, '*', '*', 10]
  24367. */
  24368. function fill(array, value, start, end) {
  24369. var length = array == null ? 0 : array.length;
  24370. if (!length) {
  24371. return [];
  24372. }
  24373. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  24374. start = 0;
  24375. end = length;
  24376. }
  24377. return baseFill(array, value, start, end);
  24378. }
  24379. /**
  24380. * This method is like `_.find` except that it returns the index of the first
  24381. * element `predicate` returns truthy for instead of the element itself.
  24382. *
  24383. * @static
  24384. * @memberOf _
  24385. * @since 1.1.0
  24386. * @category Array
  24387. * @param {Array} array The array to inspect.
  24388. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24389. * @param {number} [fromIndex=0] The index to search from.
  24390. * @returns {number} Returns the index of the found element, else `-1`.
  24391. * @example
  24392. *
  24393. * var users = [
  24394. * { 'user': 'barney', 'active': false },
  24395. * { 'user': 'fred', 'active': false },
  24396. * { 'user': 'pebbles', 'active': true }
  24397. * ];
  24398. *
  24399. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  24400. * // => 0
  24401. *
  24402. * // The `_.matches` iteratee shorthand.
  24403. * _.findIndex(users, { 'user': 'fred', 'active': false });
  24404. * // => 1
  24405. *
  24406. * // The `_.matchesProperty` iteratee shorthand.
  24407. * _.findIndex(users, ['active', false]);
  24408. * // => 0
  24409. *
  24410. * // The `_.property` iteratee shorthand.
  24411. * _.findIndex(users, 'active');
  24412. * // => 2
  24413. */
  24414. function findIndex(array, predicate, fromIndex) {
  24415. var length = array == null ? 0 : array.length;
  24416. if (!length) {
  24417. return -1;
  24418. }
  24419. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24420. if (index < 0) {
  24421. index = nativeMax(length + index, 0);
  24422. }
  24423. return baseFindIndex(array, getIteratee(predicate, 3), index);
  24424. }
  24425. /**
  24426. * This method is like `_.findIndex` except that it iterates over elements
  24427. * of `collection` from right to left.
  24428. *
  24429. * @static
  24430. * @memberOf _
  24431. * @since 2.0.0
  24432. * @category Array
  24433. * @param {Array} array The array to inspect.
  24434. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24435. * @param {number} [fromIndex=array.length-1] The index to search from.
  24436. * @returns {number} Returns the index of the found element, else `-1`.
  24437. * @example
  24438. *
  24439. * var users = [
  24440. * { 'user': 'barney', 'active': true },
  24441. * { 'user': 'fred', 'active': false },
  24442. * { 'user': 'pebbles', 'active': false }
  24443. * ];
  24444. *
  24445. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  24446. * // => 2
  24447. *
  24448. * // The `_.matches` iteratee shorthand.
  24449. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  24450. * // => 0
  24451. *
  24452. * // The `_.matchesProperty` iteratee shorthand.
  24453. * _.findLastIndex(users, ['active', false]);
  24454. * // => 2
  24455. *
  24456. * // The `_.property` iteratee shorthand.
  24457. * _.findLastIndex(users, 'active');
  24458. * // => 0
  24459. */
  24460. function findLastIndex(array, predicate, fromIndex) {
  24461. var length = array == null ? 0 : array.length;
  24462. if (!length) {
  24463. return -1;
  24464. }
  24465. var index = length - 1;
  24466. if (fromIndex !== undefined) {
  24467. index = toInteger(fromIndex);
  24468. index = fromIndex < 0
  24469. ? nativeMax(length + index, 0)
  24470. : nativeMin(index, length - 1);
  24471. }
  24472. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  24473. }
  24474. /**
  24475. * Flattens `array` a single level deep.
  24476. *
  24477. * @static
  24478. * @memberOf _
  24479. * @since 0.1.0
  24480. * @category Array
  24481. * @param {Array} array The array to flatten.
  24482. * @returns {Array} Returns the new flattened array.
  24483. * @example
  24484. *
  24485. * _.flatten([1, [2, [3, [4]], 5]]);
  24486. * // => [1, 2, [3, [4]], 5]
  24487. */
  24488. function flatten(array) {
  24489. var length = array == null ? 0 : array.length;
  24490. return length ? baseFlatten(array, 1) : [];
  24491. }
  24492. /**
  24493. * Recursively flattens `array`.
  24494. *
  24495. * @static
  24496. * @memberOf _
  24497. * @since 3.0.0
  24498. * @category Array
  24499. * @param {Array} array The array to flatten.
  24500. * @returns {Array} Returns the new flattened array.
  24501. * @example
  24502. *
  24503. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  24504. * // => [1, 2, 3, 4, 5]
  24505. */
  24506. function flattenDeep(array) {
  24507. var length = array == null ? 0 : array.length;
  24508. return length ? baseFlatten(array, INFINITY) : [];
  24509. }
  24510. /**
  24511. * Recursively flatten `array` up to `depth` times.
  24512. *
  24513. * @static
  24514. * @memberOf _
  24515. * @since 4.4.0
  24516. * @category Array
  24517. * @param {Array} array The array to flatten.
  24518. * @param {number} [depth=1] The maximum recursion depth.
  24519. * @returns {Array} Returns the new flattened array.
  24520. * @example
  24521. *
  24522. * var array = [1, [2, [3, [4]], 5]];
  24523. *
  24524. * _.flattenDepth(array, 1);
  24525. * // => [1, 2, [3, [4]], 5]
  24526. *
  24527. * _.flattenDepth(array, 2);
  24528. * // => [1, 2, 3, [4], 5]
  24529. */
  24530. function flattenDepth(array, depth) {
  24531. var length = array == null ? 0 : array.length;
  24532. if (!length) {
  24533. return [];
  24534. }
  24535. depth = depth === undefined ? 1 : toInteger(depth);
  24536. return baseFlatten(array, depth);
  24537. }
  24538. /**
  24539. * The inverse of `_.toPairs`; this method returns an object composed
  24540. * from key-value `pairs`.
  24541. *
  24542. * @static
  24543. * @memberOf _
  24544. * @since 4.0.0
  24545. * @category Array
  24546. * @param {Array} pairs The key-value pairs.
  24547. * @returns {Object} Returns the new object.
  24548. * @example
  24549. *
  24550. * _.fromPairs([['a', 1], ['b', 2]]);
  24551. * // => { 'a': 1, 'b': 2 }
  24552. */
  24553. function fromPairs(pairs) {
  24554. var index = -1,
  24555. length = pairs == null ? 0 : pairs.length,
  24556. result = {};
  24557. while (++index < length) {
  24558. var pair = pairs[index];
  24559. result[pair[0]] = pair[1];
  24560. }
  24561. return result;
  24562. }
  24563. /**
  24564. * Gets the first element of `array`.
  24565. *
  24566. * @static
  24567. * @memberOf _
  24568. * @since 0.1.0
  24569. * @alias first
  24570. * @category Array
  24571. * @param {Array} array The array to query.
  24572. * @returns {*} Returns the first element of `array`.
  24573. * @example
  24574. *
  24575. * _.head([1, 2, 3]);
  24576. * // => 1
  24577. *
  24578. * _.head([]);
  24579. * // => undefined
  24580. */
  24581. function head(array) {
  24582. return (array && array.length) ? array[0] : undefined;
  24583. }
  24584. /**
  24585. * Gets the index at which the first occurrence of `value` is found in `array`
  24586. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24587. * for equality comparisons. If `fromIndex` is negative, it's used as the
  24588. * offset from the end of `array`.
  24589. *
  24590. * @static
  24591. * @memberOf _
  24592. * @since 0.1.0
  24593. * @category Array
  24594. * @param {Array} array The array to inspect.
  24595. * @param {*} value The value to search for.
  24596. * @param {number} [fromIndex=0] The index to search from.
  24597. * @returns {number} Returns the index of the matched value, else `-1`.
  24598. * @example
  24599. *
  24600. * _.indexOf([1, 2, 1, 2], 2);
  24601. * // => 1
  24602. *
  24603. * // Search from the `fromIndex`.
  24604. * _.indexOf([1, 2, 1, 2], 2, 2);
  24605. * // => 3
  24606. */
  24607. function indexOf(array, value, fromIndex) {
  24608. var length = array == null ? 0 : array.length;
  24609. if (!length) {
  24610. return -1;
  24611. }
  24612. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24613. if (index < 0) {
  24614. index = nativeMax(length + index, 0);
  24615. }
  24616. return baseIndexOf(array, value, index);
  24617. }
  24618. /**
  24619. * Gets all but the last element of `array`.
  24620. *
  24621. * @static
  24622. * @memberOf _
  24623. * @since 0.1.0
  24624. * @category Array
  24625. * @param {Array} array The array to query.
  24626. * @returns {Array} Returns the slice of `array`.
  24627. * @example
  24628. *
  24629. * _.initial([1, 2, 3]);
  24630. * // => [1, 2]
  24631. */
  24632. function initial(array) {
  24633. var length = array == null ? 0 : array.length;
  24634. return length ? baseSlice(array, 0, -1) : [];
  24635. }
  24636. /**
  24637. * Creates an array of unique values that are included in all given arrays
  24638. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24639. * for equality comparisons. The order and references of result values are
  24640. * determined by the first array.
  24641. *
  24642. * @static
  24643. * @memberOf _
  24644. * @since 0.1.0
  24645. * @category Array
  24646. * @param {...Array} [arrays] The arrays to inspect.
  24647. * @returns {Array} Returns the new array of intersecting values.
  24648. * @example
  24649. *
  24650. * _.intersection([2, 1], [2, 3]);
  24651. * // => [2]
  24652. */
  24653. var intersection = baseRest(function(arrays) {
  24654. var mapped = arrayMap(arrays, castArrayLikeObject);
  24655. return (mapped.length && mapped[0] === arrays[0])
  24656. ? baseIntersection(mapped)
  24657. : [];
  24658. });
  24659. /**
  24660. * This method is like `_.intersection` except that it accepts `iteratee`
  24661. * which is invoked for each element of each `arrays` to generate the criterion
  24662. * by which they're compared. The order and references of result values are
  24663. * determined by the first array. The iteratee is invoked with one argument:
  24664. * (value).
  24665. *
  24666. * @static
  24667. * @memberOf _
  24668. * @since 4.0.0
  24669. * @category Array
  24670. * @param {...Array} [arrays] The arrays to inspect.
  24671. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24672. * @returns {Array} Returns the new array of intersecting values.
  24673. * @example
  24674. *
  24675. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24676. * // => [2.1]
  24677. *
  24678. * // The `_.property` iteratee shorthand.
  24679. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24680. * // => [{ 'x': 1 }]
  24681. */
  24682. var intersectionBy = baseRest(function(arrays) {
  24683. var iteratee = last(arrays),
  24684. mapped = arrayMap(arrays, castArrayLikeObject);
  24685. if (iteratee === last(mapped)) {
  24686. iteratee = undefined;
  24687. } else {
  24688. mapped.pop();
  24689. }
  24690. return (mapped.length && mapped[0] === arrays[0])
  24691. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  24692. : [];
  24693. });
  24694. /**
  24695. * This method is like `_.intersection` except that it accepts `comparator`
  24696. * which is invoked to compare elements of `arrays`. The order and references
  24697. * of result values are determined by the first array. The comparator is
  24698. * invoked with two arguments: (arrVal, othVal).
  24699. *
  24700. * @static
  24701. * @memberOf _
  24702. * @since 4.0.0
  24703. * @category Array
  24704. * @param {...Array} [arrays] The arrays to inspect.
  24705. * @param {Function} [comparator] The comparator invoked per element.
  24706. * @returns {Array} Returns the new array of intersecting values.
  24707. * @example
  24708. *
  24709. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24710. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24711. *
  24712. * _.intersectionWith(objects, others, _.isEqual);
  24713. * // => [{ 'x': 1, 'y': 2 }]
  24714. */
  24715. var intersectionWith = baseRest(function(arrays) {
  24716. var comparator = last(arrays),
  24717. mapped = arrayMap(arrays, castArrayLikeObject);
  24718. comparator = typeof comparator == 'function' ? comparator : undefined;
  24719. if (comparator) {
  24720. mapped.pop();
  24721. }
  24722. return (mapped.length && mapped[0] === arrays[0])
  24723. ? baseIntersection(mapped, undefined, comparator)
  24724. : [];
  24725. });
  24726. /**
  24727. * Converts all elements in `array` into a string separated by `separator`.
  24728. *
  24729. * @static
  24730. * @memberOf _
  24731. * @since 4.0.0
  24732. * @category Array
  24733. * @param {Array} array The array to convert.
  24734. * @param {string} [separator=','] The element separator.
  24735. * @returns {string} Returns the joined string.
  24736. * @example
  24737. *
  24738. * _.join(['a', 'b', 'c'], '~');
  24739. * // => 'a~b~c'
  24740. */
  24741. function join(array, separator) {
  24742. return array == null ? '' : nativeJoin.call(array, separator);
  24743. }
  24744. /**
  24745. * Gets the last element of `array`.
  24746. *
  24747. * @static
  24748. * @memberOf _
  24749. * @since 0.1.0
  24750. * @category Array
  24751. * @param {Array} array The array to query.
  24752. * @returns {*} Returns the last element of `array`.
  24753. * @example
  24754. *
  24755. * _.last([1, 2, 3]);
  24756. * // => 3
  24757. */
  24758. function last(array) {
  24759. var length = array == null ? 0 : array.length;
  24760. return length ? array[length - 1] : undefined;
  24761. }
  24762. /**
  24763. * This method is like `_.indexOf` except that it iterates over elements of
  24764. * `array` from right to left.
  24765. *
  24766. * @static
  24767. * @memberOf _
  24768. * @since 0.1.0
  24769. * @category Array
  24770. * @param {Array} array The array to inspect.
  24771. * @param {*} value The value to search for.
  24772. * @param {number} [fromIndex=array.length-1] The index to search from.
  24773. * @returns {number} Returns the index of the matched value, else `-1`.
  24774. * @example
  24775. *
  24776. * _.lastIndexOf([1, 2, 1, 2], 2);
  24777. * // => 3
  24778. *
  24779. * // Search from the `fromIndex`.
  24780. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  24781. * // => 1
  24782. */
  24783. function lastIndexOf(array, value, fromIndex) {
  24784. var length = array == null ? 0 : array.length;
  24785. if (!length) {
  24786. return -1;
  24787. }
  24788. var index = length;
  24789. if (fromIndex !== undefined) {
  24790. index = toInteger(fromIndex);
  24791. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  24792. }
  24793. return value === value
  24794. ? strictLastIndexOf(array, value, index)
  24795. : baseFindIndex(array, baseIsNaN, index, true);
  24796. }
  24797. /**
  24798. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  24799. * element from the end is returned.
  24800. *
  24801. * @static
  24802. * @memberOf _
  24803. * @since 4.11.0
  24804. * @category Array
  24805. * @param {Array} array The array to query.
  24806. * @param {number} [n=0] The index of the element to return.
  24807. * @returns {*} Returns the nth element of `array`.
  24808. * @example
  24809. *
  24810. * var array = ['a', 'b', 'c', 'd'];
  24811. *
  24812. * _.nth(array, 1);
  24813. * // => 'b'
  24814. *
  24815. * _.nth(array, -2);
  24816. * // => 'c';
  24817. */
  24818. function nth(array, n) {
  24819. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  24820. }
  24821. /**
  24822. * Removes all given values from `array` using
  24823. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24824. * for equality comparisons.
  24825. *
  24826. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  24827. * to remove elements from an array by predicate.
  24828. *
  24829. * @static
  24830. * @memberOf _
  24831. * @since 2.0.0
  24832. * @category Array
  24833. * @param {Array} array The array to modify.
  24834. * @param {...*} [values] The values to remove.
  24835. * @returns {Array} Returns `array`.
  24836. * @example
  24837. *
  24838. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24839. *
  24840. * _.pull(array, 'a', 'c');
  24841. * console.log(array);
  24842. * // => ['b', 'b']
  24843. */
  24844. var pull = baseRest(pullAll);
  24845. /**
  24846. * This method is like `_.pull` except that it accepts an array of values to remove.
  24847. *
  24848. * **Note:** Unlike `_.difference`, this method mutates `array`.
  24849. *
  24850. * @static
  24851. * @memberOf _
  24852. * @since 4.0.0
  24853. * @category Array
  24854. * @param {Array} array The array to modify.
  24855. * @param {Array} values The values to remove.
  24856. * @returns {Array} Returns `array`.
  24857. * @example
  24858. *
  24859. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24860. *
  24861. * _.pullAll(array, ['a', 'c']);
  24862. * console.log(array);
  24863. * // => ['b', 'b']
  24864. */
  24865. function pullAll(array, values) {
  24866. return (array && array.length && values && values.length)
  24867. ? basePullAll(array, values)
  24868. : array;
  24869. }
  24870. /**
  24871. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  24872. * invoked for each element of `array` and `values` to generate the criterion
  24873. * by which they're compared. The iteratee is invoked with one argument: (value).
  24874. *
  24875. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  24876. *
  24877. * @static
  24878. * @memberOf _
  24879. * @since 4.0.0
  24880. * @category Array
  24881. * @param {Array} array The array to modify.
  24882. * @param {Array} values The values to remove.
  24883. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24884. * @returns {Array} Returns `array`.
  24885. * @example
  24886. *
  24887. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  24888. *
  24889. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  24890. * console.log(array);
  24891. * // => [{ 'x': 2 }]
  24892. */
  24893. function pullAllBy(array, values, iteratee) {
  24894. return (array && array.length && values && values.length)
  24895. ? basePullAll(array, values, getIteratee(iteratee, 2))
  24896. : array;
  24897. }
  24898. /**
  24899. * This method is like `_.pullAll` except that it accepts `comparator` which
  24900. * is invoked to compare elements of `array` to `values`. The comparator is
  24901. * invoked with two arguments: (arrVal, othVal).
  24902. *
  24903. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  24904. *
  24905. * @static
  24906. * @memberOf _
  24907. * @since 4.6.0
  24908. * @category Array
  24909. * @param {Array} array The array to modify.
  24910. * @param {Array} values The values to remove.
  24911. * @param {Function} [comparator] The comparator invoked per element.
  24912. * @returns {Array} Returns `array`.
  24913. * @example
  24914. *
  24915. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  24916. *
  24917. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  24918. * console.log(array);
  24919. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  24920. */
  24921. function pullAllWith(array, values, comparator) {
  24922. return (array && array.length && values && values.length)
  24923. ? basePullAll(array, values, undefined, comparator)
  24924. : array;
  24925. }
  24926. /**
  24927. * Removes elements from `array` corresponding to `indexes` and returns an
  24928. * array of removed elements.
  24929. *
  24930. * **Note:** Unlike `_.at`, this method mutates `array`.
  24931. *
  24932. * @static
  24933. * @memberOf _
  24934. * @since 3.0.0
  24935. * @category Array
  24936. * @param {Array} array The array to modify.
  24937. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  24938. * @returns {Array} Returns the new array of removed elements.
  24939. * @example
  24940. *
  24941. * var array = ['a', 'b', 'c', 'd'];
  24942. * var pulled = _.pullAt(array, [1, 3]);
  24943. *
  24944. * console.log(array);
  24945. * // => ['a', 'c']
  24946. *
  24947. * console.log(pulled);
  24948. * // => ['b', 'd']
  24949. */
  24950. var pullAt = flatRest(function(array, indexes) {
  24951. var length = array == null ? 0 : array.length,
  24952. result = baseAt(array, indexes);
  24953. basePullAt(array, arrayMap(indexes, function(index) {
  24954. return isIndex(index, length) ? +index : index;
  24955. }).sort(compareAscending));
  24956. return result;
  24957. });
  24958. /**
  24959. * Removes all elements from `array` that `predicate` returns truthy for
  24960. * and returns an array of the removed elements. The predicate is invoked
  24961. * with three arguments: (value, index, array).
  24962. *
  24963. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  24964. * to pull elements from an array by value.
  24965. *
  24966. * @static
  24967. * @memberOf _
  24968. * @since 2.0.0
  24969. * @category Array
  24970. * @param {Array} array The array to modify.
  24971. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24972. * @returns {Array} Returns the new array of removed elements.
  24973. * @example
  24974. *
  24975. * var array = [1, 2, 3, 4];
  24976. * var evens = _.remove(array, function(n) {
  24977. * return n % 2 == 0;
  24978. * });
  24979. *
  24980. * console.log(array);
  24981. * // => [1, 3]
  24982. *
  24983. * console.log(evens);
  24984. * // => [2, 4]
  24985. */
  24986. function remove(array, predicate) {
  24987. var result = [];
  24988. if (!(array && array.length)) {
  24989. return result;
  24990. }
  24991. var index = -1,
  24992. indexes = [],
  24993. length = array.length;
  24994. predicate = getIteratee(predicate, 3);
  24995. while (++index < length) {
  24996. var value = array[index];
  24997. if (predicate(value, index, array)) {
  24998. result.push(value);
  24999. indexes.push(index);
  25000. }
  25001. }
  25002. basePullAt(array, indexes);
  25003. return result;
  25004. }
  25005. /**
  25006. * Reverses `array` so that the first element becomes the last, the second
  25007. * element becomes the second to last, and so on.
  25008. *
  25009. * **Note:** This method mutates `array` and is based on
  25010. * [`Array#reverse`](https://mdn.io/Array/reverse).
  25011. *
  25012. * @static
  25013. * @memberOf _
  25014. * @since 4.0.0
  25015. * @category Array
  25016. * @param {Array} array The array to modify.
  25017. * @returns {Array} Returns `array`.
  25018. * @example
  25019. *
  25020. * var array = [1, 2, 3];
  25021. *
  25022. * _.reverse(array);
  25023. * // => [3, 2, 1]
  25024. *
  25025. * console.log(array);
  25026. * // => [3, 2, 1]
  25027. */
  25028. function reverse(array) {
  25029. return array == null ? array : nativeReverse.call(array);
  25030. }
  25031. /**
  25032. * Creates a slice of `array` from `start` up to, but not including, `end`.
  25033. *
  25034. * **Note:** This method is used instead of
  25035. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  25036. * returned.
  25037. *
  25038. * @static
  25039. * @memberOf _
  25040. * @since 3.0.0
  25041. * @category Array
  25042. * @param {Array} array The array to slice.
  25043. * @param {number} [start=0] The start position.
  25044. * @param {number} [end=array.length] The end position.
  25045. * @returns {Array} Returns the slice of `array`.
  25046. */
  25047. function slice(array, start, end) {
  25048. var length = array == null ? 0 : array.length;
  25049. if (!length) {
  25050. return [];
  25051. }
  25052. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  25053. start = 0;
  25054. end = length;
  25055. }
  25056. else {
  25057. start = start == null ? 0 : toInteger(start);
  25058. end = end === undefined ? length : toInteger(end);
  25059. }
  25060. return baseSlice(array, start, end);
  25061. }
  25062. /**
  25063. * Uses a binary search to determine the lowest index at which `value`
  25064. * should be inserted into `array` in order to maintain its sort order.
  25065. *
  25066. * @static
  25067. * @memberOf _
  25068. * @since 0.1.0
  25069. * @category Array
  25070. * @param {Array} array The sorted array to inspect.
  25071. * @param {*} value The value to evaluate.
  25072. * @returns {number} Returns the index at which `value` should be inserted
  25073. * into `array`.
  25074. * @example
  25075. *
  25076. * _.sortedIndex([30, 50], 40);
  25077. * // => 1
  25078. */
  25079. function sortedIndex(array, value) {
  25080. return baseSortedIndex(array, value);
  25081. }
  25082. /**
  25083. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  25084. * which is invoked for `value` and each element of `array` to compute their
  25085. * sort ranking. The iteratee is invoked with one argument: (value).
  25086. *
  25087. * @static
  25088. * @memberOf _
  25089. * @since 4.0.0
  25090. * @category Array
  25091. * @param {Array} array The sorted array to inspect.
  25092. * @param {*} value The value to evaluate.
  25093. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25094. * @returns {number} Returns the index at which `value` should be inserted
  25095. * into `array`.
  25096. * @example
  25097. *
  25098. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25099. *
  25100. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25101. * // => 0
  25102. *
  25103. * // The `_.property` iteratee shorthand.
  25104. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  25105. * // => 0
  25106. */
  25107. function sortedIndexBy(array, value, iteratee) {
  25108. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  25109. }
  25110. /**
  25111. * This method is like `_.indexOf` except that it performs a binary
  25112. * search on a sorted `array`.
  25113. *
  25114. * @static
  25115. * @memberOf _
  25116. * @since 4.0.0
  25117. * @category Array
  25118. * @param {Array} array The array to inspect.
  25119. * @param {*} value The value to search for.
  25120. * @returns {number} Returns the index of the matched value, else `-1`.
  25121. * @example
  25122. *
  25123. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  25124. * // => 1
  25125. */
  25126. function sortedIndexOf(array, value) {
  25127. var length = array == null ? 0 : array.length;
  25128. if (length) {
  25129. var index = baseSortedIndex(array, value);
  25130. if (index < length && eq(array[index], value)) {
  25131. return index;
  25132. }
  25133. }
  25134. return -1;
  25135. }
  25136. /**
  25137. * This method is like `_.sortedIndex` except that it returns the highest
  25138. * index at which `value` should be inserted into `array` in order to
  25139. * maintain its sort order.
  25140. *
  25141. * @static
  25142. * @memberOf _
  25143. * @since 3.0.0
  25144. * @category Array
  25145. * @param {Array} array The sorted array to inspect.
  25146. * @param {*} value The value to evaluate.
  25147. * @returns {number} Returns the index at which `value` should be inserted
  25148. * into `array`.
  25149. * @example
  25150. *
  25151. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  25152. * // => 4
  25153. */
  25154. function sortedLastIndex(array, value) {
  25155. return baseSortedIndex(array, value, true);
  25156. }
  25157. /**
  25158. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  25159. * which is invoked for `value` and each element of `array` to compute their
  25160. * sort ranking. The iteratee is invoked with one argument: (value).
  25161. *
  25162. * @static
  25163. * @memberOf _
  25164. * @since 4.0.0
  25165. * @category Array
  25166. * @param {Array} array The sorted array to inspect.
  25167. * @param {*} value The value to evaluate.
  25168. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25169. * @returns {number} Returns the index at which `value` should be inserted
  25170. * into `array`.
  25171. * @example
  25172. *
  25173. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25174. *
  25175. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25176. * // => 1
  25177. *
  25178. * // The `_.property` iteratee shorthand.
  25179. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  25180. * // => 1
  25181. */
  25182. function sortedLastIndexBy(array, value, iteratee) {
  25183. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  25184. }
  25185. /**
  25186. * This method is like `_.lastIndexOf` except that it performs a binary
  25187. * search on a sorted `array`.
  25188. *
  25189. * @static
  25190. * @memberOf _
  25191. * @since 4.0.0
  25192. * @category Array
  25193. * @param {Array} array The array to inspect.
  25194. * @param {*} value The value to search for.
  25195. * @returns {number} Returns the index of the matched value, else `-1`.
  25196. * @example
  25197. *
  25198. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  25199. * // => 3
  25200. */
  25201. function sortedLastIndexOf(array, value) {
  25202. var length = array == null ? 0 : array.length;
  25203. if (length) {
  25204. var index = baseSortedIndex(array, value, true) - 1;
  25205. if (eq(array[index], value)) {
  25206. return index;
  25207. }
  25208. }
  25209. return -1;
  25210. }
  25211. /**
  25212. * This method is like `_.uniq` except that it's designed and optimized
  25213. * for sorted arrays.
  25214. *
  25215. * @static
  25216. * @memberOf _
  25217. * @since 4.0.0
  25218. * @category Array
  25219. * @param {Array} array The array to inspect.
  25220. * @returns {Array} Returns the new duplicate free array.
  25221. * @example
  25222. *
  25223. * _.sortedUniq([1, 1, 2]);
  25224. * // => [1, 2]
  25225. */
  25226. function sortedUniq(array) {
  25227. return (array && array.length)
  25228. ? baseSortedUniq(array)
  25229. : [];
  25230. }
  25231. /**
  25232. * This method is like `_.uniqBy` except that it's designed and optimized
  25233. * for sorted arrays.
  25234. *
  25235. * @static
  25236. * @memberOf _
  25237. * @since 4.0.0
  25238. * @category Array
  25239. * @param {Array} array The array to inspect.
  25240. * @param {Function} [iteratee] The iteratee invoked per element.
  25241. * @returns {Array} Returns the new duplicate free array.
  25242. * @example
  25243. *
  25244. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  25245. * // => [1.1, 2.3]
  25246. */
  25247. function sortedUniqBy(array, iteratee) {
  25248. return (array && array.length)
  25249. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  25250. : [];
  25251. }
  25252. /**
  25253. * Gets all but the first element of `array`.
  25254. *
  25255. * @static
  25256. * @memberOf _
  25257. * @since 4.0.0
  25258. * @category Array
  25259. * @param {Array} array The array to query.
  25260. * @returns {Array} Returns the slice of `array`.
  25261. * @example
  25262. *
  25263. * _.tail([1, 2, 3]);
  25264. * // => [2, 3]
  25265. */
  25266. function tail(array) {
  25267. var length = array == null ? 0 : array.length;
  25268. return length ? baseSlice(array, 1, length) : [];
  25269. }
  25270. /**
  25271. * Creates a slice of `array` with `n` elements taken from the beginning.
  25272. *
  25273. * @static
  25274. * @memberOf _
  25275. * @since 0.1.0
  25276. * @category Array
  25277. * @param {Array} array The array to query.
  25278. * @param {number} [n=1] The number of elements to take.
  25279. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25280. * @returns {Array} Returns the slice of `array`.
  25281. * @example
  25282. *
  25283. * _.take([1, 2, 3]);
  25284. * // => [1]
  25285. *
  25286. * _.take([1, 2, 3], 2);
  25287. * // => [1, 2]
  25288. *
  25289. * _.take([1, 2, 3], 5);
  25290. * // => [1, 2, 3]
  25291. *
  25292. * _.take([1, 2, 3], 0);
  25293. * // => []
  25294. */
  25295. function take(array, n, guard) {
  25296. if (!(array && array.length)) {
  25297. return [];
  25298. }
  25299. n = (guard || n === undefined) ? 1 : toInteger(n);
  25300. return baseSlice(array, 0, n < 0 ? 0 : n);
  25301. }
  25302. /**
  25303. * Creates a slice of `array` with `n` elements taken from the end.
  25304. *
  25305. * @static
  25306. * @memberOf _
  25307. * @since 3.0.0
  25308. * @category Array
  25309. * @param {Array} array The array to query.
  25310. * @param {number} [n=1] The number of elements to take.
  25311. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25312. * @returns {Array} Returns the slice of `array`.
  25313. * @example
  25314. *
  25315. * _.takeRight([1, 2, 3]);
  25316. * // => [3]
  25317. *
  25318. * _.takeRight([1, 2, 3], 2);
  25319. * // => [2, 3]
  25320. *
  25321. * _.takeRight([1, 2, 3], 5);
  25322. * // => [1, 2, 3]
  25323. *
  25324. * _.takeRight([1, 2, 3], 0);
  25325. * // => []
  25326. */
  25327. function takeRight(array, n, guard) {
  25328. var length = array == null ? 0 : array.length;
  25329. if (!length) {
  25330. return [];
  25331. }
  25332. n = (guard || n === undefined) ? 1 : toInteger(n);
  25333. n = length - n;
  25334. return baseSlice(array, n < 0 ? 0 : n, length);
  25335. }
  25336. /**
  25337. * Creates a slice of `array` with elements taken from the end. Elements are
  25338. * taken until `predicate` returns falsey. The predicate is invoked with
  25339. * three arguments: (value, index, array).
  25340. *
  25341. * @static
  25342. * @memberOf _
  25343. * @since 3.0.0
  25344. * @category Array
  25345. * @param {Array} array The array to query.
  25346. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25347. * @returns {Array} Returns the slice of `array`.
  25348. * @example
  25349. *
  25350. * var users = [
  25351. * { 'user': 'barney', 'active': true },
  25352. * { 'user': 'fred', 'active': false },
  25353. * { 'user': 'pebbles', 'active': false }
  25354. * ];
  25355. *
  25356. * _.takeRightWhile(users, function(o) { return !o.active; });
  25357. * // => objects for ['fred', 'pebbles']
  25358. *
  25359. * // The `_.matches` iteratee shorthand.
  25360. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  25361. * // => objects for ['pebbles']
  25362. *
  25363. * // The `_.matchesProperty` iteratee shorthand.
  25364. * _.takeRightWhile(users, ['active', false]);
  25365. * // => objects for ['fred', 'pebbles']
  25366. *
  25367. * // The `_.property` iteratee shorthand.
  25368. * _.takeRightWhile(users, 'active');
  25369. * // => []
  25370. */
  25371. function takeRightWhile(array, predicate) {
  25372. return (array && array.length)
  25373. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  25374. : [];
  25375. }
  25376. /**
  25377. * Creates a slice of `array` with elements taken from the beginning. Elements
  25378. * are taken until `predicate` returns falsey. The predicate is invoked with
  25379. * three arguments: (value, index, array).
  25380. *
  25381. * @static
  25382. * @memberOf _
  25383. * @since 3.0.0
  25384. * @category Array
  25385. * @param {Array} array The array to query.
  25386. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25387. * @returns {Array} Returns the slice of `array`.
  25388. * @example
  25389. *
  25390. * var users = [
  25391. * { 'user': 'barney', 'active': false },
  25392. * { 'user': 'fred', 'active': false },
  25393. * { 'user': 'pebbles', 'active': true }
  25394. * ];
  25395. *
  25396. * _.takeWhile(users, function(o) { return !o.active; });
  25397. * // => objects for ['barney', 'fred']
  25398. *
  25399. * // The `_.matches` iteratee shorthand.
  25400. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  25401. * // => objects for ['barney']
  25402. *
  25403. * // The `_.matchesProperty` iteratee shorthand.
  25404. * _.takeWhile(users, ['active', false]);
  25405. * // => objects for ['barney', 'fred']
  25406. *
  25407. * // The `_.property` iteratee shorthand.
  25408. * _.takeWhile(users, 'active');
  25409. * // => []
  25410. */
  25411. function takeWhile(array, predicate) {
  25412. return (array && array.length)
  25413. ? baseWhile(array, getIteratee(predicate, 3))
  25414. : [];
  25415. }
  25416. /**
  25417. * Creates an array of unique values, in order, from all given arrays using
  25418. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25419. * for equality comparisons.
  25420. *
  25421. * @static
  25422. * @memberOf _
  25423. * @since 0.1.0
  25424. * @category Array
  25425. * @param {...Array} [arrays] The arrays to inspect.
  25426. * @returns {Array} Returns the new array of combined values.
  25427. * @example
  25428. *
  25429. * _.union([2], [1, 2]);
  25430. * // => [2, 1]
  25431. */
  25432. var union = baseRest(function(arrays) {
  25433. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  25434. });
  25435. /**
  25436. * This method is like `_.union` except that it accepts `iteratee` which is
  25437. * invoked for each element of each `arrays` to generate the criterion by
  25438. * which uniqueness is computed. Result values are chosen from the first
  25439. * array in which the value occurs. The iteratee is invoked with one argument:
  25440. * (value).
  25441. *
  25442. * @static
  25443. * @memberOf _
  25444. * @since 4.0.0
  25445. * @category Array
  25446. * @param {...Array} [arrays] The arrays to inspect.
  25447. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25448. * @returns {Array} Returns the new array of combined values.
  25449. * @example
  25450. *
  25451. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  25452. * // => [2.1, 1.2]
  25453. *
  25454. * // The `_.property` iteratee shorthand.
  25455. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25456. * // => [{ 'x': 1 }, { 'x': 2 }]
  25457. */
  25458. var unionBy = baseRest(function(arrays) {
  25459. var iteratee = last(arrays);
  25460. if (isArrayLikeObject(iteratee)) {
  25461. iteratee = undefined;
  25462. }
  25463. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  25464. });
  25465. /**
  25466. * This method is like `_.union` except that it accepts `comparator` which
  25467. * is invoked to compare elements of `arrays`. Result values are chosen from
  25468. * the first array in which the value occurs. The comparator is invoked
  25469. * with two arguments: (arrVal, othVal).
  25470. *
  25471. * @static
  25472. * @memberOf _
  25473. * @since 4.0.0
  25474. * @category Array
  25475. * @param {...Array} [arrays] The arrays to inspect.
  25476. * @param {Function} [comparator] The comparator invoked per element.
  25477. * @returns {Array} Returns the new array of combined values.
  25478. * @example
  25479. *
  25480. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25481. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25482. *
  25483. * _.unionWith(objects, others, _.isEqual);
  25484. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25485. */
  25486. var unionWith = baseRest(function(arrays) {
  25487. var comparator = last(arrays);
  25488. comparator = typeof comparator == 'function' ? comparator : undefined;
  25489. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  25490. });
  25491. /**
  25492. * Creates a duplicate-free version of an array, using
  25493. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25494. * for equality comparisons, in which only the first occurrence of each element
  25495. * is kept. The order of result values is determined by the order they occur
  25496. * in the array.
  25497. *
  25498. * @static
  25499. * @memberOf _
  25500. * @since 0.1.0
  25501. * @category Array
  25502. * @param {Array} array The array to inspect.
  25503. * @returns {Array} Returns the new duplicate free array.
  25504. * @example
  25505. *
  25506. * _.uniq([2, 1, 2]);
  25507. * // => [2, 1]
  25508. */
  25509. function uniq(array) {
  25510. return (array && array.length) ? baseUniq(array) : [];
  25511. }
  25512. /**
  25513. * This method is like `_.uniq` except that it accepts `iteratee` which is
  25514. * invoked for each element in `array` to generate the criterion by which
  25515. * uniqueness is computed. The order of result values is determined by the
  25516. * order they occur in the array. The iteratee is invoked with one argument:
  25517. * (value).
  25518. *
  25519. * @static
  25520. * @memberOf _
  25521. * @since 4.0.0
  25522. * @category Array
  25523. * @param {Array} array The array to inspect.
  25524. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25525. * @returns {Array} Returns the new duplicate free array.
  25526. * @example
  25527. *
  25528. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  25529. * // => [2.1, 1.2]
  25530. *
  25531. * // The `_.property` iteratee shorthand.
  25532. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  25533. * // => [{ 'x': 1 }, { 'x': 2 }]
  25534. */
  25535. function uniqBy(array, iteratee) {
  25536. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  25537. }
  25538. /**
  25539. * This method is like `_.uniq` except that it accepts `comparator` which
  25540. * is invoked to compare elements of `array`. The order of result values is
  25541. * determined by the order they occur in the array.The comparator is invoked
  25542. * with two arguments: (arrVal, othVal).
  25543. *
  25544. * @static
  25545. * @memberOf _
  25546. * @since 4.0.0
  25547. * @category Array
  25548. * @param {Array} array The array to inspect.
  25549. * @param {Function} [comparator] The comparator invoked per element.
  25550. * @returns {Array} Returns the new duplicate free array.
  25551. * @example
  25552. *
  25553. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25554. *
  25555. * _.uniqWith(objects, _.isEqual);
  25556. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  25557. */
  25558. function uniqWith(array, comparator) {
  25559. comparator = typeof comparator == 'function' ? comparator : undefined;
  25560. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  25561. }
  25562. /**
  25563. * This method is like `_.zip` except that it accepts an array of grouped
  25564. * elements and creates an array regrouping the elements to their pre-zip
  25565. * configuration.
  25566. *
  25567. * @static
  25568. * @memberOf _
  25569. * @since 1.2.0
  25570. * @category Array
  25571. * @param {Array} array The array of grouped elements to process.
  25572. * @returns {Array} Returns the new array of regrouped elements.
  25573. * @example
  25574. *
  25575. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  25576. * // => [['a', 1, true], ['b', 2, false]]
  25577. *
  25578. * _.unzip(zipped);
  25579. * // => [['a', 'b'], [1, 2], [true, false]]
  25580. */
  25581. function unzip(array) {
  25582. if (!(array && array.length)) {
  25583. return [];
  25584. }
  25585. var length = 0;
  25586. array = arrayFilter(array, function(group) {
  25587. if (isArrayLikeObject(group)) {
  25588. length = nativeMax(group.length, length);
  25589. return true;
  25590. }
  25591. });
  25592. return baseTimes(length, function(index) {
  25593. return arrayMap(array, baseProperty(index));
  25594. });
  25595. }
  25596. /**
  25597. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  25598. * how regrouped values should be combined. The iteratee is invoked with the
  25599. * elements of each group: (...group).
  25600. *
  25601. * @static
  25602. * @memberOf _
  25603. * @since 3.8.0
  25604. * @category Array
  25605. * @param {Array} array The array of grouped elements to process.
  25606. * @param {Function} [iteratee=_.identity] The function to combine
  25607. * regrouped values.
  25608. * @returns {Array} Returns the new array of regrouped elements.
  25609. * @example
  25610. *
  25611. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  25612. * // => [[1, 10, 100], [2, 20, 200]]
  25613. *
  25614. * _.unzipWith(zipped, _.add);
  25615. * // => [3, 30, 300]
  25616. */
  25617. function unzipWith(array, iteratee) {
  25618. if (!(array && array.length)) {
  25619. return [];
  25620. }
  25621. var result = unzip(array);
  25622. if (iteratee == null) {
  25623. return result;
  25624. }
  25625. return arrayMap(result, function(group) {
  25626. return apply(iteratee, undefined, group);
  25627. });
  25628. }
  25629. /**
  25630. * Creates an array excluding all given values using
  25631. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25632. * for equality comparisons.
  25633. *
  25634. * **Note:** Unlike `_.pull`, this method returns a new array.
  25635. *
  25636. * @static
  25637. * @memberOf _
  25638. * @since 0.1.0
  25639. * @category Array
  25640. * @param {Array} array The array to inspect.
  25641. * @param {...*} [values] The values to exclude.
  25642. * @returns {Array} Returns the new array of filtered values.
  25643. * @see _.difference, _.xor
  25644. * @example
  25645. *
  25646. * _.without([2, 1, 2, 3], 1, 2);
  25647. * // => [3]
  25648. */
  25649. var without = baseRest(function(array, values) {
  25650. return isArrayLikeObject(array)
  25651. ? baseDifference(array, values)
  25652. : [];
  25653. });
  25654. /**
  25655. * Creates an array of unique values that is the
  25656. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  25657. * of the given arrays. The order of result values is determined by the order
  25658. * they occur in the arrays.
  25659. *
  25660. * @static
  25661. * @memberOf _
  25662. * @since 2.4.0
  25663. * @category Array
  25664. * @param {...Array} [arrays] The arrays to inspect.
  25665. * @returns {Array} Returns the new array of filtered values.
  25666. * @see _.difference, _.without
  25667. * @example
  25668. *
  25669. * _.xor([2, 1], [2, 3]);
  25670. * // => [1, 3]
  25671. */
  25672. var xor = baseRest(function(arrays) {
  25673. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  25674. });
  25675. /**
  25676. * This method is like `_.xor` except that it accepts `iteratee` which is
  25677. * invoked for each element of each `arrays` to generate the criterion by
  25678. * which by which they're compared. The order of result values is determined
  25679. * by the order they occur in the arrays. The iteratee is invoked with one
  25680. * argument: (value).
  25681. *
  25682. * @static
  25683. * @memberOf _
  25684. * @since 4.0.0
  25685. * @category Array
  25686. * @param {...Array} [arrays] The arrays to inspect.
  25687. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25688. * @returns {Array} Returns the new array of filtered values.
  25689. * @example
  25690. *
  25691. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  25692. * // => [1.2, 3.4]
  25693. *
  25694. * // The `_.property` iteratee shorthand.
  25695. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25696. * // => [{ 'x': 2 }]
  25697. */
  25698. var xorBy = baseRest(function(arrays) {
  25699. var iteratee = last(arrays);
  25700. if (isArrayLikeObject(iteratee)) {
  25701. iteratee = undefined;
  25702. }
  25703. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  25704. });
  25705. /**
  25706. * This method is like `_.xor` except that it accepts `comparator` which is
  25707. * invoked to compare elements of `arrays`. The order of result values is
  25708. * determined by the order they occur in the arrays. The comparator is invoked
  25709. * with two arguments: (arrVal, othVal).
  25710. *
  25711. * @static
  25712. * @memberOf _
  25713. * @since 4.0.0
  25714. * @category Array
  25715. * @param {...Array} [arrays] The arrays to inspect.
  25716. * @param {Function} [comparator] The comparator invoked per element.
  25717. * @returns {Array} Returns the new array of filtered values.
  25718. * @example
  25719. *
  25720. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25721. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25722. *
  25723. * _.xorWith(objects, others, _.isEqual);
  25724. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25725. */
  25726. var xorWith = baseRest(function(arrays) {
  25727. var comparator = last(arrays);
  25728. comparator = typeof comparator == 'function' ? comparator : undefined;
  25729. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  25730. });
  25731. /**
  25732. * Creates an array of grouped elements, the first of which contains the
  25733. * first elements of the given arrays, the second of which contains the
  25734. * second elements of the given arrays, and so on.
  25735. *
  25736. * @static
  25737. * @memberOf _
  25738. * @since 0.1.0
  25739. * @category Array
  25740. * @param {...Array} [arrays] The arrays to process.
  25741. * @returns {Array} Returns the new array of grouped elements.
  25742. * @example
  25743. *
  25744. * _.zip(['a', 'b'], [1, 2], [true, false]);
  25745. * // => [['a', 1, true], ['b', 2, false]]
  25746. */
  25747. var zip = baseRest(unzip);
  25748. /**
  25749. * This method is like `_.fromPairs` except that it accepts two arrays,
  25750. * one of property identifiers and one of corresponding values.
  25751. *
  25752. * @static
  25753. * @memberOf _
  25754. * @since 0.4.0
  25755. * @category Array
  25756. * @param {Array} [props=[]] The property identifiers.
  25757. * @param {Array} [values=[]] The property values.
  25758. * @returns {Object} Returns the new object.
  25759. * @example
  25760. *
  25761. * _.zipObject(['a', 'b'], [1, 2]);
  25762. * // => { 'a': 1, 'b': 2 }
  25763. */
  25764. function zipObject(props, values) {
  25765. return baseZipObject(props || [], values || [], assignValue);
  25766. }
  25767. /**
  25768. * This method is like `_.zipObject` except that it supports property paths.
  25769. *
  25770. * @static
  25771. * @memberOf _
  25772. * @since 4.1.0
  25773. * @category Array
  25774. * @param {Array} [props=[]] The property identifiers.
  25775. * @param {Array} [values=[]] The property values.
  25776. * @returns {Object} Returns the new object.
  25777. * @example
  25778. *
  25779. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  25780. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  25781. */
  25782. function zipObjectDeep(props, values) {
  25783. return baseZipObject(props || [], values || [], baseSet);
  25784. }
  25785. /**
  25786. * This method is like `_.zip` except that it accepts `iteratee` to specify
  25787. * how grouped values should be combined. The iteratee is invoked with the
  25788. * elements of each group: (...group).
  25789. *
  25790. * @static
  25791. * @memberOf _
  25792. * @since 3.8.0
  25793. * @category Array
  25794. * @param {...Array} [arrays] The arrays to process.
  25795. * @param {Function} [iteratee=_.identity] The function to combine
  25796. * grouped values.
  25797. * @returns {Array} Returns the new array of grouped elements.
  25798. * @example
  25799. *
  25800. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  25801. * return a + b + c;
  25802. * });
  25803. * // => [111, 222]
  25804. */
  25805. var zipWith = baseRest(function(arrays) {
  25806. var length = arrays.length,
  25807. iteratee = length > 1 ? arrays[length - 1] : undefined;
  25808. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  25809. return unzipWith(arrays, iteratee);
  25810. });
  25811. /*------------------------------------------------------------------------*/
  25812. /**
  25813. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  25814. * chain sequences enabled. The result of such sequences must be unwrapped
  25815. * with `_#value`.
  25816. *
  25817. * @static
  25818. * @memberOf _
  25819. * @since 1.3.0
  25820. * @category Seq
  25821. * @param {*} value The value to wrap.
  25822. * @returns {Object} Returns the new `lodash` wrapper instance.
  25823. * @example
  25824. *
  25825. * var users = [
  25826. * { 'user': 'barney', 'age': 36 },
  25827. * { 'user': 'fred', 'age': 40 },
  25828. * { 'user': 'pebbles', 'age': 1 }
  25829. * ];
  25830. *
  25831. * var youngest = _
  25832. * .chain(users)
  25833. * .sortBy('age')
  25834. * .map(function(o) {
  25835. * return o.user + ' is ' + o.age;
  25836. * })
  25837. * .head()
  25838. * .value();
  25839. * // => 'pebbles is 1'
  25840. */
  25841. function chain(value) {
  25842. var result = lodash(value);
  25843. result.__chain__ = true;
  25844. return result;
  25845. }
  25846. /**
  25847. * This method invokes `interceptor` and returns `value`. The interceptor
  25848. * is invoked with one argument; (value). The purpose of this method is to
  25849. * "tap into" a method chain sequence in order to modify intermediate results.
  25850. *
  25851. * @static
  25852. * @memberOf _
  25853. * @since 0.1.0
  25854. * @category Seq
  25855. * @param {*} value The value to provide to `interceptor`.
  25856. * @param {Function} interceptor The function to invoke.
  25857. * @returns {*} Returns `value`.
  25858. * @example
  25859. *
  25860. * _([1, 2, 3])
  25861. * .tap(function(array) {
  25862. * // Mutate input array.
  25863. * array.pop();
  25864. * })
  25865. * .reverse()
  25866. * .value();
  25867. * // => [2, 1]
  25868. */
  25869. function tap(value, interceptor) {
  25870. interceptor(value);
  25871. return value;
  25872. }
  25873. /**
  25874. * This method is like `_.tap` except that it returns the result of `interceptor`.
  25875. * The purpose of this method is to "pass thru" values replacing intermediate
  25876. * results in a method chain sequence.
  25877. *
  25878. * @static
  25879. * @memberOf _
  25880. * @since 3.0.0
  25881. * @category Seq
  25882. * @param {*} value The value to provide to `interceptor`.
  25883. * @param {Function} interceptor The function to invoke.
  25884. * @returns {*} Returns the result of `interceptor`.
  25885. * @example
  25886. *
  25887. * _(' abc ')
  25888. * .chain()
  25889. * .trim()
  25890. * .thru(function(value) {
  25891. * return [value];
  25892. * })
  25893. * .value();
  25894. * // => ['abc']
  25895. */
  25896. function thru(value, interceptor) {
  25897. return interceptor(value);
  25898. }
  25899. /**
  25900. * This method is the wrapper version of `_.at`.
  25901. *
  25902. * @name at
  25903. * @memberOf _
  25904. * @since 1.0.0
  25905. * @category Seq
  25906. * @param {...(string|string[])} [paths] The property paths to pick.
  25907. * @returns {Object} Returns the new `lodash` wrapper instance.
  25908. * @example
  25909. *
  25910. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  25911. *
  25912. * _(object).at(['a[0].b.c', 'a[1]']).value();
  25913. * // => [3, 4]
  25914. */
  25915. var wrapperAt = flatRest(function(paths) {
  25916. var length = paths.length,
  25917. start = length ? paths[0] : 0,
  25918. value = this.__wrapped__,
  25919. interceptor = function(object) { return baseAt(object, paths); };
  25920. if (length > 1 || this.__actions__.length ||
  25921. !(value instanceof LazyWrapper) || !isIndex(start)) {
  25922. return this.thru(interceptor);
  25923. }
  25924. value = value.slice(start, +start + (length ? 1 : 0));
  25925. value.__actions__.push({
  25926. 'func': thru,
  25927. 'args': [interceptor],
  25928. 'thisArg': undefined
  25929. });
  25930. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  25931. if (length && !array.length) {
  25932. array.push(undefined);
  25933. }
  25934. return array;
  25935. });
  25936. });
  25937. /**
  25938. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  25939. *
  25940. * @name chain
  25941. * @memberOf _
  25942. * @since 0.1.0
  25943. * @category Seq
  25944. * @returns {Object} Returns the new `lodash` wrapper instance.
  25945. * @example
  25946. *
  25947. * var users = [
  25948. * { 'user': 'barney', 'age': 36 },
  25949. * { 'user': 'fred', 'age': 40 }
  25950. * ];
  25951. *
  25952. * // A sequence without explicit chaining.
  25953. * _(users).head();
  25954. * // => { 'user': 'barney', 'age': 36 }
  25955. *
  25956. * // A sequence with explicit chaining.
  25957. * _(users)
  25958. * .chain()
  25959. * .head()
  25960. * .pick('user')
  25961. * .value();
  25962. * // => { 'user': 'barney' }
  25963. */
  25964. function wrapperChain() {
  25965. return chain(this);
  25966. }
  25967. /**
  25968. * Executes the chain sequence and returns the wrapped result.
  25969. *
  25970. * @name commit
  25971. * @memberOf _
  25972. * @since 3.2.0
  25973. * @category Seq
  25974. * @returns {Object} Returns the new `lodash` wrapper instance.
  25975. * @example
  25976. *
  25977. * var array = [1, 2];
  25978. * var wrapped = _(array).push(3);
  25979. *
  25980. * console.log(array);
  25981. * // => [1, 2]
  25982. *
  25983. * wrapped = wrapped.commit();
  25984. * console.log(array);
  25985. * // => [1, 2, 3]
  25986. *
  25987. * wrapped.last();
  25988. * // => 3
  25989. *
  25990. * console.log(array);
  25991. * // => [1, 2, 3]
  25992. */
  25993. function wrapperCommit() {
  25994. return new LodashWrapper(this.value(), this.__chain__);
  25995. }
  25996. /**
  25997. * Gets the next value on a wrapped object following the
  25998. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  25999. *
  26000. * @name next
  26001. * @memberOf _
  26002. * @since 4.0.0
  26003. * @category Seq
  26004. * @returns {Object} Returns the next iterator value.
  26005. * @example
  26006. *
  26007. * var wrapped = _([1, 2]);
  26008. *
  26009. * wrapped.next();
  26010. * // => { 'done': false, 'value': 1 }
  26011. *
  26012. * wrapped.next();
  26013. * // => { 'done': false, 'value': 2 }
  26014. *
  26015. * wrapped.next();
  26016. * // => { 'done': true, 'value': undefined }
  26017. */
  26018. function wrapperNext() {
  26019. if (this.__values__ === undefined) {
  26020. this.__values__ = toArray(this.value());
  26021. }
  26022. var done = this.__index__ >= this.__values__.length,
  26023. value = done ? undefined : this.__values__[this.__index__++];
  26024. return { 'done': done, 'value': value };
  26025. }
  26026. /**
  26027. * Enables the wrapper to be iterable.
  26028. *
  26029. * @name Symbol.iterator
  26030. * @memberOf _
  26031. * @since 4.0.0
  26032. * @category Seq
  26033. * @returns {Object} Returns the wrapper object.
  26034. * @example
  26035. *
  26036. * var wrapped = _([1, 2]);
  26037. *
  26038. * wrapped[Symbol.iterator]() === wrapped;
  26039. * // => true
  26040. *
  26041. * Array.from(wrapped);
  26042. * // => [1, 2]
  26043. */
  26044. function wrapperToIterator() {
  26045. return this;
  26046. }
  26047. /**
  26048. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  26049. *
  26050. * @name plant
  26051. * @memberOf _
  26052. * @since 3.2.0
  26053. * @category Seq
  26054. * @param {*} value The value to plant.
  26055. * @returns {Object} Returns the new `lodash` wrapper instance.
  26056. * @example
  26057. *
  26058. * function square(n) {
  26059. * return n * n;
  26060. * }
  26061. *
  26062. * var wrapped = _([1, 2]).map(square);
  26063. * var other = wrapped.plant([3, 4]);
  26064. *
  26065. * other.value();
  26066. * // => [9, 16]
  26067. *
  26068. * wrapped.value();
  26069. * // => [1, 4]
  26070. */
  26071. function wrapperPlant(value) {
  26072. var result,
  26073. parent = this;
  26074. while (parent instanceof baseLodash) {
  26075. var clone = wrapperClone(parent);
  26076. clone.__index__ = 0;
  26077. clone.__values__ = undefined;
  26078. if (result) {
  26079. previous.__wrapped__ = clone;
  26080. } else {
  26081. result = clone;
  26082. }
  26083. var previous = clone;
  26084. parent = parent.__wrapped__;
  26085. }
  26086. previous.__wrapped__ = value;
  26087. return result;
  26088. }
  26089. /**
  26090. * This method is the wrapper version of `_.reverse`.
  26091. *
  26092. * **Note:** This method mutates the wrapped array.
  26093. *
  26094. * @name reverse
  26095. * @memberOf _
  26096. * @since 0.1.0
  26097. * @category Seq
  26098. * @returns {Object} Returns the new `lodash` wrapper instance.
  26099. * @example
  26100. *
  26101. * var array = [1, 2, 3];
  26102. *
  26103. * _(array).reverse().value()
  26104. * // => [3, 2, 1]
  26105. *
  26106. * console.log(array);
  26107. * // => [3, 2, 1]
  26108. */
  26109. function wrapperReverse() {
  26110. var value = this.__wrapped__;
  26111. if (value instanceof LazyWrapper) {
  26112. var wrapped = value;
  26113. if (this.__actions__.length) {
  26114. wrapped = new LazyWrapper(this);
  26115. }
  26116. wrapped = wrapped.reverse();
  26117. wrapped.__actions__.push({
  26118. 'func': thru,
  26119. 'args': [reverse],
  26120. 'thisArg': undefined
  26121. });
  26122. return new LodashWrapper(wrapped, this.__chain__);
  26123. }
  26124. return this.thru(reverse);
  26125. }
  26126. /**
  26127. * Executes the chain sequence to resolve the unwrapped value.
  26128. *
  26129. * @name value
  26130. * @memberOf _
  26131. * @since 0.1.0
  26132. * @alias toJSON, valueOf
  26133. * @category Seq
  26134. * @returns {*} Returns the resolved unwrapped value.
  26135. * @example
  26136. *
  26137. * _([1, 2, 3]).value();
  26138. * // => [1, 2, 3]
  26139. */
  26140. function wrapperValue() {
  26141. return baseWrapperValue(this.__wrapped__, this.__actions__);
  26142. }
  26143. /*------------------------------------------------------------------------*/
  26144. /**
  26145. * Creates an object composed of keys generated from the results of running
  26146. * each element of `collection` thru `iteratee`. The corresponding value of
  26147. * each key is the number of times the key was returned by `iteratee`. The
  26148. * iteratee is invoked with one argument: (value).
  26149. *
  26150. * @static
  26151. * @memberOf _
  26152. * @since 0.5.0
  26153. * @category Collection
  26154. * @param {Array|Object} collection The collection to iterate over.
  26155. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26156. * @returns {Object} Returns the composed aggregate object.
  26157. * @example
  26158. *
  26159. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  26160. * // => { '4': 1, '6': 2 }
  26161. *
  26162. * // The `_.property` iteratee shorthand.
  26163. * _.countBy(['one', 'two', 'three'], 'length');
  26164. * // => { '3': 2, '5': 1 }
  26165. */
  26166. var countBy = createAggregator(function(result, value, key) {
  26167. if (hasOwnProperty.call(result, key)) {
  26168. ++result[key];
  26169. } else {
  26170. baseAssignValue(result, key, 1);
  26171. }
  26172. });
  26173. /**
  26174. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  26175. * Iteration is stopped once `predicate` returns falsey. The predicate is
  26176. * invoked with three arguments: (value, index|key, collection).
  26177. *
  26178. * **Note:** This method returns `true` for
  26179. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  26180. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  26181. * elements of empty collections.
  26182. *
  26183. * @static
  26184. * @memberOf _
  26185. * @since 0.1.0
  26186. * @category Collection
  26187. * @param {Array|Object} collection The collection to iterate over.
  26188. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26189. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26190. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  26191. * else `false`.
  26192. * @example
  26193. *
  26194. * _.every([true, 1, null, 'yes'], Boolean);
  26195. * // => false
  26196. *
  26197. * var users = [
  26198. * { 'user': 'barney', 'age': 36, 'active': false },
  26199. * { 'user': 'fred', 'age': 40, 'active': false }
  26200. * ];
  26201. *
  26202. * // The `_.matches` iteratee shorthand.
  26203. * _.every(users, { 'user': 'barney', 'active': false });
  26204. * // => false
  26205. *
  26206. * // The `_.matchesProperty` iteratee shorthand.
  26207. * _.every(users, ['active', false]);
  26208. * // => true
  26209. *
  26210. * // The `_.property` iteratee shorthand.
  26211. * _.every(users, 'active');
  26212. * // => false
  26213. */
  26214. function every(collection, predicate, guard) {
  26215. var func = isArray(collection) ? arrayEvery : baseEvery;
  26216. if (guard && isIterateeCall(collection, predicate, guard)) {
  26217. predicate = undefined;
  26218. }
  26219. return func(collection, getIteratee(predicate, 3));
  26220. }
  26221. /**
  26222. * Iterates over elements of `collection`, returning an array of all elements
  26223. * `predicate` returns truthy for. The predicate is invoked with three
  26224. * arguments: (value, index|key, collection).
  26225. *
  26226. * **Note:** Unlike `_.remove`, this method returns a new array.
  26227. *
  26228. * @static
  26229. * @memberOf _
  26230. * @since 0.1.0
  26231. * @category Collection
  26232. * @param {Array|Object} collection The collection to iterate over.
  26233. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26234. * @returns {Array} Returns the new filtered array.
  26235. * @see _.reject
  26236. * @example
  26237. *
  26238. * var users = [
  26239. * { 'user': 'barney', 'age': 36, 'active': true },
  26240. * { 'user': 'fred', 'age': 40, 'active': false }
  26241. * ];
  26242. *
  26243. * _.filter(users, function(o) { return !o.active; });
  26244. * // => objects for ['fred']
  26245. *
  26246. * // The `_.matches` iteratee shorthand.
  26247. * _.filter(users, { 'age': 36, 'active': true });
  26248. * // => objects for ['barney']
  26249. *
  26250. * // The `_.matchesProperty` iteratee shorthand.
  26251. * _.filter(users, ['active', false]);
  26252. * // => objects for ['fred']
  26253. *
  26254. * // The `_.property` iteratee shorthand.
  26255. * _.filter(users, 'active');
  26256. * // => objects for ['barney']
  26257. */
  26258. function filter(collection, predicate) {
  26259. var func = isArray(collection) ? arrayFilter : baseFilter;
  26260. return func(collection, getIteratee(predicate, 3));
  26261. }
  26262. /**
  26263. * Iterates over elements of `collection`, returning the first element
  26264. * `predicate` returns truthy for. The predicate is invoked with three
  26265. * arguments: (value, index|key, collection).
  26266. *
  26267. * @static
  26268. * @memberOf _
  26269. * @since 0.1.0
  26270. * @category Collection
  26271. * @param {Array|Object} collection The collection to inspect.
  26272. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26273. * @param {number} [fromIndex=0] The index to search from.
  26274. * @returns {*} Returns the matched element, else `undefined`.
  26275. * @example
  26276. *
  26277. * var users = [
  26278. * { 'user': 'barney', 'age': 36, 'active': true },
  26279. * { 'user': 'fred', 'age': 40, 'active': false },
  26280. * { 'user': 'pebbles', 'age': 1, 'active': true }
  26281. * ];
  26282. *
  26283. * _.find(users, function(o) { return o.age < 40; });
  26284. * // => object for 'barney'
  26285. *
  26286. * // The `_.matches` iteratee shorthand.
  26287. * _.find(users, { 'age': 1, 'active': true });
  26288. * // => object for 'pebbles'
  26289. *
  26290. * // The `_.matchesProperty` iteratee shorthand.
  26291. * _.find(users, ['active', false]);
  26292. * // => object for 'fred'
  26293. *
  26294. * // The `_.property` iteratee shorthand.
  26295. * _.find(users, 'active');
  26296. * // => object for 'barney'
  26297. */
  26298. var find = createFind(findIndex);
  26299. /**
  26300. * This method is like `_.find` except that it iterates over elements of
  26301. * `collection` from right to left.
  26302. *
  26303. * @static
  26304. * @memberOf _
  26305. * @since 2.0.0
  26306. * @category Collection
  26307. * @param {Array|Object} collection The collection to inspect.
  26308. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26309. * @param {number} [fromIndex=collection.length-1] The index to search from.
  26310. * @returns {*} Returns the matched element, else `undefined`.
  26311. * @example
  26312. *
  26313. * _.findLast([1, 2, 3, 4], function(n) {
  26314. * return n % 2 == 1;
  26315. * });
  26316. * // => 3
  26317. */
  26318. var findLast = createFind(findLastIndex);
  26319. /**
  26320. * Creates a flattened array of values by running each element in `collection`
  26321. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  26322. * with three arguments: (value, index|key, collection).
  26323. *
  26324. * @static
  26325. * @memberOf _
  26326. * @since 4.0.0
  26327. * @category Collection
  26328. * @param {Array|Object} collection The collection to iterate over.
  26329. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26330. * @returns {Array} Returns the new flattened array.
  26331. * @example
  26332. *
  26333. * function duplicate(n) {
  26334. * return [n, n];
  26335. * }
  26336. *
  26337. * _.flatMap([1, 2], duplicate);
  26338. * // => [1, 1, 2, 2]
  26339. */
  26340. function flatMap(collection, iteratee) {
  26341. return baseFlatten(map(collection, iteratee), 1);
  26342. }
  26343. /**
  26344. * This method is like `_.flatMap` except that it recursively flattens the
  26345. * mapped results.
  26346. *
  26347. * @static
  26348. * @memberOf _
  26349. * @since 4.7.0
  26350. * @category Collection
  26351. * @param {Array|Object} collection The collection to iterate over.
  26352. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26353. * @returns {Array} Returns the new flattened array.
  26354. * @example
  26355. *
  26356. * function duplicate(n) {
  26357. * return [[[n, n]]];
  26358. * }
  26359. *
  26360. * _.flatMapDeep([1, 2], duplicate);
  26361. * // => [1, 1, 2, 2]
  26362. */
  26363. function flatMapDeep(collection, iteratee) {
  26364. return baseFlatten(map(collection, iteratee), INFINITY);
  26365. }
  26366. /**
  26367. * This method is like `_.flatMap` except that it recursively flattens the
  26368. * mapped results up to `depth` times.
  26369. *
  26370. * @static
  26371. * @memberOf _
  26372. * @since 4.7.0
  26373. * @category Collection
  26374. * @param {Array|Object} collection The collection to iterate over.
  26375. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26376. * @param {number} [depth=1] The maximum recursion depth.
  26377. * @returns {Array} Returns the new flattened array.
  26378. * @example
  26379. *
  26380. * function duplicate(n) {
  26381. * return [[[n, n]]];
  26382. * }
  26383. *
  26384. * _.flatMapDepth([1, 2], duplicate, 2);
  26385. * // => [[1, 1], [2, 2]]
  26386. */
  26387. function flatMapDepth(collection, iteratee, depth) {
  26388. depth = depth === undefined ? 1 : toInteger(depth);
  26389. return baseFlatten(map(collection, iteratee), depth);
  26390. }
  26391. /**
  26392. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  26393. * The iteratee is invoked with three arguments: (value, index|key, collection).
  26394. * Iteratee functions may exit iteration early by explicitly returning `false`.
  26395. *
  26396. * **Note:** As with other "Collections" methods, objects with a "length"
  26397. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  26398. * or `_.forOwn` for object iteration.
  26399. *
  26400. * @static
  26401. * @memberOf _
  26402. * @since 0.1.0
  26403. * @alias each
  26404. * @category Collection
  26405. * @param {Array|Object} collection The collection to iterate over.
  26406. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26407. * @returns {Array|Object} Returns `collection`.
  26408. * @see _.forEachRight
  26409. * @example
  26410. *
  26411. * _.forEach([1, 2], function(value) {
  26412. * console.log(value);
  26413. * });
  26414. * // => Logs `1` then `2`.
  26415. *
  26416. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  26417. * console.log(key);
  26418. * });
  26419. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  26420. */
  26421. function forEach(collection, iteratee) {
  26422. var func = isArray(collection) ? arrayEach : baseEach;
  26423. return func(collection, getIteratee(iteratee, 3));
  26424. }
  26425. /**
  26426. * This method is like `_.forEach` except that it iterates over elements of
  26427. * `collection` from right to left.
  26428. *
  26429. * @static
  26430. * @memberOf _
  26431. * @since 2.0.0
  26432. * @alias eachRight
  26433. * @category Collection
  26434. * @param {Array|Object} collection The collection to iterate over.
  26435. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26436. * @returns {Array|Object} Returns `collection`.
  26437. * @see _.forEach
  26438. * @example
  26439. *
  26440. * _.forEachRight([1, 2], function(value) {
  26441. * console.log(value);
  26442. * });
  26443. * // => Logs `2` then `1`.
  26444. */
  26445. function forEachRight(collection, iteratee) {
  26446. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  26447. return func(collection, getIteratee(iteratee, 3));
  26448. }
  26449. /**
  26450. * Creates an object composed of keys generated from the results of running
  26451. * each element of `collection` thru `iteratee`. The order of grouped values
  26452. * is determined by the order they occur in `collection`. The corresponding
  26453. * value of each key is an array of elements responsible for generating the
  26454. * key. The iteratee is invoked with one argument: (value).
  26455. *
  26456. * @static
  26457. * @memberOf _
  26458. * @since 0.1.0
  26459. * @category Collection
  26460. * @param {Array|Object} collection The collection to iterate over.
  26461. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26462. * @returns {Object} Returns the composed aggregate object.
  26463. * @example
  26464. *
  26465. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  26466. * // => { '4': [4.2], '6': [6.1, 6.3] }
  26467. *
  26468. * // The `_.property` iteratee shorthand.
  26469. * _.groupBy(['one', 'two', 'three'], 'length');
  26470. * // => { '3': ['one', 'two'], '5': ['three'] }
  26471. */
  26472. var groupBy = createAggregator(function(result, value, key) {
  26473. if (hasOwnProperty.call(result, key)) {
  26474. result[key].push(value);
  26475. } else {
  26476. baseAssignValue(result, key, [value]);
  26477. }
  26478. });
  26479. /**
  26480. * Checks if `value` is in `collection`. If `collection` is a string, it's
  26481. * checked for a substring of `value`, otherwise
  26482. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  26483. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  26484. * the offset from the end of `collection`.
  26485. *
  26486. * @static
  26487. * @memberOf _
  26488. * @since 0.1.0
  26489. * @category Collection
  26490. * @param {Array|Object|string} collection The collection to inspect.
  26491. * @param {*} value The value to search for.
  26492. * @param {number} [fromIndex=0] The index to search from.
  26493. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26494. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  26495. * @example
  26496. *
  26497. * _.includes([1, 2, 3], 1);
  26498. * // => true
  26499. *
  26500. * _.includes([1, 2, 3], 1, 2);
  26501. * // => false
  26502. *
  26503. * _.includes({ 'a': 1, 'b': 2 }, 1);
  26504. * // => true
  26505. *
  26506. * _.includes('abcd', 'bc');
  26507. * // => true
  26508. */
  26509. function includes(collection, value, fromIndex, guard) {
  26510. collection = isArrayLike(collection) ? collection : values(collection);
  26511. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  26512. var length = collection.length;
  26513. if (fromIndex < 0) {
  26514. fromIndex = nativeMax(length + fromIndex, 0);
  26515. }
  26516. return isString(collection)
  26517. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  26518. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  26519. }
  26520. /**
  26521. * Invokes the method at `path` of each element in `collection`, returning
  26522. * an array of the results of each invoked method. Any additional arguments
  26523. * are provided to each invoked method. If `path` is a function, it's invoked
  26524. * for, and `this` bound to, each element in `collection`.
  26525. *
  26526. * @static
  26527. * @memberOf _
  26528. * @since 4.0.0
  26529. * @category Collection
  26530. * @param {Array|Object} collection The collection to iterate over.
  26531. * @param {Array|Function|string} path The path of the method to invoke or
  26532. * the function invoked per iteration.
  26533. * @param {...*} [args] The arguments to invoke each method with.
  26534. * @returns {Array} Returns the array of results.
  26535. * @example
  26536. *
  26537. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  26538. * // => [[1, 5, 7], [1, 2, 3]]
  26539. *
  26540. * _.invokeMap([123, 456], String.prototype.split, '');
  26541. * // => [['1', '2', '3'], ['4', '5', '6']]
  26542. */
  26543. var invokeMap = baseRest(function(collection, path, args) {
  26544. var index = -1,
  26545. isFunc = typeof path == 'function',
  26546. result = isArrayLike(collection) ? Array(collection.length) : [];
  26547. baseEach(collection, function(value) {
  26548. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  26549. });
  26550. return result;
  26551. });
  26552. /**
  26553. * Creates an object composed of keys generated from the results of running
  26554. * each element of `collection` thru `iteratee`. The corresponding value of
  26555. * each key is the last element responsible for generating the key. The
  26556. * iteratee is invoked with one argument: (value).
  26557. *
  26558. * @static
  26559. * @memberOf _
  26560. * @since 4.0.0
  26561. * @category Collection
  26562. * @param {Array|Object} collection The collection to iterate over.
  26563. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26564. * @returns {Object} Returns the composed aggregate object.
  26565. * @example
  26566. *
  26567. * var array = [
  26568. * { 'dir': 'left', 'code': 97 },
  26569. * { 'dir': 'right', 'code': 100 }
  26570. * ];
  26571. *
  26572. * _.keyBy(array, function(o) {
  26573. * return String.fromCharCode(o.code);
  26574. * });
  26575. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  26576. *
  26577. * _.keyBy(array, 'dir');
  26578. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  26579. */
  26580. var keyBy = createAggregator(function(result, value, key) {
  26581. baseAssignValue(result, key, value);
  26582. });
  26583. /**
  26584. * Creates an array of values by running each element in `collection` thru
  26585. * `iteratee`. The iteratee is invoked with three arguments:
  26586. * (value, index|key, collection).
  26587. *
  26588. * Many lodash methods are guarded to work as iteratees for methods like
  26589. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  26590. *
  26591. * The guarded methods are:
  26592. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  26593. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  26594. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  26595. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  26596. *
  26597. * @static
  26598. * @memberOf _
  26599. * @since 0.1.0
  26600. * @category Collection
  26601. * @param {Array|Object} collection The collection to iterate over.
  26602. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26603. * @returns {Array} Returns the new mapped array.
  26604. * @example
  26605. *
  26606. * function square(n) {
  26607. * return n * n;
  26608. * }
  26609. *
  26610. * _.map([4, 8], square);
  26611. * // => [16, 64]
  26612. *
  26613. * _.map({ 'a': 4, 'b': 8 }, square);
  26614. * // => [16, 64] (iteration order is not guaranteed)
  26615. *
  26616. * var users = [
  26617. * { 'user': 'barney' },
  26618. * { 'user': 'fred' }
  26619. * ];
  26620. *
  26621. * // The `_.property` iteratee shorthand.
  26622. * _.map(users, 'user');
  26623. * // => ['barney', 'fred']
  26624. */
  26625. function map(collection, iteratee) {
  26626. var func = isArray(collection) ? arrayMap : baseMap;
  26627. return func(collection, getIteratee(iteratee, 3));
  26628. }
  26629. /**
  26630. * This method is like `_.sortBy` except that it allows specifying the sort
  26631. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  26632. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  26633. * descending or "asc" for ascending sort order of corresponding values.
  26634. *
  26635. * @static
  26636. * @memberOf _
  26637. * @since 4.0.0
  26638. * @category Collection
  26639. * @param {Array|Object} collection The collection to iterate over.
  26640. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  26641. * The iteratees to sort by.
  26642. * @param {string[]} [orders] The sort orders of `iteratees`.
  26643. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26644. * @returns {Array} Returns the new sorted array.
  26645. * @example
  26646. *
  26647. * var users = [
  26648. * { 'user': 'fred', 'age': 48 },
  26649. * { 'user': 'barney', 'age': 34 },
  26650. * { 'user': 'fred', 'age': 40 },
  26651. * { 'user': 'barney', 'age': 36 }
  26652. * ];
  26653. *
  26654. * // Sort by `user` in ascending order and by `age` in descending order.
  26655. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  26656. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26657. */
  26658. function orderBy(collection, iteratees, orders, guard) {
  26659. if (collection == null) {
  26660. return [];
  26661. }
  26662. if (!isArray(iteratees)) {
  26663. iteratees = iteratees == null ? [] : [iteratees];
  26664. }
  26665. orders = guard ? undefined : orders;
  26666. if (!isArray(orders)) {
  26667. orders = orders == null ? [] : [orders];
  26668. }
  26669. return baseOrderBy(collection, iteratees, orders);
  26670. }
  26671. /**
  26672. * Creates an array of elements split into two groups, the first of which
  26673. * contains elements `predicate` returns truthy for, the second of which
  26674. * contains elements `predicate` returns falsey for. The predicate is
  26675. * invoked with one argument: (value).
  26676. *
  26677. * @static
  26678. * @memberOf _
  26679. * @since 3.0.0
  26680. * @category Collection
  26681. * @param {Array|Object} collection The collection to iterate over.
  26682. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26683. * @returns {Array} Returns the array of grouped elements.
  26684. * @example
  26685. *
  26686. * var users = [
  26687. * { 'user': 'barney', 'age': 36, 'active': false },
  26688. * { 'user': 'fred', 'age': 40, 'active': true },
  26689. * { 'user': 'pebbles', 'age': 1, 'active': false }
  26690. * ];
  26691. *
  26692. * _.partition(users, function(o) { return o.active; });
  26693. * // => objects for [['fred'], ['barney', 'pebbles']]
  26694. *
  26695. * // The `_.matches` iteratee shorthand.
  26696. * _.partition(users, { 'age': 1, 'active': false });
  26697. * // => objects for [['pebbles'], ['barney', 'fred']]
  26698. *
  26699. * // The `_.matchesProperty` iteratee shorthand.
  26700. * _.partition(users, ['active', false]);
  26701. * // => objects for [['barney', 'pebbles'], ['fred']]
  26702. *
  26703. * // The `_.property` iteratee shorthand.
  26704. * _.partition(users, 'active');
  26705. * // => objects for [['fred'], ['barney', 'pebbles']]
  26706. */
  26707. var partition = createAggregator(function(result, value, key) {
  26708. result[key ? 0 : 1].push(value);
  26709. }, function() { return [[], []]; });
  26710. /**
  26711. * Reduces `collection` to a value which is the accumulated result of running
  26712. * each element in `collection` thru `iteratee`, where each successive
  26713. * invocation is supplied the return value of the previous. If `accumulator`
  26714. * is not given, the first element of `collection` is used as the initial
  26715. * value. The iteratee is invoked with four arguments:
  26716. * (accumulator, value, index|key, collection).
  26717. *
  26718. * Many lodash methods are guarded to work as iteratees for methods like
  26719. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  26720. *
  26721. * The guarded methods are:
  26722. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  26723. * and `sortBy`
  26724. *
  26725. * @static
  26726. * @memberOf _
  26727. * @since 0.1.0
  26728. * @category Collection
  26729. * @param {Array|Object} collection The collection to iterate over.
  26730. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26731. * @param {*} [accumulator] The initial value.
  26732. * @returns {*} Returns the accumulated value.
  26733. * @see _.reduceRight
  26734. * @example
  26735. *
  26736. * _.reduce([1, 2], function(sum, n) {
  26737. * return sum + n;
  26738. * }, 0);
  26739. * // => 3
  26740. *
  26741. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  26742. * (result[value] || (result[value] = [])).push(key);
  26743. * return result;
  26744. * }, {});
  26745. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  26746. */
  26747. function reduce(collection, iteratee, accumulator) {
  26748. var func = isArray(collection) ? arrayReduce : baseReduce,
  26749. initAccum = arguments.length < 3;
  26750. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  26751. }
  26752. /**
  26753. * This method is like `_.reduce` except that it iterates over elements of
  26754. * `collection` from right to left.
  26755. *
  26756. * @static
  26757. * @memberOf _
  26758. * @since 0.1.0
  26759. * @category Collection
  26760. * @param {Array|Object} collection The collection to iterate over.
  26761. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26762. * @param {*} [accumulator] The initial value.
  26763. * @returns {*} Returns the accumulated value.
  26764. * @see _.reduce
  26765. * @example
  26766. *
  26767. * var array = [[0, 1], [2, 3], [4, 5]];
  26768. *
  26769. * _.reduceRight(array, function(flattened, other) {
  26770. * return flattened.concat(other);
  26771. * }, []);
  26772. * // => [4, 5, 2, 3, 0, 1]
  26773. */
  26774. function reduceRight(collection, iteratee, accumulator) {
  26775. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  26776. initAccum = arguments.length < 3;
  26777. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  26778. }
  26779. /**
  26780. * The opposite of `_.filter`; this method returns the elements of `collection`
  26781. * that `predicate` does **not** return truthy for.
  26782. *
  26783. * @static
  26784. * @memberOf _
  26785. * @since 0.1.0
  26786. * @category Collection
  26787. * @param {Array|Object} collection The collection to iterate over.
  26788. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26789. * @returns {Array} Returns the new filtered array.
  26790. * @see _.filter
  26791. * @example
  26792. *
  26793. * var users = [
  26794. * { 'user': 'barney', 'age': 36, 'active': false },
  26795. * { 'user': 'fred', 'age': 40, 'active': true }
  26796. * ];
  26797. *
  26798. * _.reject(users, function(o) { return !o.active; });
  26799. * // => objects for ['fred']
  26800. *
  26801. * // The `_.matches` iteratee shorthand.
  26802. * _.reject(users, { 'age': 40, 'active': true });
  26803. * // => objects for ['barney']
  26804. *
  26805. * // The `_.matchesProperty` iteratee shorthand.
  26806. * _.reject(users, ['active', false]);
  26807. * // => objects for ['fred']
  26808. *
  26809. * // The `_.property` iteratee shorthand.
  26810. * _.reject(users, 'active');
  26811. * // => objects for ['barney']
  26812. */
  26813. function reject(collection, predicate) {
  26814. var func = isArray(collection) ? arrayFilter : baseFilter;
  26815. return func(collection, negate(getIteratee(predicate, 3)));
  26816. }
  26817. /**
  26818. * Gets a random element from `collection`.
  26819. *
  26820. * @static
  26821. * @memberOf _
  26822. * @since 2.0.0
  26823. * @category Collection
  26824. * @param {Array|Object} collection The collection to sample.
  26825. * @returns {*} Returns the random element.
  26826. * @example
  26827. *
  26828. * _.sample([1, 2, 3, 4]);
  26829. * // => 2
  26830. */
  26831. function sample(collection) {
  26832. var func = isArray(collection) ? arraySample : baseSample;
  26833. return func(collection);
  26834. }
  26835. /**
  26836. * Gets `n` random elements at unique keys from `collection` up to the
  26837. * size of `collection`.
  26838. *
  26839. * @static
  26840. * @memberOf _
  26841. * @since 4.0.0
  26842. * @category Collection
  26843. * @param {Array|Object} collection The collection to sample.
  26844. * @param {number} [n=1] The number of elements to sample.
  26845. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26846. * @returns {Array} Returns the random elements.
  26847. * @example
  26848. *
  26849. * _.sampleSize([1, 2, 3], 2);
  26850. * // => [3, 1]
  26851. *
  26852. * _.sampleSize([1, 2, 3], 4);
  26853. * // => [2, 3, 1]
  26854. */
  26855. function sampleSize(collection, n, guard) {
  26856. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  26857. n = 1;
  26858. } else {
  26859. n = toInteger(n);
  26860. }
  26861. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  26862. return func(collection, n);
  26863. }
  26864. /**
  26865. * Creates an array of shuffled values, using a version of the
  26866. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  26867. *
  26868. * @static
  26869. * @memberOf _
  26870. * @since 0.1.0
  26871. * @category Collection
  26872. * @param {Array|Object} collection The collection to shuffle.
  26873. * @returns {Array} Returns the new shuffled array.
  26874. * @example
  26875. *
  26876. * _.shuffle([1, 2, 3, 4]);
  26877. * // => [4, 1, 3, 2]
  26878. */
  26879. function shuffle(collection) {
  26880. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  26881. return func(collection);
  26882. }
  26883. /**
  26884. * Gets the size of `collection` by returning its length for array-like
  26885. * values or the number of own enumerable string keyed properties for objects.
  26886. *
  26887. * @static
  26888. * @memberOf _
  26889. * @since 0.1.0
  26890. * @category Collection
  26891. * @param {Array|Object|string} collection The collection to inspect.
  26892. * @returns {number} Returns the collection size.
  26893. * @example
  26894. *
  26895. * _.size([1, 2, 3]);
  26896. * // => 3
  26897. *
  26898. * _.size({ 'a': 1, 'b': 2 });
  26899. * // => 2
  26900. *
  26901. * _.size('pebbles');
  26902. * // => 7
  26903. */
  26904. function size(collection) {
  26905. if (collection == null) {
  26906. return 0;
  26907. }
  26908. if (isArrayLike(collection)) {
  26909. return isString(collection) ? stringSize(collection) : collection.length;
  26910. }
  26911. var tag = getTag(collection);
  26912. if (tag == mapTag || tag == setTag) {
  26913. return collection.size;
  26914. }
  26915. return baseKeys(collection).length;
  26916. }
  26917. /**
  26918. * Checks if `predicate` returns truthy for **any** element of `collection`.
  26919. * Iteration is stopped once `predicate` returns truthy. The predicate is
  26920. * invoked with three arguments: (value, index|key, collection).
  26921. *
  26922. * @static
  26923. * @memberOf _
  26924. * @since 0.1.0
  26925. * @category Collection
  26926. * @param {Array|Object} collection The collection to iterate over.
  26927. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26928. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26929. * @returns {boolean} Returns `true` if any element passes the predicate check,
  26930. * else `false`.
  26931. * @example
  26932. *
  26933. * _.some([null, 0, 'yes', false], Boolean);
  26934. * // => true
  26935. *
  26936. * var users = [
  26937. * { 'user': 'barney', 'active': true },
  26938. * { 'user': 'fred', 'active': false }
  26939. * ];
  26940. *
  26941. * // The `_.matches` iteratee shorthand.
  26942. * _.some(users, { 'user': 'barney', 'active': false });
  26943. * // => false
  26944. *
  26945. * // The `_.matchesProperty` iteratee shorthand.
  26946. * _.some(users, ['active', false]);
  26947. * // => true
  26948. *
  26949. * // The `_.property` iteratee shorthand.
  26950. * _.some(users, 'active');
  26951. * // => true
  26952. */
  26953. function some(collection, predicate, guard) {
  26954. var func = isArray(collection) ? arraySome : baseSome;
  26955. if (guard && isIterateeCall(collection, predicate, guard)) {
  26956. predicate = undefined;
  26957. }
  26958. return func(collection, getIteratee(predicate, 3));
  26959. }
  26960. /**
  26961. * Creates an array of elements, sorted in ascending order by the results of
  26962. * running each element in a collection thru each iteratee. This method
  26963. * performs a stable sort, that is, it preserves the original sort order of
  26964. * equal elements. The iteratees are invoked with one argument: (value).
  26965. *
  26966. * @static
  26967. * @memberOf _
  26968. * @since 0.1.0
  26969. * @category Collection
  26970. * @param {Array|Object} collection The collection to iterate over.
  26971. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  26972. * The iteratees to sort by.
  26973. * @returns {Array} Returns the new sorted array.
  26974. * @example
  26975. *
  26976. * var users = [
  26977. * { 'user': 'fred', 'age': 48 },
  26978. * { 'user': 'barney', 'age': 36 },
  26979. * { 'user': 'fred', 'age': 40 },
  26980. * { 'user': 'barney', 'age': 34 }
  26981. * ];
  26982. *
  26983. * _.sortBy(users, [function(o) { return o.user; }]);
  26984. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26985. *
  26986. * _.sortBy(users, ['user', 'age']);
  26987. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  26988. */
  26989. var sortBy = baseRest(function(collection, iteratees) {
  26990. if (collection == null) {
  26991. return [];
  26992. }
  26993. var length = iteratees.length;
  26994. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  26995. iteratees = [];
  26996. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  26997. iteratees = [iteratees[0]];
  26998. }
  26999. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  27000. });
  27001. /*------------------------------------------------------------------------*/
  27002. /**
  27003. * Gets the timestamp of the number of milliseconds that have elapsed since
  27004. * the Unix epoch (1 January 1970 00:00:00 UTC).
  27005. *
  27006. * @static
  27007. * @memberOf _
  27008. * @since 2.4.0
  27009. * @category Date
  27010. * @returns {number} Returns the timestamp.
  27011. * @example
  27012. *
  27013. * _.defer(function(stamp) {
  27014. * console.log(_.now() - stamp);
  27015. * }, _.now());
  27016. * // => Logs the number of milliseconds it took for the deferred invocation.
  27017. */
  27018. var now = ctxNow || function() {
  27019. return root.Date.now();
  27020. };
  27021. /*------------------------------------------------------------------------*/
  27022. /**
  27023. * The opposite of `_.before`; this method creates a function that invokes
  27024. * `func` once it's called `n` or more times.
  27025. *
  27026. * @static
  27027. * @memberOf _
  27028. * @since 0.1.0
  27029. * @category Function
  27030. * @param {number} n The number of calls before `func` is invoked.
  27031. * @param {Function} func The function to restrict.
  27032. * @returns {Function} Returns the new restricted function.
  27033. * @example
  27034. *
  27035. * var saves = ['profile', 'settings'];
  27036. *
  27037. * var done = _.after(saves.length, function() {
  27038. * console.log('done saving!');
  27039. * });
  27040. *
  27041. * _.forEach(saves, function(type) {
  27042. * asyncSave({ 'type': type, 'complete': done });
  27043. * });
  27044. * // => Logs 'done saving!' after the two async saves have completed.
  27045. */
  27046. function after(n, func) {
  27047. if (typeof func != 'function') {
  27048. throw new TypeError(FUNC_ERROR_TEXT);
  27049. }
  27050. n = toInteger(n);
  27051. return function() {
  27052. if (--n < 1) {
  27053. return func.apply(this, arguments);
  27054. }
  27055. };
  27056. }
  27057. /**
  27058. * Creates a function that invokes `func`, with up to `n` arguments,
  27059. * ignoring any additional arguments.
  27060. *
  27061. * @static
  27062. * @memberOf _
  27063. * @since 3.0.0
  27064. * @category Function
  27065. * @param {Function} func The function to cap arguments for.
  27066. * @param {number} [n=func.length] The arity cap.
  27067. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27068. * @returns {Function} Returns the new capped function.
  27069. * @example
  27070. *
  27071. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  27072. * // => [6, 8, 10]
  27073. */
  27074. function ary(func, n, guard) {
  27075. n = guard ? undefined : n;
  27076. n = (func && n == null) ? func.length : n;
  27077. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  27078. }
  27079. /**
  27080. * Creates a function that invokes `func`, with the `this` binding and arguments
  27081. * of the created function, while it's called less than `n` times. Subsequent
  27082. * calls to the created function return the result of the last `func` invocation.
  27083. *
  27084. * @static
  27085. * @memberOf _
  27086. * @since 3.0.0
  27087. * @category Function
  27088. * @param {number} n The number of calls at which `func` is no longer invoked.
  27089. * @param {Function} func The function to restrict.
  27090. * @returns {Function} Returns the new restricted function.
  27091. * @example
  27092. *
  27093. * jQuery(element).on('click', _.before(5, addContactToList));
  27094. * // => Allows adding up to 4 contacts to the list.
  27095. */
  27096. function before(n, func) {
  27097. var result;
  27098. if (typeof func != 'function') {
  27099. throw new TypeError(FUNC_ERROR_TEXT);
  27100. }
  27101. n = toInteger(n);
  27102. return function() {
  27103. if (--n > 0) {
  27104. result = func.apply(this, arguments);
  27105. }
  27106. if (n <= 1) {
  27107. func = undefined;
  27108. }
  27109. return result;
  27110. };
  27111. }
  27112. /**
  27113. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  27114. * and `partials` prepended to the arguments it receives.
  27115. *
  27116. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  27117. * may be used as a placeholder for partially applied arguments.
  27118. *
  27119. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  27120. * property of bound functions.
  27121. *
  27122. * @static
  27123. * @memberOf _
  27124. * @since 0.1.0
  27125. * @category Function
  27126. * @param {Function} func The function to bind.
  27127. * @param {*} thisArg The `this` binding of `func`.
  27128. * @param {...*} [partials] The arguments to be partially applied.
  27129. * @returns {Function} Returns the new bound function.
  27130. * @example
  27131. *
  27132. * function greet(greeting, punctuation) {
  27133. * return greeting + ' ' + this.user + punctuation;
  27134. * }
  27135. *
  27136. * var object = { 'user': 'fred' };
  27137. *
  27138. * var bound = _.bind(greet, object, 'hi');
  27139. * bound('!');
  27140. * // => 'hi fred!'
  27141. *
  27142. * // Bound with placeholders.
  27143. * var bound = _.bind(greet, object, _, '!');
  27144. * bound('hi');
  27145. * // => 'hi fred!'
  27146. */
  27147. var bind = baseRest(function(func, thisArg, partials) {
  27148. var bitmask = WRAP_BIND_FLAG;
  27149. if (partials.length) {
  27150. var holders = replaceHolders(partials, getHolder(bind));
  27151. bitmask |= WRAP_PARTIAL_FLAG;
  27152. }
  27153. return createWrap(func, bitmask, thisArg, partials, holders);
  27154. });
  27155. /**
  27156. * Creates a function that invokes the method at `object[key]` with `partials`
  27157. * prepended to the arguments it receives.
  27158. *
  27159. * This method differs from `_.bind` by allowing bound functions to reference
  27160. * methods that may be redefined or don't yet exist. See
  27161. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  27162. * for more details.
  27163. *
  27164. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  27165. * builds, may be used as a placeholder for partially applied arguments.
  27166. *
  27167. * @static
  27168. * @memberOf _
  27169. * @since 0.10.0
  27170. * @category Function
  27171. * @param {Object} object The object to invoke the method on.
  27172. * @param {string} key The key of the method.
  27173. * @param {...*} [partials] The arguments to be partially applied.
  27174. * @returns {Function} Returns the new bound function.
  27175. * @example
  27176. *
  27177. * var object = {
  27178. * 'user': 'fred',
  27179. * 'greet': function(greeting, punctuation) {
  27180. * return greeting + ' ' + this.user + punctuation;
  27181. * }
  27182. * };
  27183. *
  27184. * var bound = _.bindKey(object, 'greet', 'hi');
  27185. * bound('!');
  27186. * // => 'hi fred!'
  27187. *
  27188. * object.greet = function(greeting, punctuation) {
  27189. * return greeting + 'ya ' + this.user + punctuation;
  27190. * };
  27191. *
  27192. * bound('!');
  27193. * // => 'hiya fred!'
  27194. *
  27195. * // Bound with placeholders.
  27196. * var bound = _.bindKey(object, 'greet', _, '!');
  27197. * bound('hi');
  27198. * // => 'hiya fred!'
  27199. */
  27200. var bindKey = baseRest(function(object, key, partials) {
  27201. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  27202. if (partials.length) {
  27203. var holders = replaceHolders(partials, getHolder(bindKey));
  27204. bitmask |= WRAP_PARTIAL_FLAG;
  27205. }
  27206. return createWrap(key, bitmask, object, partials, holders);
  27207. });
  27208. /**
  27209. * Creates a function that accepts arguments of `func` and either invokes
  27210. * `func` returning its result, if at least `arity` number of arguments have
  27211. * been provided, or returns a function that accepts the remaining `func`
  27212. * arguments, and so on. The arity of `func` may be specified if `func.length`
  27213. * is not sufficient.
  27214. *
  27215. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  27216. * may be used as a placeholder for provided arguments.
  27217. *
  27218. * **Note:** This method doesn't set the "length" property of curried functions.
  27219. *
  27220. * @static
  27221. * @memberOf _
  27222. * @since 2.0.0
  27223. * @category Function
  27224. * @param {Function} func The function to curry.
  27225. * @param {number} [arity=func.length] The arity of `func`.
  27226. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27227. * @returns {Function} Returns the new curried function.
  27228. * @example
  27229. *
  27230. * var abc = function(a, b, c) {
  27231. * return [a, b, c];
  27232. * };
  27233. *
  27234. * var curried = _.curry(abc);
  27235. *
  27236. * curried(1)(2)(3);
  27237. * // => [1, 2, 3]
  27238. *
  27239. * curried(1, 2)(3);
  27240. * // => [1, 2, 3]
  27241. *
  27242. * curried(1, 2, 3);
  27243. * // => [1, 2, 3]
  27244. *
  27245. * // Curried with placeholders.
  27246. * curried(1)(_, 3)(2);
  27247. * // => [1, 2, 3]
  27248. */
  27249. function curry(func, arity, guard) {
  27250. arity = guard ? undefined : arity;
  27251. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27252. result.placeholder = curry.placeholder;
  27253. return result;
  27254. }
  27255. /**
  27256. * This method is like `_.curry` except that arguments are applied to `func`
  27257. * in the manner of `_.partialRight` instead of `_.partial`.
  27258. *
  27259. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  27260. * builds, may be used as a placeholder for provided arguments.
  27261. *
  27262. * **Note:** This method doesn't set the "length" property of curried functions.
  27263. *
  27264. * @static
  27265. * @memberOf _
  27266. * @since 3.0.0
  27267. * @category Function
  27268. * @param {Function} func The function to curry.
  27269. * @param {number} [arity=func.length] The arity of `func`.
  27270. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27271. * @returns {Function} Returns the new curried function.
  27272. * @example
  27273. *
  27274. * var abc = function(a, b, c) {
  27275. * return [a, b, c];
  27276. * };
  27277. *
  27278. * var curried = _.curryRight(abc);
  27279. *
  27280. * curried(3)(2)(1);
  27281. * // => [1, 2, 3]
  27282. *
  27283. * curried(2, 3)(1);
  27284. * // => [1, 2, 3]
  27285. *
  27286. * curried(1, 2, 3);
  27287. * // => [1, 2, 3]
  27288. *
  27289. * // Curried with placeholders.
  27290. * curried(3)(1, _)(2);
  27291. * // => [1, 2, 3]
  27292. */
  27293. function curryRight(func, arity, guard) {
  27294. arity = guard ? undefined : arity;
  27295. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27296. result.placeholder = curryRight.placeholder;
  27297. return result;
  27298. }
  27299. /**
  27300. * Creates a debounced function that delays invoking `func` until after `wait`
  27301. * milliseconds have elapsed since the last time the debounced function was
  27302. * invoked. The debounced function comes with a `cancel` method to cancel
  27303. * delayed `func` invocations and a `flush` method to immediately invoke them.
  27304. * Provide `options` to indicate whether `func` should be invoked on the
  27305. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  27306. * with the last arguments provided to the debounced function. Subsequent
  27307. * calls to the debounced function return the result of the last `func`
  27308. * invocation.
  27309. *
  27310. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27311. * invoked on the trailing edge of the timeout only if the debounced function
  27312. * is invoked more than once during the `wait` timeout.
  27313. *
  27314. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27315. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27316. *
  27317. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27318. * for details over the differences between `_.debounce` and `_.throttle`.
  27319. *
  27320. * @static
  27321. * @memberOf _
  27322. * @since 0.1.0
  27323. * @category Function
  27324. * @param {Function} func The function to debounce.
  27325. * @param {number} [wait=0] The number of milliseconds to delay.
  27326. * @param {Object} [options={}] The options object.
  27327. * @param {boolean} [options.leading=false]
  27328. * Specify invoking on the leading edge of the timeout.
  27329. * @param {number} [options.maxWait]
  27330. * The maximum time `func` is allowed to be delayed before it's invoked.
  27331. * @param {boolean} [options.trailing=true]
  27332. * Specify invoking on the trailing edge of the timeout.
  27333. * @returns {Function} Returns the new debounced function.
  27334. * @example
  27335. *
  27336. * // Avoid costly calculations while the window size is in flux.
  27337. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  27338. *
  27339. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  27340. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  27341. * 'leading': true,
  27342. * 'trailing': false
  27343. * }));
  27344. *
  27345. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  27346. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  27347. * var source = new EventSource('/stream');
  27348. * jQuery(source).on('message', debounced);
  27349. *
  27350. * // Cancel the trailing debounced invocation.
  27351. * jQuery(window).on('popstate', debounced.cancel);
  27352. */
  27353. function debounce(func, wait, options) {
  27354. var lastArgs,
  27355. lastThis,
  27356. maxWait,
  27357. result,
  27358. timerId,
  27359. lastCallTime,
  27360. lastInvokeTime = 0,
  27361. leading = false,
  27362. maxing = false,
  27363. trailing = true;
  27364. if (typeof func != 'function') {
  27365. throw new TypeError(FUNC_ERROR_TEXT);
  27366. }
  27367. wait = toNumber(wait) || 0;
  27368. if (isObject(options)) {
  27369. leading = !!options.leading;
  27370. maxing = 'maxWait' in options;
  27371. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  27372. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27373. }
  27374. function invokeFunc(time) {
  27375. var args = lastArgs,
  27376. thisArg = lastThis;
  27377. lastArgs = lastThis = undefined;
  27378. lastInvokeTime = time;
  27379. result = func.apply(thisArg, args);
  27380. return result;
  27381. }
  27382. function leadingEdge(time) {
  27383. // Reset any `maxWait` timer.
  27384. lastInvokeTime = time;
  27385. // Start the timer for the trailing edge.
  27386. timerId = setTimeout(timerExpired, wait);
  27387. // Invoke the leading edge.
  27388. return leading ? invokeFunc(time) : result;
  27389. }
  27390. function remainingWait(time) {
  27391. var timeSinceLastCall = time - lastCallTime,
  27392. timeSinceLastInvoke = time - lastInvokeTime,
  27393. timeWaiting = wait - timeSinceLastCall;
  27394. return maxing
  27395. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  27396. : timeWaiting;
  27397. }
  27398. function shouldInvoke(time) {
  27399. var timeSinceLastCall = time - lastCallTime,
  27400. timeSinceLastInvoke = time - lastInvokeTime;
  27401. // Either this is the first call, activity has stopped and we're at the
  27402. // trailing edge, the system time has gone backwards and we're treating
  27403. // it as the trailing edge, or we've hit the `maxWait` limit.
  27404. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  27405. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  27406. }
  27407. function timerExpired() {
  27408. var time = now();
  27409. if (shouldInvoke(time)) {
  27410. return trailingEdge(time);
  27411. }
  27412. // Restart the timer.
  27413. timerId = setTimeout(timerExpired, remainingWait(time));
  27414. }
  27415. function trailingEdge(time) {
  27416. timerId = undefined;
  27417. // Only invoke if we have `lastArgs` which means `func` has been
  27418. // debounced at least once.
  27419. if (trailing && lastArgs) {
  27420. return invokeFunc(time);
  27421. }
  27422. lastArgs = lastThis = undefined;
  27423. return result;
  27424. }
  27425. function cancel() {
  27426. if (timerId !== undefined) {
  27427. clearTimeout(timerId);
  27428. }
  27429. lastInvokeTime = 0;
  27430. lastArgs = lastCallTime = lastThis = timerId = undefined;
  27431. }
  27432. function flush() {
  27433. return timerId === undefined ? result : trailingEdge(now());
  27434. }
  27435. function debounced() {
  27436. var time = now(),
  27437. isInvoking = shouldInvoke(time);
  27438. lastArgs = arguments;
  27439. lastThis = this;
  27440. lastCallTime = time;
  27441. if (isInvoking) {
  27442. if (timerId === undefined) {
  27443. return leadingEdge(lastCallTime);
  27444. }
  27445. if (maxing) {
  27446. // Handle invocations in a tight loop.
  27447. clearTimeout(timerId);
  27448. timerId = setTimeout(timerExpired, wait);
  27449. return invokeFunc(lastCallTime);
  27450. }
  27451. }
  27452. if (timerId === undefined) {
  27453. timerId = setTimeout(timerExpired, wait);
  27454. }
  27455. return result;
  27456. }
  27457. debounced.cancel = cancel;
  27458. debounced.flush = flush;
  27459. return debounced;
  27460. }
  27461. /**
  27462. * Defers invoking the `func` until the current call stack has cleared. Any
  27463. * additional arguments are provided to `func` when it's invoked.
  27464. *
  27465. * @static
  27466. * @memberOf _
  27467. * @since 0.1.0
  27468. * @category Function
  27469. * @param {Function} func The function to defer.
  27470. * @param {...*} [args] The arguments to invoke `func` with.
  27471. * @returns {number} Returns the timer id.
  27472. * @example
  27473. *
  27474. * _.defer(function(text) {
  27475. * console.log(text);
  27476. * }, 'deferred');
  27477. * // => Logs 'deferred' after one millisecond.
  27478. */
  27479. var defer = baseRest(function(func, args) {
  27480. return baseDelay(func, 1, args);
  27481. });
  27482. /**
  27483. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  27484. * provided to `func` when it's invoked.
  27485. *
  27486. * @static
  27487. * @memberOf _
  27488. * @since 0.1.0
  27489. * @category Function
  27490. * @param {Function} func The function to delay.
  27491. * @param {number} wait The number of milliseconds to delay invocation.
  27492. * @param {...*} [args] The arguments to invoke `func` with.
  27493. * @returns {number} Returns the timer id.
  27494. * @example
  27495. *
  27496. * _.delay(function(text) {
  27497. * console.log(text);
  27498. * }, 1000, 'later');
  27499. * // => Logs 'later' after one second.
  27500. */
  27501. var delay = baseRest(function(func, wait, args) {
  27502. return baseDelay(func, toNumber(wait) || 0, args);
  27503. });
  27504. /**
  27505. * Creates a function that invokes `func` with arguments reversed.
  27506. *
  27507. * @static
  27508. * @memberOf _
  27509. * @since 4.0.0
  27510. * @category Function
  27511. * @param {Function} func The function to flip arguments for.
  27512. * @returns {Function} Returns the new flipped function.
  27513. * @example
  27514. *
  27515. * var flipped = _.flip(function() {
  27516. * return _.toArray(arguments);
  27517. * });
  27518. *
  27519. * flipped('a', 'b', 'c', 'd');
  27520. * // => ['d', 'c', 'b', 'a']
  27521. */
  27522. function flip(func) {
  27523. return createWrap(func, WRAP_FLIP_FLAG);
  27524. }
  27525. /**
  27526. * Creates a function that memoizes the result of `func`. If `resolver` is
  27527. * provided, it determines the cache key for storing the result based on the
  27528. * arguments provided to the memoized function. By default, the first argument
  27529. * provided to the memoized function is used as the map cache key. The `func`
  27530. * is invoked with the `this` binding of the memoized function.
  27531. *
  27532. * **Note:** The cache is exposed as the `cache` property on the memoized
  27533. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  27534. * constructor with one whose instances implement the
  27535. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  27536. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  27537. *
  27538. * @static
  27539. * @memberOf _
  27540. * @since 0.1.0
  27541. * @category Function
  27542. * @param {Function} func The function to have its output memoized.
  27543. * @param {Function} [resolver] The function to resolve the cache key.
  27544. * @returns {Function} Returns the new memoized function.
  27545. * @example
  27546. *
  27547. * var object = { 'a': 1, 'b': 2 };
  27548. * var other = { 'c': 3, 'd': 4 };
  27549. *
  27550. * var values = _.memoize(_.values);
  27551. * values(object);
  27552. * // => [1, 2]
  27553. *
  27554. * values(other);
  27555. * // => [3, 4]
  27556. *
  27557. * object.a = 2;
  27558. * values(object);
  27559. * // => [1, 2]
  27560. *
  27561. * // Modify the result cache.
  27562. * values.cache.set(object, ['a', 'b']);
  27563. * values(object);
  27564. * // => ['a', 'b']
  27565. *
  27566. * // Replace `_.memoize.Cache`.
  27567. * _.memoize.Cache = WeakMap;
  27568. */
  27569. function memoize(func, resolver) {
  27570. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  27571. throw new TypeError(FUNC_ERROR_TEXT);
  27572. }
  27573. var memoized = function() {
  27574. var args = arguments,
  27575. key = resolver ? resolver.apply(this, args) : args[0],
  27576. cache = memoized.cache;
  27577. if (cache.has(key)) {
  27578. return cache.get(key);
  27579. }
  27580. var result = func.apply(this, args);
  27581. memoized.cache = cache.set(key, result) || cache;
  27582. return result;
  27583. };
  27584. memoized.cache = new (memoize.Cache || MapCache);
  27585. return memoized;
  27586. }
  27587. // Expose `MapCache`.
  27588. memoize.Cache = MapCache;
  27589. /**
  27590. * Creates a function that negates the result of the predicate `func`. The
  27591. * `func` predicate is invoked with the `this` binding and arguments of the
  27592. * created function.
  27593. *
  27594. * @static
  27595. * @memberOf _
  27596. * @since 3.0.0
  27597. * @category Function
  27598. * @param {Function} predicate The predicate to negate.
  27599. * @returns {Function} Returns the new negated function.
  27600. * @example
  27601. *
  27602. * function isEven(n) {
  27603. * return n % 2 == 0;
  27604. * }
  27605. *
  27606. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  27607. * // => [1, 3, 5]
  27608. */
  27609. function negate(predicate) {
  27610. if (typeof predicate != 'function') {
  27611. throw new TypeError(FUNC_ERROR_TEXT);
  27612. }
  27613. return function() {
  27614. var args = arguments;
  27615. switch (args.length) {
  27616. case 0: return !predicate.call(this);
  27617. case 1: return !predicate.call(this, args[0]);
  27618. case 2: return !predicate.call(this, args[0], args[1]);
  27619. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  27620. }
  27621. return !predicate.apply(this, args);
  27622. };
  27623. }
  27624. /**
  27625. * Creates a function that is restricted to invoking `func` once. Repeat calls
  27626. * to the function return the value of the first invocation. The `func` is
  27627. * invoked with the `this` binding and arguments of the created function.
  27628. *
  27629. * @static
  27630. * @memberOf _
  27631. * @since 0.1.0
  27632. * @category Function
  27633. * @param {Function} func The function to restrict.
  27634. * @returns {Function} Returns the new restricted function.
  27635. * @example
  27636. *
  27637. * var initialize = _.once(createApplication);
  27638. * initialize();
  27639. * initialize();
  27640. * // => `createApplication` is invoked once
  27641. */
  27642. function once(func) {
  27643. return before(2, func);
  27644. }
  27645. /**
  27646. * Creates a function that invokes `func` with its arguments transformed.
  27647. *
  27648. * @static
  27649. * @since 4.0.0
  27650. * @memberOf _
  27651. * @category Function
  27652. * @param {Function} func The function to wrap.
  27653. * @param {...(Function|Function[])} [transforms=[_.identity]]
  27654. * The argument transforms.
  27655. * @returns {Function} Returns the new function.
  27656. * @example
  27657. *
  27658. * function doubled(n) {
  27659. * return n * 2;
  27660. * }
  27661. *
  27662. * function square(n) {
  27663. * return n * n;
  27664. * }
  27665. *
  27666. * var func = _.overArgs(function(x, y) {
  27667. * return [x, y];
  27668. * }, [square, doubled]);
  27669. *
  27670. * func(9, 3);
  27671. * // => [81, 6]
  27672. *
  27673. * func(10, 5);
  27674. * // => [100, 10]
  27675. */
  27676. var overArgs = castRest(function(func, transforms) {
  27677. transforms = (transforms.length == 1 && isArray(transforms[0]))
  27678. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  27679. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  27680. var funcsLength = transforms.length;
  27681. return baseRest(function(args) {
  27682. var index = -1,
  27683. length = nativeMin(args.length, funcsLength);
  27684. while (++index < length) {
  27685. args[index] = transforms[index].call(this, args[index]);
  27686. }
  27687. return apply(func, this, args);
  27688. });
  27689. });
  27690. /**
  27691. * Creates a function that invokes `func` with `partials` prepended to the
  27692. * arguments it receives. This method is like `_.bind` except it does **not**
  27693. * alter the `this` binding.
  27694. *
  27695. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  27696. * builds, may be used as a placeholder for partially applied arguments.
  27697. *
  27698. * **Note:** This method doesn't set the "length" property of partially
  27699. * applied functions.
  27700. *
  27701. * @static
  27702. * @memberOf _
  27703. * @since 0.2.0
  27704. * @category Function
  27705. * @param {Function} func The function to partially apply arguments to.
  27706. * @param {...*} [partials] The arguments to be partially applied.
  27707. * @returns {Function} Returns the new partially applied function.
  27708. * @example
  27709. *
  27710. * function greet(greeting, name) {
  27711. * return greeting + ' ' + name;
  27712. * }
  27713. *
  27714. * var sayHelloTo = _.partial(greet, 'hello');
  27715. * sayHelloTo('fred');
  27716. * // => 'hello fred'
  27717. *
  27718. * // Partially applied with placeholders.
  27719. * var greetFred = _.partial(greet, _, 'fred');
  27720. * greetFred('hi');
  27721. * // => 'hi fred'
  27722. */
  27723. var partial = baseRest(function(func, partials) {
  27724. var holders = replaceHolders(partials, getHolder(partial));
  27725. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  27726. });
  27727. /**
  27728. * This method is like `_.partial` except that partially applied arguments
  27729. * are appended to the arguments it receives.
  27730. *
  27731. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  27732. * builds, may be used as a placeholder for partially applied arguments.
  27733. *
  27734. * **Note:** This method doesn't set the "length" property of partially
  27735. * applied functions.
  27736. *
  27737. * @static
  27738. * @memberOf _
  27739. * @since 1.0.0
  27740. * @category Function
  27741. * @param {Function} func The function to partially apply arguments to.
  27742. * @param {...*} [partials] The arguments to be partially applied.
  27743. * @returns {Function} Returns the new partially applied function.
  27744. * @example
  27745. *
  27746. * function greet(greeting, name) {
  27747. * return greeting + ' ' + name;
  27748. * }
  27749. *
  27750. * var greetFred = _.partialRight(greet, 'fred');
  27751. * greetFred('hi');
  27752. * // => 'hi fred'
  27753. *
  27754. * // Partially applied with placeholders.
  27755. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  27756. * sayHelloTo('fred');
  27757. * // => 'hello fred'
  27758. */
  27759. var partialRight = baseRest(function(func, partials) {
  27760. var holders = replaceHolders(partials, getHolder(partialRight));
  27761. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  27762. });
  27763. /**
  27764. * Creates a function that invokes `func` with arguments arranged according
  27765. * to the specified `indexes` where the argument value at the first index is
  27766. * provided as the first argument, the argument value at the second index is
  27767. * provided as the second argument, and so on.
  27768. *
  27769. * @static
  27770. * @memberOf _
  27771. * @since 3.0.0
  27772. * @category Function
  27773. * @param {Function} func The function to rearrange arguments for.
  27774. * @param {...(number|number[])} indexes The arranged argument indexes.
  27775. * @returns {Function} Returns the new function.
  27776. * @example
  27777. *
  27778. * var rearged = _.rearg(function(a, b, c) {
  27779. * return [a, b, c];
  27780. * }, [2, 0, 1]);
  27781. *
  27782. * rearged('b', 'c', 'a')
  27783. * // => ['a', 'b', 'c']
  27784. */
  27785. var rearg = flatRest(function(func, indexes) {
  27786. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  27787. });
  27788. /**
  27789. * Creates a function that invokes `func` with the `this` binding of the
  27790. * created function and arguments from `start` and beyond provided as
  27791. * an array.
  27792. *
  27793. * **Note:** This method is based on the
  27794. * [rest parameter](https://mdn.io/rest_parameters).
  27795. *
  27796. * @static
  27797. * @memberOf _
  27798. * @since 4.0.0
  27799. * @category Function
  27800. * @param {Function} func The function to apply a rest parameter to.
  27801. * @param {number} [start=func.length-1] The start position of the rest parameter.
  27802. * @returns {Function} Returns the new function.
  27803. * @example
  27804. *
  27805. * var say = _.rest(function(what, names) {
  27806. * return what + ' ' + _.initial(names).join(', ') +
  27807. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  27808. * });
  27809. *
  27810. * say('hello', 'fred', 'barney', 'pebbles');
  27811. * // => 'hello fred, barney, & pebbles'
  27812. */
  27813. function rest(func, start) {
  27814. if (typeof func != 'function') {
  27815. throw new TypeError(FUNC_ERROR_TEXT);
  27816. }
  27817. start = start === undefined ? start : toInteger(start);
  27818. return baseRest(func, start);
  27819. }
  27820. /**
  27821. * Creates a function that invokes `func` with the `this` binding of the
  27822. * create function and an array of arguments much like
  27823. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  27824. *
  27825. * **Note:** This method is based on the
  27826. * [spread operator](https://mdn.io/spread_operator).
  27827. *
  27828. * @static
  27829. * @memberOf _
  27830. * @since 3.2.0
  27831. * @category Function
  27832. * @param {Function} func The function to spread arguments over.
  27833. * @param {number} [start=0] The start position of the spread.
  27834. * @returns {Function} Returns the new function.
  27835. * @example
  27836. *
  27837. * var say = _.spread(function(who, what) {
  27838. * return who + ' says ' + what;
  27839. * });
  27840. *
  27841. * say(['fred', 'hello']);
  27842. * // => 'fred says hello'
  27843. *
  27844. * var numbers = Promise.all([
  27845. * Promise.resolve(40),
  27846. * Promise.resolve(36)
  27847. * ]);
  27848. *
  27849. * numbers.then(_.spread(function(x, y) {
  27850. * return x + y;
  27851. * }));
  27852. * // => a Promise of 76
  27853. */
  27854. function spread(func, start) {
  27855. if (typeof func != 'function') {
  27856. throw new TypeError(FUNC_ERROR_TEXT);
  27857. }
  27858. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  27859. return baseRest(function(args) {
  27860. var array = args[start],
  27861. otherArgs = castSlice(args, 0, start);
  27862. if (array) {
  27863. arrayPush(otherArgs, array);
  27864. }
  27865. return apply(func, this, otherArgs);
  27866. });
  27867. }
  27868. /**
  27869. * Creates a throttled function that only invokes `func` at most once per
  27870. * every `wait` milliseconds. The throttled function comes with a `cancel`
  27871. * method to cancel delayed `func` invocations and a `flush` method to
  27872. * immediately invoke them. Provide `options` to indicate whether `func`
  27873. * should be invoked on the leading and/or trailing edge of the `wait`
  27874. * timeout. The `func` is invoked with the last arguments provided to the
  27875. * throttled function. Subsequent calls to the throttled function return the
  27876. * result of the last `func` invocation.
  27877. *
  27878. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27879. * invoked on the trailing edge of the timeout only if the throttled function
  27880. * is invoked more than once during the `wait` timeout.
  27881. *
  27882. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27883. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27884. *
  27885. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27886. * for details over the differences between `_.throttle` and `_.debounce`.
  27887. *
  27888. * @static
  27889. * @memberOf _
  27890. * @since 0.1.0
  27891. * @category Function
  27892. * @param {Function} func The function to throttle.
  27893. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  27894. * @param {Object} [options={}] The options object.
  27895. * @param {boolean} [options.leading=true]
  27896. * Specify invoking on the leading edge of the timeout.
  27897. * @param {boolean} [options.trailing=true]
  27898. * Specify invoking on the trailing edge of the timeout.
  27899. * @returns {Function} Returns the new throttled function.
  27900. * @example
  27901. *
  27902. * // Avoid excessively updating the position while scrolling.
  27903. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  27904. *
  27905. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  27906. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  27907. * jQuery(element).on('click', throttled);
  27908. *
  27909. * // Cancel the trailing throttled invocation.
  27910. * jQuery(window).on('popstate', throttled.cancel);
  27911. */
  27912. function throttle(func, wait, options) {
  27913. var leading = true,
  27914. trailing = true;
  27915. if (typeof func != 'function') {
  27916. throw new TypeError(FUNC_ERROR_TEXT);
  27917. }
  27918. if (isObject(options)) {
  27919. leading = 'leading' in options ? !!options.leading : leading;
  27920. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27921. }
  27922. return debounce(func, wait, {
  27923. 'leading': leading,
  27924. 'maxWait': wait,
  27925. 'trailing': trailing
  27926. });
  27927. }
  27928. /**
  27929. * Creates a function that accepts up to one argument, ignoring any
  27930. * additional arguments.
  27931. *
  27932. * @static
  27933. * @memberOf _
  27934. * @since 4.0.0
  27935. * @category Function
  27936. * @param {Function} func The function to cap arguments for.
  27937. * @returns {Function} Returns the new capped function.
  27938. * @example
  27939. *
  27940. * _.map(['6', '8', '10'], _.unary(parseInt));
  27941. * // => [6, 8, 10]
  27942. */
  27943. function unary(func) {
  27944. return ary(func, 1);
  27945. }
  27946. /**
  27947. * Creates a function that provides `value` to `wrapper` as its first
  27948. * argument. Any additional arguments provided to the function are appended
  27949. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  27950. * binding of the created function.
  27951. *
  27952. * @static
  27953. * @memberOf _
  27954. * @since 0.1.0
  27955. * @category Function
  27956. * @param {*} value The value to wrap.
  27957. * @param {Function} [wrapper=identity] The wrapper function.
  27958. * @returns {Function} Returns the new function.
  27959. * @example
  27960. *
  27961. * var p = _.wrap(_.escape, function(func, text) {
  27962. * return '<p>' + func(text) + '</p>';
  27963. * });
  27964. *
  27965. * p('fred, barney, & pebbles');
  27966. * // => '<p>fred, barney, &amp; pebbles</p>'
  27967. */
  27968. function wrap(value, wrapper) {
  27969. return partial(castFunction(wrapper), value);
  27970. }
  27971. /*------------------------------------------------------------------------*/
  27972. /**
  27973. * Casts `value` as an array if it's not one.
  27974. *
  27975. * @static
  27976. * @memberOf _
  27977. * @since 4.4.0
  27978. * @category Lang
  27979. * @param {*} value The value to inspect.
  27980. * @returns {Array} Returns the cast array.
  27981. * @example
  27982. *
  27983. * _.castArray(1);
  27984. * // => [1]
  27985. *
  27986. * _.castArray({ 'a': 1 });
  27987. * // => [{ 'a': 1 }]
  27988. *
  27989. * _.castArray('abc');
  27990. * // => ['abc']
  27991. *
  27992. * _.castArray(null);
  27993. * // => [null]
  27994. *
  27995. * _.castArray(undefined);
  27996. * // => [undefined]
  27997. *
  27998. * _.castArray();
  27999. * // => []
  28000. *
  28001. * var array = [1, 2, 3];
  28002. * console.log(_.castArray(array) === array);
  28003. * // => true
  28004. */
  28005. function castArray() {
  28006. if (!arguments.length) {
  28007. return [];
  28008. }
  28009. var value = arguments[0];
  28010. return isArray(value) ? value : [value];
  28011. }
  28012. /**
  28013. * Creates a shallow clone of `value`.
  28014. *
  28015. * **Note:** This method is loosely based on the
  28016. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  28017. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  28018. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  28019. * arrays. The own enumerable properties of `arguments` objects are cloned
  28020. * as plain objects. An empty object is returned for uncloneable values such
  28021. * as error objects, functions, DOM nodes, and WeakMaps.
  28022. *
  28023. * @static
  28024. * @memberOf _
  28025. * @since 0.1.0
  28026. * @category Lang
  28027. * @param {*} value The value to clone.
  28028. * @returns {*} Returns the cloned value.
  28029. * @see _.cloneDeep
  28030. * @example
  28031. *
  28032. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28033. *
  28034. * var shallow = _.clone(objects);
  28035. * console.log(shallow[0] === objects[0]);
  28036. * // => true
  28037. */
  28038. function clone(value) {
  28039. return baseClone(value, CLONE_SYMBOLS_FLAG);
  28040. }
  28041. /**
  28042. * This method is like `_.clone` except that it accepts `customizer` which
  28043. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  28044. * cloning is handled by the method instead. The `customizer` is invoked with
  28045. * up to four arguments; (value [, index|key, object, stack]).
  28046. *
  28047. * @static
  28048. * @memberOf _
  28049. * @since 4.0.0
  28050. * @category Lang
  28051. * @param {*} value The value to clone.
  28052. * @param {Function} [customizer] The function to customize cloning.
  28053. * @returns {*} Returns the cloned value.
  28054. * @see _.cloneDeepWith
  28055. * @example
  28056. *
  28057. * function customizer(value) {
  28058. * if (_.isElement(value)) {
  28059. * return value.cloneNode(false);
  28060. * }
  28061. * }
  28062. *
  28063. * var el = _.cloneWith(document.body, customizer);
  28064. *
  28065. * console.log(el === document.body);
  28066. * // => false
  28067. * console.log(el.nodeName);
  28068. * // => 'BODY'
  28069. * console.log(el.childNodes.length);
  28070. * // => 0
  28071. */
  28072. function cloneWith(value, customizer) {
  28073. customizer = typeof customizer == 'function' ? customizer : undefined;
  28074. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  28075. }
  28076. /**
  28077. * This method is like `_.clone` except that it recursively clones `value`.
  28078. *
  28079. * @static
  28080. * @memberOf _
  28081. * @since 1.0.0
  28082. * @category Lang
  28083. * @param {*} value The value to recursively clone.
  28084. * @returns {*} Returns the deep cloned value.
  28085. * @see _.clone
  28086. * @example
  28087. *
  28088. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28089. *
  28090. * var deep = _.cloneDeep(objects);
  28091. * console.log(deep[0] === objects[0]);
  28092. * // => false
  28093. */
  28094. function cloneDeep(value) {
  28095. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  28096. }
  28097. /**
  28098. * This method is like `_.cloneWith` except that it recursively clones `value`.
  28099. *
  28100. * @static
  28101. * @memberOf _
  28102. * @since 4.0.0
  28103. * @category Lang
  28104. * @param {*} value The value to recursively clone.
  28105. * @param {Function} [customizer] The function to customize cloning.
  28106. * @returns {*} Returns the deep cloned value.
  28107. * @see _.cloneWith
  28108. * @example
  28109. *
  28110. * function customizer(value) {
  28111. * if (_.isElement(value)) {
  28112. * return value.cloneNode(true);
  28113. * }
  28114. * }
  28115. *
  28116. * var el = _.cloneDeepWith(document.body, customizer);
  28117. *
  28118. * console.log(el === document.body);
  28119. * // => false
  28120. * console.log(el.nodeName);
  28121. * // => 'BODY'
  28122. * console.log(el.childNodes.length);
  28123. * // => 20
  28124. */
  28125. function cloneDeepWith(value, customizer) {
  28126. customizer = typeof customizer == 'function' ? customizer : undefined;
  28127. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  28128. }
  28129. /**
  28130. * Checks if `object` conforms to `source` by invoking the predicate
  28131. * properties of `source` with the corresponding property values of `object`.
  28132. *
  28133. * **Note:** This method is equivalent to `_.conforms` when `source` is
  28134. * partially applied.
  28135. *
  28136. * @static
  28137. * @memberOf _
  28138. * @since 4.14.0
  28139. * @category Lang
  28140. * @param {Object} object The object to inspect.
  28141. * @param {Object} source The object of property predicates to conform to.
  28142. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  28143. * @example
  28144. *
  28145. * var object = { 'a': 1, 'b': 2 };
  28146. *
  28147. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  28148. * // => true
  28149. *
  28150. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  28151. * // => false
  28152. */
  28153. function conformsTo(object, source) {
  28154. return source == null || baseConformsTo(object, source, keys(source));
  28155. }
  28156. /**
  28157. * Performs a
  28158. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  28159. * comparison between two values to determine if they are equivalent.
  28160. *
  28161. * @static
  28162. * @memberOf _
  28163. * @since 4.0.0
  28164. * @category Lang
  28165. * @param {*} value The value to compare.
  28166. * @param {*} other The other value to compare.
  28167. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28168. * @example
  28169. *
  28170. * var object = { 'a': 1 };
  28171. * var other = { 'a': 1 };
  28172. *
  28173. * _.eq(object, object);
  28174. * // => true
  28175. *
  28176. * _.eq(object, other);
  28177. * // => false
  28178. *
  28179. * _.eq('a', 'a');
  28180. * // => true
  28181. *
  28182. * _.eq('a', Object('a'));
  28183. * // => false
  28184. *
  28185. * _.eq(NaN, NaN);
  28186. * // => true
  28187. */
  28188. function eq(value, other) {
  28189. return value === other || (value !== value && other !== other);
  28190. }
  28191. /**
  28192. * Checks if `value` is greater than `other`.
  28193. *
  28194. * @static
  28195. * @memberOf _
  28196. * @since 3.9.0
  28197. * @category Lang
  28198. * @param {*} value The value to compare.
  28199. * @param {*} other The other value to compare.
  28200. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  28201. * else `false`.
  28202. * @see _.lt
  28203. * @example
  28204. *
  28205. * _.gt(3, 1);
  28206. * // => true
  28207. *
  28208. * _.gt(3, 3);
  28209. * // => false
  28210. *
  28211. * _.gt(1, 3);
  28212. * // => false
  28213. */
  28214. var gt = createRelationalOperation(baseGt);
  28215. /**
  28216. * Checks if `value` is greater than or equal to `other`.
  28217. *
  28218. * @static
  28219. * @memberOf _
  28220. * @since 3.9.0
  28221. * @category Lang
  28222. * @param {*} value The value to compare.
  28223. * @param {*} other The other value to compare.
  28224. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  28225. * `other`, else `false`.
  28226. * @see _.lte
  28227. * @example
  28228. *
  28229. * _.gte(3, 1);
  28230. * // => true
  28231. *
  28232. * _.gte(3, 3);
  28233. * // => true
  28234. *
  28235. * _.gte(1, 3);
  28236. * // => false
  28237. */
  28238. var gte = createRelationalOperation(function(value, other) {
  28239. return value >= other;
  28240. });
  28241. /**
  28242. * Checks if `value` is likely an `arguments` object.
  28243. *
  28244. * @static
  28245. * @memberOf _
  28246. * @since 0.1.0
  28247. * @category Lang
  28248. * @param {*} value The value to check.
  28249. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  28250. * else `false`.
  28251. * @example
  28252. *
  28253. * _.isArguments(function() { return arguments; }());
  28254. * // => true
  28255. *
  28256. * _.isArguments([1, 2, 3]);
  28257. * // => false
  28258. */
  28259. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  28260. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  28261. !propertyIsEnumerable.call(value, 'callee');
  28262. };
  28263. /**
  28264. * Checks if `value` is classified as an `Array` object.
  28265. *
  28266. * @static
  28267. * @memberOf _
  28268. * @since 0.1.0
  28269. * @category Lang
  28270. * @param {*} value The value to check.
  28271. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  28272. * @example
  28273. *
  28274. * _.isArray([1, 2, 3]);
  28275. * // => true
  28276. *
  28277. * _.isArray(document.body.children);
  28278. * // => false
  28279. *
  28280. * _.isArray('abc');
  28281. * // => false
  28282. *
  28283. * _.isArray(_.noop);
  28284. * // => false
  28285. */
  28286. var isArray = Array.isArray;
  28287. /**
  28288. * Checks if `value` is classified as an `ArrayBuffer` object.
  28289. *
  28290. * @static
  28291. * @memberOf _
  28292. * @since 4.3.0
  28293. * @category Lang
  28294. * @param {*} value The value to check.
  28295. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  28296. * @example
  28297. *
  28298. * _.isArrayBuffer(new ArrayBuffer(2));
  28299. * // => true
  28300. *
  28301. * _.isArrayBuffer(new Array(2));
  28302. * // => false
  28303. */
  28304. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  28305. /**
  28306. * Checks if `value` is array-like. A value is considered array-like if it's
  28307. * not a function and has a `value.length` that's an integer greater than or
  28308. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  28309. *
  28310. * @static
  28311. * @memberOf _
  28312. * @since 4.0.0
  28313. * @category Lang
  28314. * @param {*} value The value to check.
  28315. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  28316. * @example
  28317. *
  28318. * _.isArrayLike([1, 2, 3]);
  28319. * // => true
  28320. *
  28321. * _.isArrayLike(document.body.children);
  28322. * // => true
  28323. *
  28324. * _.isArrayLike('abc');
  28325. * // => true
  28326. *
  28327. * _.isArrayLike(_.noop);
  28328. * // => false
  28329. */
  28330. function isArrayLike(value) {
  28331. return value != null && isLength(value.length) && !isFunction(value);
  28332. }
  28333. /**
  28334. * This method is like `_.isArrayLike` except that it also checks if `value`
  28335. * is an object.
  28336. *
  28337. * @static
  28338. * @memberOf _
  28339. * @since 4.0.0
  28340. * @category Lang
  28341. * @param {*} value The value to check.
  28342. * @returns {boolean} Returns `true` if `value` is an array-like object,
  28343. * else `false`.
  28344. * @example
  28345. *
  28346. * _.isArrayLikeObject([1, 2, 3]);
  28347. * // => true
  28348. *
  28349. * _.isArrayLikeObject(document.body.children);
  28350. * // => true
  28351. *
  28352. * _.isArrayLikeObject('abc');
  28353. * // => false
  28354. *
  28355. * _.isArrayLikeObject(_.noop);
  28356. * // => false
  28357. */
  28358. function isArrayLikeObject(value) {
  28359. return isObjectLike(value) && isArrayLike(value);
  28360. }
  28361. /**
  28362. * Checks if `value` is classified as a boolean primitive or object.
  28363. *
  28364. * @static
  28365. * @memberOf _
  28366. * @since 0.1.0
  28367. * @category Lang
  28368. * @param {*} value The value to check.
  28369. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  28370. * @example
  28371. *
  28372. * _.isBoolean(false);
  28373. * // => true
  28374. *
  28375. * _.isBoolean(null);
  28376. * // => false
  28377. */
  28378. function isBoolean(value) {
  28379. return value === true || value === false ||
  28380. (isObjectLike(value) && baseGetTag(value) == boolTag);
  28381. }
  28382. /**
  28383. * Checks if `value` is a buffer.
  28384. *
  28385. * @static
  28386. * @memberOf _
  28387. * @since 4.3.0
  28388. * @category Lang
  28389. * @param {*} value The value to check.
  28390. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  28391. * @example
  28392. *
  28393. * _.isBuffer(new Buffer(2));
  28394. * // => true
  28395. *
  28396. * _.isBuffer(new Uint8Array(2));
  28397. * // => false
  28398. */
  28399. var isBuffer = nativeIsBuffer || stubFalse;
  28400. /**
  28401. * Checks if `value` is classified as a `Date` object.
  28402. *
  28403. * @static
  28404. * @memberOf _
  28405. * @since 0.1.0
  28406. * @category Lang
  28407. * @param {*} value The value to check.
  28408. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  28409. * @example
  28410. *
  28411. * _.isDate(new Date);
  28412. * // => true
  28413. *
  28414. * _.isDate('Mon April 23 2012');
  28415. * // => false
  28416. */
  28417. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  28418. /**
  28419. * Checks if `value` is likely a DOM element.
  28420. *
  28421. * @static
  28422. * @memberOf _
  28423. * @since 0.1.0
  28424. * @category Lang
  28425. * @param {*} value The value to check.
  28426. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  28427. * @example
  28428. *
  28429. * _.isElement(document.body);
  28430. * // => true
  28431. *
  28432. * _.isElement('<body>');
  28433. * // => false
  28434. */
  28435. function isElement(value) {
  28436. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  28437. }
  28438. /**
  28439. * Checks if `value` is an empty object, collection, map, or set.
  28440. *
  28441. * Objects are considered empty if they have no own enumerable string keyed
  28442. * properties.
  28443. *
  28444. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  28445. * jQuery-like collections are considered empty if they have a `length` of `0`.
  28446. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  28447. *
  28448. * @static
  28449. * @memberOf _
  28450. * @since 0.1.0
  28451. * @category Lang
  28452. * @param {*} value The value to check.
  28453. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  28454. * @example
  28455. *
  28456. * _.isEmpty(null);
  28457. * // => true
  28458. *
  28459. * _.isEmpty(true);
  28460. * // => true
  28461. *
  28462. * _.isEmpty(1);
  28463. * // => true
  28464. *
  28465. * _.isEmpty([1, 2, 3]);
  28466. * // => false
  28467. *
  28468. * _.isEmpty({ 'a': 1 });
  28469. * // => false
  28470. */
  28471. function isEmpty(value) {
  28472. if (value == null) {
  28473. return true;
  28474. }
  28475. if (isArrayLike(value) &&
  28476. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  28477. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  28478. return !value.length;
  28479. }
  28480. var tag = getTag(value);
  28481. if (tag == mapTag || tag == setTag) {
  28482. return !value.size;
  28483. }
  28484. if (isPrototype(value)) {
  28485. return !baseKeys(value).length;
  28486. }
  28487. for (var key in value) {
  28488. if (hasOwnProperty.call(value, key)) {
  28489. return false;
  28490. }
  28491. }
  28492. return true;
  28493. }
  28494. /**
  28495. * Performs a deep comparison between two values to determine if they are
  28496. * equivalent.
  28497. *
  28498. * **Note:** This method supports comparing arrays, array buffers, booleans,
  28499. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  28500. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  28501. * by their own, not inherited, enumerable properties. Functions and DOM
  28502. * nodes are compared by strict equality, i.e. `===`.
  28503. *
  28504. * @static
  28505. * @memberOf _
  28506. * @since 0.1.0
  28507. * @category Lang
  28508. * @param {*} value The value to compare.
  28509. * @param {*} other The other value to compare.
  28510. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28511. * @example
  28512. *
  28513. * var object = { 'a': 1 };
  28514. * var other = { 'a': 1 };
  28515. *
  28516. * _.isEqual(object, other);
  28517. * // => true
  28518. *
  28519. * object === other;
  28520. * // => false
  28521. */
  28522. function isEqual(value, other) {
  28523. return baseIsEqual(value, other);
  28524. }
  28525. /**
  28526. * This method is like `_.isEqual` except that it accepts `customizer` which
  28527. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28528. * are handled by the method instead. The `customizer` is invoked with up to
  28529. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  28530. *
  28531. * @static
  28532. * @memberOf _
  28533. * @since 4.0.0
  28534. * @category Lang
  28535. * @param {*} value The value to compare.
  28536. * @param {*} other The other value to compare.
  28537. * @param {Function} [customizer] The function to customize comparisons.
  28538. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28539. * @example
  28540. *
  28541. * function isGreeting(value) {
  28542. * return /^h(?:i|ello)$/.test(value);
  28543. * }
  28544. *
  28545. * function customizer(objValue, othValue) {
  28546. * if (isGreeting(objValue) && isGreeting(othValue)) {
  28547. * return true;
  28548. * }
  28549. * }
  28550. *
  28551. * var array = ['hello', 'goodbye'];
  28552. * var other = ['hi', 'goodbye'];
  28553. *
  28554. * _.isEqualWith(array, other, customizer);
  28555. * // => true
  28556. */
  28557. function isEqualWith(value, other, customizer) {
  28558. customizer = typeof customizer == 'function' ? customizer : undefined;
  28559. var result = customizer ? customizer(value, other) : undefined;
  28560. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  28561. }
  28562. /**
  28563. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  28564. * `SyntaxError`, `TypeError`, or `URIError` object.
  28565. *
  28566. * @static
  28567. * @memberOf _
  28568. * @since 3.0.0
  28569. * @category Lang
  28570. * @param {*} value The value to check.
  28571. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  28572. * @example
  28573. *
  28574. * _.isError(new Error);
  28575. * // => true
  28576. *
  28577. * _.isError(Error);
  28578. * // => false
  28579. */
  28580. function isError(value) {
  28581. if (!isObjectLike(value)) {
  28582. return false;
  28583. }
  28584. var tag = baseGetTag(value);
  28585. return tag == errorTag || tag == domExcTag ||
  28586. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  28587. }
  28588. /**
  28589. * Checks if `value` is a finite primitive number.
  28590. *
  28591. * **Note:** This method is based on
  28592. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  28593. *
  28594. * @static
  28595. * @memberOf _
  28596. * @since 0.1.0
  28597. * @category Lang
  28598. * @param {*} value The value to check.
  28599. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  28600. * @example
  28601. *
  28602. * _.isFinite(3);
  28603. * // => true
  28604. *
  28605. * _.isFinite(Number.MIN_VALUE);
  28606. * // => true
  28607. *
  28608. * _.isFinite(Infinity);
  28609. * // => false
  28610. *
  28611. * _.isFinite('3');
  28612. * // => false
  28613. */
  28614. function isFinite(value) {
  28615. return typeof value == 'number' && nativeIsFinite(value);
  28616. }
  28617. /**
  28618. * Checks if `value` is classified as a `Function` object.
  28619. *
  28620. * @static
  28621. * @memberOf _
  28622. * @since 0.1.0
  28623. * @category Lang
  28624. * @param {*} value The value to check.
  28625. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  28626. * @example
  28627. *
  28628. * _.isFunction(_);
  28629. * // => true
  28630. *
  28631. * _.isFunction(/abc/);
  28632. * // => false
  28633. */
  28634. function isFunction(value) {
  28635. if (!isObject(value)) {
  28636. return false;
  28637. }
  28638. // The use of `Object#toString` avoids issues with the `typeof` operator
  28639. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  28640. var tag = baseGetTag(value);
  28641. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  28642. }
  28643. /**
  28644. * Checks if `value` is an integer.
  28645. *
  28646. * **Note:** This method is based on
  28647. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  28648. *
  28649. * @static
  28650. * @memberOf _
  28651. * @since 4.0.0
  28652. * @category Lang
  28653. * @param {*} value The value to check.
  28654. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  28655. * @example
  28656. *
  28657. * _.isInteger(3);
  28658. * // => true
  28659. *
  28660. * _.isInteger(Number.MIN_VALUE);
  28661. * // => false
  28662. *
  28663. * _.isInteger(Infinity);
  28664. * // => false
  28665. *
  28666. * _.isInteger('3');
  28667. * // => false
  28668. */
  28669. function isInteger(value) {
  28670. return typeof value == 'number' && value == toInteger(value);
  28671. }
  28672. /**
  28673. * Checks if `value` is a valid array-like length.
  28674. *
  28675. * **Note:** This method is loosely based on
  28676. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28677. *
  28678. * @static
  28679. * @memberOf _
  28680. * @since 4.0.0
  28681. * @category Lang
  28682. * @param {*} value The value to check.
  28683. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  28684. * @example
  28685. *
  28686. * _.isLength(3);
  28687. * // => true
  28688. *
  28689. * _.isLength(Number.MIN_VALUE);
  28690. * // => false
  28691. *
  28692. * _.isLength(Infinity);
  28693. * // => false
  28694. *
  28695. * _.isLength('3');
  28696. * // => false
  28697. */
  28698. function isLength(value) {
  28699. return typeof value == 'number' &&
  28700. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  28701. }
  28702. /**
  28703. * Checks if `value` is the
  28704. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  28705. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  28706. *
  28707. * @static
  28708. * @memberOf _
  28709. * @since 0.1.0
  28710. * @category Lang
  28711. * @param {*} value The value to check.
  28712. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  28713. * @example
  28714. *
  28715. * _.isObject({});
  28716. * // => true
  28717. *
  28718. * _.isObject([1, 2, 3]);
  28719. * // => true
  28720. *
  28721. * _.isObject(_.noop);
  28722. * // => true
  28723. *
  28724. * _.isObject(null);
  28725. * // => false
  28726. */
  28727. function isObject(value) {
  28728. var type = typeof value;
  28729. return value != null && (type == 'object' || type == 'function');
  28730. }
  28731. /**
  28732. * Checks if `value` is object-like. A value is object-like if it's not `null`
  28733. * and has a `typeof` result of "object".
  28734. *
  28735. * @static
  28736. * @memberOf _
  28737. * @since 4.0.0
  28738. * @category Lang
  28739. * @param {*} value The value to check.
  28740. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  28741. * @example
  28742. *
  28743. * _.isObjectLike({});
  28744. * // => true
  28745. *
  28746. * _.isObjectLike([1, 2, 3]);
  28747. * // => true
  28748. *
  28749. * _.isObjectLike(_.noop);
  28750. * // => false
  28751. *
  28752. * _.isObjectLike(null);
  28753. * // => false
  28754. */
  28755. function isObjectLike(value) {
  28756. return value != null && typeof value == 'object';
  28757. }
  28758. /**
  28759. * Checks if `value` is classified as a `Map` object.
  28760. *
  28761. * @static
  28762. * @memberOf _
  28763. * @since 4.3.0
  28764. * @category Lang
  28765. * @param {*} value The value to check.
  28766. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  28767. * @example
  28768. *
  28769. * _.isMap(new Map);
  28770. * // => true
  28771. *
  28772. * _.isMap(new WeakMap);
  28773. * // => false
  28774. */
  28775. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  28776. /**
  28777. * Performs a partial deep comparison between `object` and `source` to
  28778. * determine if `object` contains equivalent property values.
  28779. *
  28780. * **Note:** This method is equivalent to `_.matches` when `source` is
  28781. * partially applied.
  28782. *
  28783. * Partial comparisons will match empty array and empty object `source`
  28784. * values against any array or object value, respectively. See `_.isEqual`
  28785. * for a list of supported value comparisons.
  28786. *
  28787. * @static
  28788. * @memberOf _
  28789. * @since 3.0.0
  28790. * @category Lang
  28791. * @param {Object} object The object to inspect.
  28792. * @param {Object} source The object of property values to match.
  28793. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28794. * @example
  28795. *
  28796. * var object = { 'a': 1, 'b': 2 };
  28797. *
  28798. * _.isMatch(object, { 'b': 2 });
  28799. * // => true
  28800. *
  28801. * _.isMatch(object, { 'b': 1 });
  28802. * // => false
  28803. */
  28804. function isMatch(object, source) {
  28805. return object === source || baseIsMatch(object, source, getMatchData(source));
  28806. }
  28807. /**
  28808. * This method is like `_.isMatch` except that it accepts `customizer` which
  28809. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28810. * are handled by the method instead. The `customizer` is invoked with five
  28811. * arguments: (objValue, srcValue, index|key, object, source).
  28812. *
  28813. * @static
  28814. * @memberOf _
  28815. * @since 4.0.0
  28816. * @category Lang
  28817. * @param {Object} object The object to inspect.
  28818. * @param {Object} source The object of property values to match.
  28819. * @param {Function} [customizer] The function to customize comparisons.
  28820. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28821. * @example
  28822. *
  28823. * function isGreeting(value) {
  28824. * return /^h(?:i|ello)$/.test(value);
  28825. * }
  28826. *
  28827. * function customizer(objValue, srcValue) {
  28828. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  28829. * return true;
  28830. * }
  28831. * }
  28832. *
  28833. * var object = { 'greeting': 'hello' };
  28834. * var source = { 'greeting': 'hi' };
  28835. *
  28836. * _.isMatchWith(object, source, customizer);
  28837. * // => true
  28838. */
  28839. function isMatchWith(object, source, customizer) {
  28840. customizer = typeof customizer == 'function' ? customizer : undefined;
  28841. return baseIsMatch(object, source, getMatchData(source), customizer);
  28842. }
  28843. /**
  28844. * Checks if `value` is `NaN`.
  28845. *
  28846. * **Note:** This method is based on
  28847. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  28848. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  28849. * `undefined` and other non-number values.
  28850. *
  28851. * @static
  28852. * @memberOf _
  28853. * @since 0.1.0
  28854. * @category Lang
  28855. * @param {*} value The value to check.
  28856. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  28857. * @example
  28858. *
  28859. * _.isNaN(NaN);
  28860. * // => true
  28861. *
  28862. * _.isNaN(new Number(NaN));
  28863. * // => true
  28864. *
  28865. * isNaN(undefined);
  28866. * // => true
  28867. *
  28868. * _.isNaN(undefined);
  28869. * // => false
  28870. */
  28871. function isNaN(value) {
  28872. // An `NaN` primitive is the only value that is not equal to itself.
  28873. // Perform the `toStringTag` check first to avoid errors with some
  28874. // ActiveX objects in IE.
  28875. return isNumber(value) && value != +value;
  28876. }
  28877. /**
  28878. * Checks if `value` is a pristine native function.
  28879. *
  28880. * **Note:** This method can't reliably detect native functions in the presence
  28881. * of the core-js package because core-js circumvents this kind of detection.
  28882. * Despite multiple requests, the core-js maintainer has made it clear: any
  28883. * attempt to fix the detection will be obstructed. As a result, we're left
  28884. * with little choice but to throw an error. Unfortunately, this also affects
  28885. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  28886. * which rely on core-js.
  28887. *
  28888. * @static
  28889. * @memberOf _
  28890. * @since 3.0.0
  28891. * @category Lang
  28892. * @param {*} value The value to check.
  28893. * @returns {boolean} Returns `true` if `value` is a native function,
  28894. * else `false`.
  28895. * @example
  28896. *
  28897. * _.isNative(Array.prototype.push);
  28898. * // => true
  28899. *
  28900. * _.isNative(_);
  28901. * // => false
  28902. */
  28903. function isNative(value) {
  28904. if (isMaskable(value)) {
  28905. throw new Error(CORE_ERROR_TEXT);
  28906. }
  28907. return baseIsNative(value);
  28908. }
  28909. /**
  28910. * Checks if `value` is `null`.
  28911. *
  28912. * @static
  28913. * @memberOf _
  28914. * @since 0.1.0
  28915. * @category Lang
  28916. * @param {*} value The value to check.
  28917. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  28918. * @example
  28919. *
  28920. * _.isNull(null);
  28921. * // => true
  28922. *
  28923. * _.isNull(void 0);
  28924. * // => false
  28925. */
  28926. function isNull(value) {
  28927. return value === null;
  28928. }
  28929. /**
  28930. * Checks if `value` is `null` or `undefined`.
  28931. *
  28932. * @static
  28933. * @memberOf _
  28934. * @since 4.0.0
  28935. * @category Lang
  28936. * @param {*} value The value to check.
  28937. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  28938. * @example
  28939. *
  28940. * _.isNil(null);
  28941. * // => true
  28942. *
  28943. * _.isNil(void 0);
  28944. * // => true
  28945. *
  28946. * _.isNil(NaN);
  28947. * // => false
  28948. */
  28949. function isNil(value) {
  28950. return value == null;
  28951. }
  28952. /**
  28953. * Checks if `value` is classified as a `Number` primitive or object.
  28954. *
  28955. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  28956. * classified as numbers, use the `_.isFinite` method.
  28957. *
  28958. * @static
  28959. * @memberOf _
  28960. * @since 0.1.0
  28961. * @category Lang
  28962. * @param {*} value The value to check.
  28963. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  28964. * @example
  28965. *
  28966. * _.isNumber(3);
  28967. * // => true
  28968. *
  28969. * _.isNumber(Number.MIN_VALUE);
  28970. * // => true
  28971. *
  28972. * _.isNumber(Infinity);
  28973. * // => true
  28974. *
  28975. * _.isNumber('3');
  28976. * // => false
  28977. */
  28978. function isNumber(value) {
  28979. return typeof value == 'number' ||
  28980. (isObjectLike(value) && baseGetTag(value) == numberTag);
  28981. }
  28982. /**
  28983. * Checks if `value` is a plain object, that is, an object created by the
  28984. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  28985. *
  28986. * @static
  28987. * @memberOf _
  28988. * @since 0.8.0
  28989. * @category Lang
  28990. * @param {*} value The value to check.
  28991. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  28992. * @example
  28993. *
  28994. * function Foo() {
  28995. * this.a = 1;
  28996. * }
  28997. *
  28998. * _.isPlainObject(new Foo);
  28999. * // => false
  29000. *
  29001. * _.isPlainObject([1, 2, 3]);
  29002. * // => false
  29003. *
  29004. * _.isPlainObject({ 'x': 0, 'y': 0 });
  29005. * // => true
  29006. *
  29007. * _.isPlainObject(Object.create(null));
  29008. * // => true
  29009. */
  29010. function isPlainObject(value) {
  29011. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  29012. return false;
  29013. }
  29014. var proto = getPrototype(value);
  29015. if (proto === null) {
  29016. return true;
  29017. }
  29018. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  29019. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  29020. funcToString.call(Ctor) == objectCtorString;
  29021. }
  29022. /**
  29023. * Checks if `value` is classified as a `RegExp` object.
  29024. *
  29025. * @static
  29026. * @memberOf _
  29027. * @since 0.1.0
  29028. * @category Lang
  29029. * @param {*} value The value to check.
  29030. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  29031. * @example
  29032. *
  29033. * _.isRegExp(/abc/);
  29034. * // => true
  29035. *
  29036. * _.isRegExp('/abc/');
  29037. * // => false
  29038. */
  29039. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  29040. /**
  29041. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  29042. * double precision number which isn't the result of a rounded unsafe integer.
  29043. *
  29044. * **Note:** This method is based on
  29045. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  29046. *
  29047. * @static
  29048. * @memberOf _
  29049. * @since 4.0.0
  29050. * @category Lang
  29051. * @param {*} value The value to check.
  29052. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  29053. * @example
  29054. *
  29055. * _.isSafeInteger(3);
  29056. * // => true
  29057. *
  29058. * _.isSafeInteger(Number.MIN_VALUE);
  29059. * // => false
  29060. *
  29061. * _.isSafeInteger(Infinity);
  29062. * // => false
  29063. *
  29064. * _.isSafeInteger('3');
  29065. * // => false
  29066. */
  29067. function isSafeInteger(value) {
  29068. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  29069. }
  29070. /**
  29071. * Checks if `value` is classified as a `Set` object.
  29072. *
  29073. * @static
  29074. * @memberOf _
  29075. * @since 4.3.0
  29076. * @category Lang
  29077. * @param {*} value The value to check.
  29078. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  29079. * @example
  29080. *
  29081. * _.isSet(new Set);
  29082. * // => true
  29083. *
  29084. * _.isSet(new WeakSet);
  29085. * // => false
  29086. */
  29087. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  29088. /**
  29089. * Checks if `value` is classified as a `String` primitive or object.
  29090. *
  29091. * @static
  29092. * @since 0.1.0
  29093. * @memberOf _
  29094. * @category Lang
  29095. * @param {*} value The value to check.
  29096. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  29097. * @example
  29098. *
  29099. * _.isString('abc');
  29100. * // => true
  29101. *
  29102. * _.isString(1);
  29103. * // => false
  29104. */
  29105. function isString(value) {
  29106. return typeof value == 'string' ||
  29107. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  29108. }
  29109. /**
  29110. * Checks if `value` is classified as a `Symbol` primitive or object.
  29111. *
  29112. * @static
  29113. * @memberOf _
  29114. * @since 4.0.0
  29115. * @category Lang
  29116. * @param {*} value The value to check.
  29117. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  29118. * @example
  29119. *
  29120. * _.isSymbol(Symbol.iterator);
  29121. * // => true
  29122. *
  29123. * _.isSymbol('abc');
  29124. * // => false
  29125. */
  29126. function isSymbol(value) {
  29127. return typeof value == 'symbol' ||
  29128. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  29129. }
  29130. /**
  29131. * Checks if `value` is classified as a typed array.
  29132. *
  29133. * @static
  29134. * @memberOf _
  29135. * @since 3.0.0
  29136. * @category Lang
  29137. * @param {*} value The value to check.
  29138. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  29139. * @example
  29140. *
  29141. * _.isTypedArray(new Uint8Array);
  29142. * // => true
  29143. *
  29144. * _.isTypedArray([]);
  29145. * // => false
  29146. */
  29147. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  29148. /**
  29149. * Checks if `value` is `undefined`.
  29150. *
  29151. * @static
  29152. * @since 0.1.0
  29153. * @memberOf _
  29154. * @category Lang
  29155. * @param {*} value The value to check.
  29156. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  29157. * @example
  29158. *
  29159. * _.isUndefined(void 0);
  29160. * // => true
  29161. *
  29162. * _.isUndefined(null);
  29163. * // => false
  29164. */
  29165. function isUndefined(value) {
  29166. return value === undefined;
  29167. }
  29168. /**
  29169. * Checks if `value` is classified as a `WeakMap` object.
  29170. *
  29171. * @static
  29172. * @memberOf _
  29173. * @since 4.3.0
  29174. * @category Lang
  29175. * @param {*} value The value to check.
  29176. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  29177. * @example
  29178. *
  29179. * _.isWeakMap(new WeakMap);
  29180. * // => true
  29181. *
  29182. * _.isWeakMap(new Map);
  29183. * // => false
  29184. */
  29185. function isWeakMap(value) {
  29186. return isObjectLike(value) && getTag(value) == weakMapTag;
  29187. }
  29188. /**
  29189. * Checks if `value` is classified as a `WeakSet` object.
  29190. *
  29191. * @static
  29192. * @memberOf _
  29193. * @since 4.3.0
  29194. * @category Lang
  29195. * @param {*} value The value to check.
  29196. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  29197. * @example
  29198. *
  29199. * _.isWeakSet(new WeakSet);
  29200. * // => true
  29201. *
  29202. * _.isWeakSet(new Set);
  29203. * // => false
  29204. */
  29205. function isWeakSet(value) {
  29206. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  29207. }
  29208. /**
  29209. * Checks if `value` is less than `other`.
  29210. *
  29211. * @static
  29212. * @memberOf _
  29213. * @since 3.9.0
  29214. * @category Lang
  29215. * @param {*} value The value to compare.
  29216. * @param {*} other The other value to compare.
  29217. * @returns {boolean} Returns `true` if `value` is less than `other`,
  29218. * else `false`.
  29219. * @see _.gt
  29220. * @example
  29221. *
  29222. * _.lt(1, 3);
  29223. * // => true
  29224. *
  29225. * _.lt(3, 3);
  29226. * // => false
  29227. *
  29228. * _.lt(3, 1);
  29229. * // => false
  29230. */
  29231. var lt = createRelationalOperation(baseLt);
  29232. /**
  29233. * Checks if `value` is less than or equal to `other`.
  29234. *
  29235. * @static
  29236. * @memberOf _
  29237. * @since 3.9.0
  29238. * @category Lang
  29239. * @param {*} value The value to compare.
  29240. * @param {*} other The other value to compare.
  29241. * @returns {boolean} Returns `true` if `value` is less than or equal to
  29242. * `other`, else `false`.
  29243. * @see _.gte
  29244. * @example
  29245. *
  29246. * _.lte(1, 3);
  29247. * // => true
  29248. *
  29249. * _.lte(3, 3);
  29250. * // => true
  29251. *
  29252. * _.lte(3, 1);
  29253. * // => false
  29254. */
  29255. var lte = createRelationalOperation(function(value, other) {
  29256. return value <= other;
  29257. });
  29258. /**
  29259. * Converts `value` to an array.
  29260. *
  29261. * @static
  29262. * @since 0.1.0
  29263. * @memberOf _
  29264. * @category Lang
  29265. * @param {*} value The value to convert.
  29266. * @returns {Array} Returns the converted array.
  29267. * @example
  29268. *
  29269. * _.toArray({ 'a': 1, 'b': 2 });
  29270. * // => [1, 2]
  29271. *
  29272. * _.toArray('abc');
  29273. * // => ['a', 'b', 'c']
  29274. *
  29275. * _.toArray(1);
  29276. * // => []
  29277. *
  29278. * _.toArray(null);
  29279. * // => []
  29280. */
  29281. function toArray(value) {
  29282. if (!value) {
  29283. return [];
  29284. }
  29285. if (isArrayLike(value)) {
  29286. return isString(value) ? stringToArray(value) : copyArray(value);
  29287. }
  29288. if (symIterator && value[symIterator]) {
  29289. return iteratorToArray(value[symIterator]());
  29290. }
  29291. var tag = getTag(value),
  29292. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  29293. return func(value);
  29294. }
  29295. /**
  29296. * Converts `value` to a finite number.
  29297. *
  29298. * @static
  29299. * @memberOf _
  29300. * @since 4.12.0
  29301. * @category Lang
  29302. * @param {*} value The value to convert.
  29303. * @returns {number} Returns the converted number.
  29304. * @example
  29305. *
  29306. * _.toFinite(3.2);
  29307. * // => 3.2
  29308. *
  29309. * _.toFinite(Number.MIN_VALUE);
  29310. * // => 5e-324
  29311. *
  29312. * _.toFinite(Infinity);
  29313. * // => 1.7976931348623157e+308
  29314. *
  29315. * _.toFinite('3.2');
  29316. * // => 3.2
  29317. */
  29318. function toFinite(value) {
  29319. if (!value) {
  29320. return value === 0 ? value : 0;
  29321. }
  29322. value = toNumber(value);
  29323. if (value === INFINITY || value === -INFINITY) {
  29324. var sign = (value < 0 ? -1 : 1);
  29325. return sign * MAX_INTEGER;
  29326. }
  29327. return value === value ? value : 0;
  29328. }
  29329. /**
  29330. * Converts `value` to an integer.
  29331. *
  29332. * **Note:** This method is loosely based on
  29333. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  29334. *
  29335. * @static
  29336. * @memberOf _
  29337. * @since 4.0.0
  29338. * @category Lang
  29339. * @param {*} value The value to convert.
  29340. * @returns {number} Returns the converted integer.
  29341. * @example
  29342. *
  29343. * _.toInteger(3.2);
  29344. * // => 3
  29345. *
  29346. * _.toInteger(Number.MIN_VALUE);
  29347. * // => 0
  29348. *
  29349. * _.toInteger(Infinity);
  29350. * // => 1.7976931348623157e+308
  29351. *
  29352. * _.toInteger('3.2');
  29353. * // => 3
  29354. */
  29355. function toInteger(value) {
  29356. var result = toFinite(value),
  29357. remainder = result % 1;
  29358. return result === result ? (remainder ? result - remainder : result) : 0;
  29359. }
  29360. /**
  29361. * Converts `value` to an integer suitable for use as the length of an
  29362. * array-like object.
  29363. *
  29364. * **Note:** This method is based on
  29365. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  29366. *
  29367. * @static
  29368. * @memberOf _
  29369. * @since 4.0.0
  29370. * @category Lang
  29371. * @param {*} value The value to convert.
  29372. * @returns {number} Returns the converted integer.
  29373. * @example
  29374. *
  29375. * _.toLength(3.2);
  29376. * // => 3
  29377. *
  29378. * _.toLength(Number.MIN_VALUE);
  29379. * // => 0
  29380. *
  29381. * _.toLength(Infinity);
  29382. * // => 4294967295
  29383. *
  29384. * _.toLength('3.2');
  29385. * // => 3
  29386. */
  29387. function toLength(value) {
  29388. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  29389. }
  29390. /**
  29391. * Converts `value` to a number.
  29392. *
  29393. * @static
  29394. * @memberOf _
  29395. * @since 4.0.0
  29396. * @category Lang
  29397. * @param {*} value The value to process.
  29398. * @returns {number} Returns the number.
  29399. * @example
  29400. *
  29401. * _.toNumber(3.2);
  29402. * // => 3.2
  29403. *
  29404. * _.toNumber(Number.MIN_VALUE);
  29405. * // => 5e-324
  29406. *
  29407. * _.toNumber(Infinity);
  29408. * // => Infinity
  29409. *
  29410. * _.toNumber('3.2');
  29411. * // => 3.2
  29412. */
  29413. function toNumber(value) {
  29414. if (typeof value == 'number') {
  29415. return value;
  29416. }
  29417. if (isSymbol(value)) {
  29418. return NAN;
  29419. }
  29420. if (isObject(value)) {
  29421. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  29422. value = isObject(other) ? (other + '') : other;
  29423. }
  29424. if (typeof value != 'string') {
  29425. return value === 0 ? value : +value;
  29426. }
  29427. value = value.replace(reTrim, '');
  29428. var isBinary = reIsBinary.test(value);
  29429. return (isBinary || reIsOctal.test(value))
  29430. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  29431. : (reIsBadHex.test(value) ? NAN : +value);
  29432. }
  29433. /**
  29434. * Converts `value` to a plain object flattening inherited enumerable string
  29435. * keyed properties of `value` to own properties of the plain object.
  29436. *
  29437. * @static
  29438. * @memberOf _
  29439. * @since 3.0.0
  29440. * @category Lang
  29441. * @param {*} value The value to convert.
  29442. * @returns {Object} Returns the converted plain object.
  29443. * @example
  29444. *
  29445. * function Foo() {
  29446. * this.b = 2;
  29447. * }
  29448. *
  29449. * Foo.prototype.c = 3;
  29450. *
  29451. * _.assign({ 'a': 1 }, new Foo);
  29452. * // => { 'a': 1, 'b': 2 }
  29453. *
  29454. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  29455. * // => { 'a': 1, 'b': 2, 'c': 3 }
  29456. */
  29457. function toPlainObject(value) {
  29458. return copyObject(value, keysIn(value));
  29459. }
  29460. /**
  29461. * Converts `value` to a safe integer. A safe integer can be compared and
  29462. * represented correctly.
  29463. *
  29464. * @static
  29465. * @memberOf _
  29466. * @since 4.0.0
  29467. * @category Lang
  29468. * @param {*} value The value to convert.
  29469. * @returns {number} Returns the converted integer.
  29470. * @example
  29471. *
  29472. * _.toSafeInteger(3.2);
  29473. * // => 3
  29474. *
  29475. * _.toSafeInteger(Number.MIN_VALUE);
  29476. * // => 0
  29477. *
  29478. * _.toSafeInteger(Infinity);
  29479. * // => 9007199254740991
  29480. *
  29481. * _.toSafeInteger('3.2');
  29482. * // => 3
  29483. */
  29484. function toSafeInteger(value) {
  29485. return value
  29486. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  29487. : (value === 0 ? value : 0);
  29488. }
  29489. /**
  29490. * Converts `value` to a string. An empty string is returned for `null`
  29491. * and `undefined` values. The sign of `-0` is preserved.
  29492. *
  29493. * @static
  29494. * @memberOf _
  29495. * @since 4.0.0
  29496. * @category Lang
  29497. * @param {*} value The value to convert.
  29498. * @returns {string} Returns the converted string.
  29499. * @example
  29500. *
  29501. * _.toString(null);
  29502. * // => ''
  29503. *
  29504. * _.toString(-0);
  29505. * // => '-0'
  29506. *
  29507. * _.toString([1, 2, 3]);
  29508. * // => '1,2,3'
  29509. */
  29510. function toString(value) {
  29511. return value == null ? '' : baseToString(value);
  29512. }
  29513. /*------------------------------------------------------------------------*/
  29514. /**
  29515. * Assigns own enumerable string keyed properties of source objects to the
  29516. * destination object. Source objects are applied from left to right.
  29517. * Subsequent sources overwrite property assignments of previous sources.
  29518. *
  29519. * **Note:** This method mutates `object` and is loosely based on
  29520. * [`Object.assign`](https://mdn.io/Object/assign).
  29521. *
  29522. * @static
  29523. * @memberOf _
  29524. * @since 0.10.0
  29525. * @category Object
  29526. * @param {Object} object The destination object.
  29527. * @param {...Object} [sources] The source objects.
  29528. * @returns {Object} Returns `object`.
  29529. * @see _.assignIn
  29530. * @example
  29531. *
  29532. * function Foo() {
  29533. * this.a = 1;
  29534. * }
  29535. *
  29536. * function Bar() {
  29537. * this.c = 3;
  29538. * }
  29539. *
  29540. * Foo.prototype.b = 2;
  29541. * Bar.prototype.d = 4;
  29542. *
  29543. * _.assign({ 'a': 0 }, new Foo, new Bar);
  29544. * // => { 'a': 1, 'c': 3 }
  29545. */
  29546. var assign = createAssigner(function(object, source) {
  29547. if (isPrototype(source) || isArrayLike(source)) {
  29548. copyObject(source, keys(source), object);
  29549. return;
  29550. }
  29551. for (var key in source) {
  29552. if (hasOwnProperty.call(source, key)) {
  29553. assignValue(object, key, source[key]);
  29554. }
  29555. }
  29556. });
  29557. /**
  29558. * This method is like `_.assign` except that it iterates over own and
  29559. * inherited source properties.
  29560. *
  29561. * **Note:** This method mutates `object`.
  29562. *
  29563. * @static
  29564. * @memberOf _
  29565. * @since 4.0.0
  29566. * @alias extend
  29567. * @category Object
  29568. * @param {Object} object The destination object.
  29569. * @param {...Object} [sources] The source objects.
  29570. * @returns {Object} Returns `object`.
  29571. * @see _.assign
  29572. * @example
  29573. *
  29574. * function Foo() {
  29575. * this.a = 1;
  29576. * }
  29577. *
  29578. * function Bar() {
  29579. * this.c = 3;
  29580. * }
  29581. *
  29582. * Foo.prototype.b = 2;
  29583. * Bar.prototype.d = 4;
  29584. *
  29585. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  29586. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  29587. */
  29588. var assignIn = createAssigner(function(object, source) {
  29589. copyObject(source, keysIn(source), object);
  29590. });
  29591. /**
  29592. * This method is like `_.assignIn` except that it accepts `customizer`
  29593. * which is invoked to produce the assigned values. If `customizer` returns
  29594. * `undefined`, assignment is handled by the method instead. The `customizer`
  29595. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29596. *
  29597. * **Note:** This method mutates `object`.
  29598. *
  29599. * @static
  29600. * @memberOf _
  29601. * @since 4.0.0
  29602. * @alias extendWith
  29603. * @category Object
  29604. * @param {Object} object The destination object.
  29605. * @param {...Object} sources The source objects.
  29606. * @param {Function} [customizer] The function to customize assigned values.
  29607. * @returns {Object} Returns `object`.
  29608. * @see _.assignWith
  29609. * @example
  29610. *
  29611. * function customizer(objValue, srcValue) {
  29612. * return _.isUndefined(objValue) ? srcValue : objValue;
  29613. * }
  29614. *
  29615. * var defaults = _.partialRight(_.assignInWith, customizer);
  29616. *
  29617. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29618. * // => { 'a': 1, 'b': 2 }
  29619. */
  29620. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  29621. copyObject(source, keysIn(source), object, customizer);
  29622. });
  29623. /**
  29624. * This method is like `_.assign` except that it accepts `customizer`
  29625. * which is invoked to produce the assigned values. If `customizer` returns
  29626. * `undefined`, assignment is handled by the method instead. The `customizer`
  29627. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29628. *
  29629. * **Note:** This method mutates `object`.
  29630. *
  29631. * @static
  29632. * @memberOf _
  29633. * @since 4.0.0
  29634. * @category Object
  29635. * @param {Object} object The destination object.
  29636. * @param {...Object} sources The source objects.
  29637. * @param {Function} [customizer] The function to customize assigned values.
  29638. * @returns {Object} Returns `object`.
  29639. * @see _.assignInWith
  29640. * @example
  29641. *
  29642. * function customizer(objValue, srcValue) {
  29643. * return _.isUndefined(objValue) ? srcValue : objValue;
  29644. * }
  29645. *
  29646. * var defaults = _.partialRight(_.assignWith, customizer);
  29647. *
  29648. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29649. * // => { 'a': 1, 'b': 2 }
  29650. */
  29651. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  29652. copyObject(source, keys(source), object, customizer);
  29653. });
  29654. /**
  29655. * Creates an array of values corresponding to `paths` of `object`.
  29656. *
  29657. * @static
  29658. * @memberOf _
  29659. * @since 1.0.0
  29660. * @category Object
  29661. * @param {Object} object The object to iterate over.
  29662. * @param {...(string|string[])} [paths] The property paths to pick.
  29663. * @returns {Array} Returns the picked values.
  29664. * @example
  29665. *
  29666. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  29667. *
  29668. * _.at(object, ['a[0].b.c', 'a[1]']);
  29669. * // => [3, 4]
  29670. */
  29671. var at = flatRest(baseAt);
  29672. /**
  29673. * Creates an object that inherits from the `prototype` object. If a
  29674. * `properties` object is given, its own enumerable string keyed properties
  29675. * are assigned to the created object.
  29676. *
  29677. * @static
  29678. * @memberOf _
  29679. * @since 2.3.0
  29680. * @category Object
  29681. * @param {Object} prototype The object to inherit from.
  29682. * @param {Object} [properties] The properties to assign to the object.
  29683. * @returns {Object} Returns the new object.
  29684. * @example
  29685. *
  29686. * function Shape() {
  29687. * this.x = 0;
  29688. * this.y = 0;
  29689. * }
  29690. *
  29691. * function Circle() {
  29692. * Shape.call(this);
  29693. * }
  29694. *
  29695. * Circle.prototype = _.create(Shape.prototype, {
  29696. * 'constructor': Circle
  29697. * });
  29698. *
  29699. * var circle = new Circle;
  29700. * circle instanceof Circle;
  29701. * // => true
  29702. *
  29703. * circle instanceof Shape;
  29704. * // => true
  29705. */
  29706. function create(prototype, properties) {
  29707. var result = baseCreate(prototype);
  29708. return properties == null ? result : baseAssign(result, properties);
  29709. }
  29710. /**
  29711. * Assigns own and inherited enumerable string keyed properties of source
  29712. * objects to the destination object for all destination properties that
  29713. * resolve to `undefined`. Source objects are applied from left to right.
  29714. * Once a property is set, additional values of the same property are ignored.
  29715. *
  29716. * **Note:** This method mutates `object`.
  29717. *
  29718. * @static
  29719. * @since 0.1.0
  29720. * @memberOf _
  29721. * @category Object
  29722. * @param {Object} object The destination object.
  29723. * @param {...Object} [sources] The source objects.
  29724. * @returns {Object} Returns `object`.
  29725. * @see _.defaultsDeep
  29726. * @example
  29727. *
  29728. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29729. * // => { 'a': 1, 'b': 2 }
  29730. */
  29731. var defaults = baseRest(function(object, sources) {
  29732. object = Object(object);
  29733. var index = -1;
  29734. var length = sources.length;
  29735. var guard = length > 2 ? sources[2] : undefined;
  29736. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  29737. length = 1;
  29738. }
  29739. while (++index < length) {
  29740. var source = sources[index];
  29741. var props = keysIn(source);
  29742. var propsIndex = -1;
  29743. var propsLength = props.length;
  29744. while (++propsIndex < propsLength) {
  29745. var key = props[propsIndex];
  29746. var value = object[key];
  29747. if (value === undefined ||
  29748. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  29749. object[key] = source[key];
  29750. }
  29751. }
  29752. }
  29753. return object;
  29754. });
  29755. /**
  29756. * This method is like `_.defaults` except that it recursively assigns
  29757. * default properties.
  29758. *
  29759. * **Note:** This method mutates `object`.
  29760. *
  29761. * @static
  29762. * @memberOf _
  29763. * @since 3.10.0
  29764. * @category Object
  29765. * @param {Object} object The destination object.
  29766. * @param {...Object} [sources] The source objects.
  29767. * @returns {Object} Returns `object`.
  29768. * @see _.defaults
  29769. * @example
  29770. *
  29771. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  29772. * // => { 'a': { 'b': 2, 'c': 3 } }
  29773. */
  29774. var defaultsDeep = baseRest(function(args) {
  29775. args.push(undefined, customDefaultsMerge);
  29776. return apply(mergeWith, undefined, args);
  29777. });
  29778. /**
  29779. * This method is like `_.find` except that it returns the key of the first
  29780. * element `predicate` returns truthy for instead of the element itself.
  29781. *
  29782. * @static
  29783. * @memberOf _
  29784. * @since 1.1.0
  29785. * @category Object
  29786. * @param {Object} object The object to inspect.
  29787. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29788. * @returns {string|undefined} Returns the key of the matched element,
  29789. * else `undefined`.
  29790. * @example
  29791. *
  29792. * var users = {
  29793. * 'barney': { 'age': 36, 'active': true },
  29794. * 'fred': { 'age': 40, 'active': false },
  29795. * 'pebbles': { 'age': 1, 'active': true }
  29796. * };
  29797. *
  29798. * _.findKey(users, function(o) { return o.age < 40; });
  29799. * // => 'barney' (iteration order is not guaranteed)
  29800. *
  29801. * // The `_.matches` iteratee shorthand.
  29802. * _.findKey(users, { 'age': 1, 'active': true });
  29803. * // => 'pebbles'
  29804. *
  29805. * // The `_.matchesProperty` iteratee shorthand.
  29806. * _.findKey(users, ['active', false]);
  29807. * // => 'fred'
  29808. *
  29809. * // The `_.property` iteratee shorthand.
  29810. * _.findKey(users, 'active');
  29811. * // => 'barney'
  29812. */
  29813. function findKey(object, predicate) {
  29814. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  29815. }
  29816. /**
  29817. * This method is like `_.findKey` except that it iterates over elements of
  29818. * a collection in the opposite order.
  29819. *
  29820. * @static
  29821. * @memberOf _
  29822. * @since 2.0.0
  29823. * @category Object
  29824. * @param {Object} object The object to inspect.
  29825. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29826. * @returns {string|undefined} Returns the key of the matched element,
  29827. * else `undefined`.
  29828. * @example
  29829. *
  29830. * var users = {
  29831. * 'barney': { 'age': 36, 'active': true },
  29832. * 'fred': { 'age': 40, 'active': false },
  29833. * 'pebbles': { 'age': 1, 'active': true }
  29834. * };
  29835. *
  29836. * _.findLastKey(users, function(o) { return o.age < 40; });
  29837. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  29838. *
  29839. * // The `_.matches` iteratee shorthand.
  29840. * _.findLastKey(users, { 'age': 36, 'active': true });
  29841. * // => 'barney'
  29842. *
  29843. * // The `_.matchesProperty` iteratee shorthand.
  29844. * _.findLastKey(users, ['active', false]);
  29845. * // => 'fred'
  29846. *
  29847. * // The `_.property` iteratee shorthand.
  29848. * _.findLastKey(users, 'active');
  29849. * // => 'pebbles'
  29850. */
  29851. function findLastKey(object, predicate) {
  29852. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  29853. }
  29854. /**
  29855. * Iterates over own and inherited enumerable string keyed properties of an
  29856. * object and invokes `iteratee` for each property. The iteratee is invoked
  29857. * with three arguments: (value, key, object). Iteratee functions may exit
  29858. * iteration early by explicitly returning `false`.
  29859. *
  29860. * @static
  29861. * @memberOf _
  29862. * @since 0.3.0
  29863. * @category Object
  29864. * @param {Object} object The object to iterate over.
  29865. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29866. * @returns {Object} Returns `object`.
  29867. * @see _.forInRight
  29868. * @example
  29869. *
  29870. * function Foo() {
  29871. * this.a = 1;
  29872. * this.b = 2;
  29873. * }
  29874. *
  29875. * Foo.prototype.c = 3;
  29876. *
  29877. * _.forIn(new Foo, function(value, key) {
  29878. * console.log(key);
  29879. * });
  29880. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  29881. */
  29882. function forIn(object, iteratee) {
  29883. return object == null
  29884. ? object
  29885. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  29886. }
  29887. /**
  29888. * This method is like `_.forIn` except that it iterates over properties of
  29889. * `object` in the opposite order.
  29890. *
  29891. * @static
  29892. * @memberOf _
  29893. * @since 2.0.0
  29894. * @category Object
  29895. * @param {Object} object The object to iterate over.
  29896. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29897. * @returns {Object} Returns `object`.
  29898. * @see _.forIn
  29899. * @example
  29900. *
  29901. * function Foo() {
  29902. * this.a = 1;
  29903. * this.b = 2;
  29904. * }
  29905. *
  29906. * Foo.prototype.c = 3;
  29907. *
  29908. * _.forInRight(new Foo, function(value, key) {
  29909. * console.log(key);
  29910. * });
  29911. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  29912. */
  29913. function forInRight(object, iteratee) {
  29914. return object == null
  29915. ? object
  29916. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  29917. }
  29918. /**
  29919. * Iterates over own enumerable string keyed properties of an object and
  29920. * invokes `iteratee` for each property. The iteratee is invoked with three
  29921. * arguments: (value, key, object). Iteratee functions may exit iteration
  29922. * early by explicitly returning `false`.
  29923. *
  29924. * @static
  29925. * @memberOf _
  29926. * @since 0.3.0
  29927. * @category Object
  29928. * @param {Object} object The object to iterate over.
  29929. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29930. * @returns {Object} Returns `object`.
  29931. * @see _.forOwnRight
  29932. * @example
  29933. *
  29934. * function Foo() {
  29935. * this.a = 1;
  29936. * this.b = 2;
  29937. * }
  29938. *
  29939. * Foo.prototype.c = 3;
  29940. *
  29941. * _.forOwn(new Foo, function(value, key) {
  29942. * console.log(key);
  29943. * });
  29944. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  29945. */
  29946. function forOwn(object, iteratee) {
  29947. return object && baseForOwn(object, getIteratee(iteratee, 3));
  29948. }
  29949. /**
  29950. * This method is like `_.forOwn` except that it iterates over properties of
  29951. * `object` in the opposite order.
  29952. *
  29953. * @static
  29954. * @memberOf _
  29955. * @since 2.0.0
  29956. * @category Object
  29957. * @param {Object} object The object to iterate over.
  29958. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29959. * @returns {Object} Returns `object`.
  29960. * @see _.forOwn
  29961. * @example
  29962. *
  29963. * function Foo() {
  29964. * this.a = 1;
  29965. * this.b = 2;
  29966. * }
  29967. *
  29968. * Foo.prototype.c = 3;
  29969. *
  29970. * _.forOwnRight(new Foo, function(value, key) {
  29971. * console.log(key);
  29972. * });
  29973. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  29974. */
  29975. function forOwnRight(object, iteratee) {
  29976. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  29977. }
  29978. /**
  29979. * Creates an array of function property names from own enumerable properties
  29980. * of `object`.
  29981. *
  29982. * @static
  29983. * @since 0.1.0
  29984. * @memberOf _
  29985. * @category Object
  29986. * @param {Object} object The object to inspect.
  29987. * @returns {Array} Returns the function names.
  29988. * @see _.functionsIn
  29989. * @example
  29990. *
  29991. * function Foo() {
  29992. * this.a = _.constant('a');
  29993. * this.b = _.constant('b');
  29994. * }
  29995. *
  29996. * Foo.prototype.c = _.constant('c');
  29997. *
  29998. * _.functions(new Foo);
  29999. * // => ['a', 'b']
  30000. */
  30001. function functions(object) {
  30002. return object == null ? [] : baseFunctions(object, keys(object));
  30003. }
  30004. /**
  30005. * Creates an array of function property names from own and inherited
  30006. * enumerable properties of `object`.
  30007. *
  30008. * @static
  30009. * @memberOf _
  30010. * @since 4.0.0
  30011. * @category Object
  30012. * @param {Object} object The object to inspect.
  30013. * @returns {Array} Returns the function names.
  30014. * @see _.functions
  30015. * @example
  30016. *
  30017. * function Foo() {
  30018. * this.a = _.constant('a');
  30019. * this.b = _.constant('b');
  30020. * }
  30021. *
  30022. * Foo.prototype.c = _.constant('c');
  30023. *
  30024. * _.functionsIn(new Foo);
  30025. * // => ['a', 'b', 'c']
  30026. */
  30027. function functionsIn(object) {
  30028. return object == null ? [] : baseFunctions(object, keysIn(object));
  30029. }
  30030. /**
  30031. * Gets the value at `path` of `object`. If the resolved value is
  30032. * `undefined`, the `defaultValue` is returned in its place.
  30033. *
  30034. * @static
  30035. * @memberOf _
  30036. * @since 3.7.0
  30037. * @category Object
  30038. * @param {Object} object The object to query.
  30039. * @param {Array|string} path The path of the property to get.
  30040. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30041. * @returns {*} Returns the resolved value.
  30042. * @example
  30043. *
  30044. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30045. *
  30046. * _.get(object, 'a[0].b.c');
  30047. * // => 3
  30048. *
  30049. * _.get(object, ['a', '0', 'b', 'c']);
  30050. * // => 3
  30051. *
  30052. * _.get(object, 'a.b.c', 'default');
  30053. * // => 'default'
  30054. */
  30055. function get(object, path, defaultValue) {
  30056. var result = object == null ? undefined : baseGet(object, path);
  30057. return result === undefined ? defaultValue : result;
  30058. }
  30059. /**
  30060. * Checks if `path` is a direct property of `object`.
  30061. *
  30062. * @static
  30063. * @since 0.1.0
  30064. * @memberOf _
  30065. * @category Object
  30066. * @param {Object} object The object to query.
  30067. * @param {Array|string} path The path to check.
  30068. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30069. * @example
  30070. *
  30071. * var object = { 'a': { 'b': 2 } };
  30072. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  30073. *
  30074. * _.has(object, 'a');
  30075. * // => true
  30076. *
  30077. * _.has(object, 'a.b');
  30078. * // => true
  30079. *
  30080. * _.has(object, ['a', 'b']);
  30081. * // => true
  30082. *
  30083. * _.has(other, 'a');
  30084. * // => false
  30085. */
  30086. function has(object, path) {
  30087. return object != null && hasPath(object, path, baseHas);
  30088. }
  30089. /**
  30090. * Checks if `path` is a direct or inherited property of `object`.
  30091. *
  30092. * @static
  30093. * @memberOf _
  30094. * @since 4.0.0
  30095. * @category Object
  30096. * @param {Object} object The object to query.
  30097. * @param {Array|string} path The path to check.
  30098. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30099. * @example
  30100. *
  30101. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  30102. *
  30103. * _.hasIn(object, 'a');
  30104. * // => true
  30105. *
  30106. * _.hasIn(object, 'a.b');
  30107. * // => true
  30108. *
  30109. * _.hasIn(object, ['a', 'b']);
  30110. * // => true
  30111. *
  30112. * _.hasIn(object, 'b');
  30113. * // => false
  30114. */
  30115. function hasIn(object, path) {
  30116. return object != null && hasPath(object, path, baseHasIn);
  30117. }
  30118. /**
  30119. * Creates an object composed of the inverted keys and values of `object`.
  30120. * If `object` contains duplicate values, subsequent values overwrite
  30121. * property assignments of previous values.
  30122. *
  30123. * @static
  30124. * @memberOf _
  30125. * @since 0.7.0
  30126. * @category Object
  30127. * @param {Object} object The object to invert.
  30128. * @returns {Object} Returns the new inverted object.
  30129. * @example
  30130. *
  30131. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30132. *
  30133. * _.invert(object);
  30134. * // => { '1': 'c', '2': 'b' }
  30135. */
  30136. var invert = createInverter(function(result, value, key) {
  30137. if (value != null &&
  30138. typeof value.toString != 'function') {
  30139. value = nativeObjectToString.call(value);
  30140. }
  30141. result[value] = key;
  30142. }, constant(identity));
  30143. /**
  30144. * This method is like `_.invert` except that the inverted object is generated
  30145. * from the results of running each element of `object` thru `iteratee`. The
  30146. * corresponding inverted value of each inverted key is an array of keys
  30147. * responsible for generating the inverted value. The iteratee is invoked
  30148. * with one argument: (value).
  30149. *
  30150. * @static
  30151. * @memberOf _
  30152. * @since 4.1.0
  30153. * @category Object
  30154. * @param {Object} object The object to invert.
  30155. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  30156. * @returns {Object} Returns the new inverted object.
  30157. * @example
  30158. *
  30159. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30160. *
  30161. * _.invertBy(object);
  30162. * // => { '1': ['a', 'c'], '2': ['b'] }
  30163. *
  30164. * _.invertBy(object, function(value) {
  30165. * return 'group' + value;
  30166. * });
  30167. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  30168. */
  30169. var invertBy = createInverter(function(result, value, key) {
  30170. if (value != null &&
  30171. typeof value.toString != 'function') {
  30172. value = nativeObjectToString.call(value);
  30173. }
  30174. if (hasOwnProperty.call(result, value)) {
  30175. result[value].push(key);
  30176. } else {
  30177. result[value] = [key];
  30178. }
  30179. }, getIteratee);
  30180. /**
  30181. * Invokes the method at `path` of `object`.
  30182. *
  30183. * @static
  30184. * @memberOf _
  30185. * @since 4.0.0
  30186. * @category Object
  30187. * @param {Object} object The object to query.
  30188. * @param {Array|string} path The path of the method to invoke.
  30189. * @param {...*} [args] The arguments to invoke the method with.
  30190. * @returns {*} Returns the result of the invoked method.
  30191. * @example
  30192. *
  30193. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  30194. *
  30195. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  30196. * // => [2, 3]
  30197. */
  30198. var invoke = baseRest(baseInvoke);
  30199. /**
  30200. * Creates an array of the own enumerable property names of `object`.
  30201. *
  30202. * **Note:** Non-object values are coerced to objects. See the
  30203. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  30204. * for more details.
  30205. *
  30206. * @static
  30207. * @since 0.1.0
  30208. * @memberOf _
  30209. * @category Object
  30210. * @param {Object} object The object to query.
  30211. * @returns {Array} Returns the array of property names.
  30212. * @example
  30213. *
  30214. * function Foo() {
  30215. * this.a = 1;
  30216. * this.b = 2;
  30217. * }
  30218. *
  30219. * Foo.prototype.c = 3;
  30220. *
  30221. * _.keys(new Foo);
  30222. * // => ['a', 'b'] (iteration order is not guaranteed)
  30223. *
  30224. * _.keys('hi');
  30225. * // => ['0', '1']
  30226. */
  30227. function keys(object) {
  30228. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  30229. }
  30230. /**
  30231. * Creates an array of the own and inherited enumerable property names of `object`.
  30232. *
  30233. * **Note:** Non-object values are coerced to objects.
  30234. *
  30235. * @static
  30236. * @memberOf _
  30237. * @since 3.0.0
  30238. * @category Object
  30239. * @param {Object} object The object to query.
  30240. * @returns {Array} Returns the array of property names.
  30241. * @example
  30242. *
  30243. * function Foo() {
  30244. * this.a = 1;
  30245. * this.b = 2;
  30246. * }
  30247. *
  30248. * Foo.prototype.c = 3;
  30249. *
  30250. * _.keysIn(new Foo);
  30251. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  30252. */
  30253. function keysIn(object) {
  30254. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  30255. }
  30256. /**
  30257. * The opposite of `_.mapValues`; this method creates an object with the
  30258. * same values as `object` and keys generated by running each own enumerable
  30259. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  30260. * with three arguments: (value, key, object).
  30261. *
  30262. * @static
  30263. * @memberOf _
  30264. * @since 3.8.0
  30265. * @category Object
  30266. * @param {Object} object The object to iterate over.
  30267. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30268. * @returns {Object} Returns the new mapped object.
  30269. * @see _.mapValues
  30270. * @example
  30271. *
  30272. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  30273. * return key + value;
  30274. * });
  30275. * // => { 'a1': 1, 'b2': 2 }
  30276. */
  30277. function mapKeys(object, iteratee) {
  30278. var result = {};
  30279. iteratee = getIteratee(iteratee, 3);
  30280. baseForOwn(object, function(value, key, object) {
  30281. baseAssignValue(result, iteratee(value, key, object), value);
  30282. });
  30283. return result;
  30284. }
  30285. /**
  30286. * Creates an object with the same keys as `object` and values generated
  30287. * by running each own enumerable string keyed property of `object` thru
  30288. * `iteratee`. The iteratee is invoked with three arguments:
  30289. * (value, key, object).
  30290. *
  30291. * @static
  30292. * @memberOf _
  30293. * @since 2.4.0
  30294. * @category Object
  30295. * @param {Object} object The object to iterate over.
  30296. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30297. * @returns {Object} Returns the new mapped object.
  30298. * @see _.mapKeys
  30299. * @example
  30300. *
  30301. * var users = {
  30302. * 'fred': { 'user': 'fred', 'age': 40 },
  30303. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  30304. * };
  30305. *
  30306. * _.mapValues(users, function(o) { return o.age; });
  30307. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30308. *
  30309. * // The `_.property` iteratee shorthand.
  30310. * _.mapValues(users, 'age');
  30311. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30312. */
  30313. function mapValues(object, iteratee) {
  30314. var result = {};
  30315. iteratee = getIteratee(iteratee, 3);
  30316. baseForOwn(object, function(value, key, object) {
  30317. baseAssignValue(result, key, iteratee(value, key, object));
  30318. });
  30319. return result;
  30320. }
  30321. /**
  30322. * This method is like `_.assign` except that it recursively merges own and
  30323. * inherited enumerable string keyed properties of source objects into the
  30324. * destination object. Source properties that resolve to `undefined` are
  30325. * skipped if a destination value exists. Array and plain object properties
  30326. * are merged recursively. Other objects and value types are overridden by
  30327. * assignment. Source objects are applied from left to right. Subsequent
  30328. * sources overwrite property assignments of previous sources.
  30329. *
  30330. * **Note:** This method mutates `object`.
  30331. *
  30332. * @static
  30333. * @memberOf _
  30334. * @since 0.5.0
  30335. * @category Object
  30336. * @param {Object} object The destination object.
  30337. * @param {...Object} [sources] The source objects.
  30338. * @returns {Object} Returns `object`.
  30339. * @example
  30340. *
  30341. * var object = {
  30342. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  30343. * };
  30344. *
  30345. * var other = {
  30346. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  30347. * };
  30348. *
  30349. * _.merge(object, other);
  30350. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  30351. */
  30352. var merge = createAssigner(function(object, source, srcIndex) {
  30353. baseMerge(object, source, srcIndex);
  30354. });
  30355. /**
  30356. * This method is like `_.merge` except that it accepts `customizer` which
  30357. * is invoked to produce the merged values of the destination and source
  30358. * properties. If `customizer` returns `undefined`, merging is handled by the
  30359. * method instead. The `customizer` is invoked with six arguments:
  30360. * (objValue, srcValue, key, object, source, stack).
  30361. *
  30362. * **Note:** This method mutates `object`.
  30363. *
  30364. * @static
  30365. * @memberOf _
  30366. * @since 4.0.0
  30367. * @category Object
  30368. * @param {Object} object The destination object.
  30369. * @param {...Object} sources The source objects.
  30370. * @param {Function} customizer The function to customize assigned values.
  30371. * @returns {Object} Returns `object`.
  30372. * @example
  30373. *
  30374. * function customizer(objValue, srcValue) {
  30375. * if (_.isArray(objValue)) {
  30376. * return objValue.concat(srcValue);
  30377. * }
  30378. * }
  30379. *
  30380. * var object = { 'a': [1], 'b': [2] };
  30381. * var other = { 'a': [3], 'b': [4] };
  30382. *
  30383. * _.mergeWith(object, other, customizer);
  30384. * // => { 'a': [1, 3], 'b': [2, 4] }
  30385. */
  30386. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  30387. baseMerge(object, source, srcIndex, customizer);
  30388. });
  30389. /**
  30390. * The opposite of `_.pick`; this method creates an object composed of the
  30391. * own and inherited enumerable property paths of `object` that are not omitted.
  30392. *
  30393. * **Note:** This method is considerably slower than `_.pick`.
  30394. *
  30395. * @static
  30396. * @since 0.1.0
  30397. * @memberOf _
  30398. * @category Object
  30399. * @param {Object} object The source object.
  30400. * @param {...(string|string[])} [paths] The property paths to omit.
  30401. * @returns {Object} Returns the new object.
  30402. * @example
  30403. *
  30404. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30405. *
  30406. * _.omit(object, ['a', 'c']);
  30407. * // => { 'b': '2' }
  30408. */
  30409. var omit = flatRest(function(object, paths) {
  30410. var result = {};
  30411. if (object == null) {
  30412. return result;
  30413. }
  30414. var isDeep = false;
  30415. paths = arrayMap(paths, function(path) {
  30416. path = castPath(path, object);
  30417. isDeep || (isDeep = path.length > 1);
  30418. return path;
  30419. });
  30420. copyObject(object, getAllKeysIn(object), result);
  30421. if (isDeep) {
  30422. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  30423. }
  30424. var length = paths.length;
  30425. while (length--) {
  30426. baseUnset(result, paths[length]);
  30427. }
  30428. return result;
  30429. });
  30430. /**
  30431. * The opposite of `_.pickBy`; this method creates an object composed of
  30432. * the own and inherited enumerable string keyed properties of `object` that
  30433. * `predicate` doesn't return truthy for. The predicate is invoked with two
  30434. * arguments: (value, key).
  30435. *
  30436. * @static
  30437. * @memberOf _
  30438. * @since 4.0.0
  30439. * @category Object
  30440. * @param {Object} object The source object.
  30441. * @param {Function} [predicate=_.identity] The function invoked per property.
  30442. * @returns {Object} Returns the new object.
  30443. * @example
  30444. *
  30445. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30446. *
  30447. * _.omitBy(object, _.isNumber);
  30448. * // => { 'b': '2' }
  30449. */
  30450. function omitBy(object, predicate) {
  30451. return pickBy(object, negate(getIteratee(predicate)));
  30452. }
  30453. /**
  30454. * Creates an object composed of the picked `object` properties.
  30455. *
  30456. * @static
  30457. * @since 0.1.0
  30458. * @memberOf _
  30459. * @category Object
  30460. * @param {Object} object The source object.
  30461. * @param {...(string|string[])} [paths] The property paths to pick.
  30462. * @returns {Object} Returns the new object.
  30463. * @example
  30464. *
  30465. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30466. *
  30467. * _.pick(object, ['a', 'c']);
  30468. * // => { 'a': 1, 'c': 3 }
  30469. */
  30470. var pick = flatRest(function(object, paths) {
  30471. return object == null ? {} : basePick(object, paths);
  30472. });
  30473. /**
  30474. * Creates an object composed of the `object` properties `predicate` returns
  30475. * truthy for. The predicate is invoked with two arguments: (value, key).
  30476. *
  30477. * @static
  30478. * @memberOf _
  30479. * @since 4.0.0
  30480. * @category Object
  30481. * @param {Object} object The source object.
  30482. * @param {Function} [predicate=_.identity] The function invoked per property.
  30483. * @returns {Object} Returns the new object.
  30484. * @example
  30485. *
  30486. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30487. *
  30488. * _.pickBy(object, _.isNumber);
  30489. * // => { 'a': 1, 'c': 3 }
  30490. */
  30491. function pickBy(object, predicate) {
  30492. if (object == null) {
  30493. return {};
  30494. }
  30495. var props = arrayMap(getAllKeysIn(object), function(prop) {
  30496. return [prop];
  30497. });
  30498. predicate = getIteratee(predicate);
  30499. return basePickBy(object, props, function(value, path) {
  30500. return predicate(value, path[0]);
  30501. });
  30502. }
  30503. /**
  30504. * This method is like `_.get` except that if the resolved value is a
  30505. * function it's invoked with the `this` binding of its parent object and
  30506. * its result is returned.
  30507. *
  30508. * @static
  30509. * @since 0.1.0
  30510. * @memberOf _
  30511. * @category Object
  30512. * @param {Object} object The object to query.
  30513. * @param {Array|string} path The path of the property to resolve.
  30514. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30515. * @returns {*} Returns the resolved value.
  30516. * @example
  30517. *
  30518. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  30519. *
  30520. * _.result(object, 'a[0].b.c1');
  30521. * // => 3
  30522. *
  30523. * _.result(object, 'a[0].b.c2');
  30524. * // => 4
  30525. *
  30526. * _.result(object, 'a[0].b.c3', 'default');
  30527. * // => 'default'
  30528. *
  30529. * _.result(object, 'a[0].b.c3', _.constant('default'));
  30530. * // => 'default'
  30531. */
  30532. function result(object, path, defaultValue) {
  30533. path = castPath(path, object);
  30534. var index = -1,
  30535. length = path.length;
  30536. // Ensure the loop is entered when path is empty.
  30537. if (!length) {
  30538. length = 1;
  30539. object = undefined;
  30540. }
  30541. while (++index < length) {
  30542. var value = object == null ? undefined : object[toKey(path[index])];
  30543. if (value === undefined) {
  30544. index = length;
  30545. value = defaultValue;
  30546. }
  30547. object = isFunction(value) ? value.call(object) : value;
  30548. }
  30549. return object;
  30550. }
  30551. /**
  30552. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  30553. * it's created. Arrays are created for missing index properties while objects
  30554. * are created for all other missing properties. Use `_.setWith` to customize
  30555. * `path` creation.
  30556. *
  30557. * **Note:** This method mutates `object`.
  30558. *
  30559. * @static
  30560. * @memberOf _
  30561. * @since 3.7.0
  30562. * @category Object
  30563. * @param {Object} object The object to modify.
  30564. * @param {Array|string} path The path of the property to set.
  30565. * @param {*} value The value to set.
  30566. * @returns {Object} Returns `object`.
  30567. * @example
  30568. *
  30569. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30570. *
  30571. * _.set(object, 'a[0].b.c', 4);
  30572. * console.log(object.a[0].b.c);
  30573. * // => 4
  30574. *
  30575. * _.set(object, ['x', '0', 'y', 'z'], 5);
  30576. * console.log(object.x[0].y.z);
  30577. * // => 5
  30578. */
  30579. function set(object, path, value) {
  30580. return object == null ? object : baseSet(object, path, value);
  30581. }
  30582. /**
  30583. * This method is like `_.set` except that it accepts `customizer` which is
  30584. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30585. * path creation is handled by the method instead. The `customizer` is invoked
  30586. * with three arguments: (nsValue, key, nsObject).
  30587. *
  30588. * **Note:** This method mutates `object`.
  30589. *
  30590. * @static
  30591. * @memberOf _
  30592. * @since 4.0.0
  30593. * @category Object
  30594. * @param {Object} object The object to modify.
  30595. * @param {Array|string} path The path of the property to set.
  30596. * @param {*} value The value to set.
  30597. * @param {Function} [customizer] The function to customize assigned values.
  30598. * @returns {Object} Returns `object`.
  30599. * @example
  30600. *
  30601. * var object = {};
  30602. *
  30603. * _.setWith(object, '[0][1]', 'a', Object);
  30604. * // => { '0': { '1': 'a' } }
  30605. */
  30606. function setWith(object, path, value, customizer) {
  30607. customizer = typeof customizer == 'function' ? customizer : undefined;
  30608. return object == null ? object : baseSet(object, path, value, customizer);
  30609. }
  30610. /**
  30611. * Creates an array of own enumerable string keyed-value pairs for `object`
  30612. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  30613. * entries are returned.
  30614. *
  30615. * @static
  30616. * @memberOf _
  30617. * @since 4.0.0
  30618. * @alias entries
  30619. * @category Object
  30620. * @param {Object} object The object to query.
  30621. * @returns {Array} Returns the key-value pairs.
  30622. * @example
  30623. *
  30624. * function Foo() {
  30625. * this.a = 1;
  30626. * this.b = 2;
  30627. * }
  30628. *
  30629. * Foo.prototype.c = 3;
  30630. *
  30631. * _.toPairs(new Foo);
  30632. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  30633. */
  30634. var toPairs = createToPairs(keys);
  30635. /**
  30636. * Creates an array of own and inherited enumerable string keyed-value pairs
  30637. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  30638. * or set, its entries are returned.
  30639. *
  30640. * @static
  30641. * @memberOf _
  30642. * @since 4.0.0
  30643. * @alias entriesIn
  30644. * @category Object
  30645. * @param {Object} object The object to query.
  30646. * @returns {Array} Returns the key-value pairs.
  30647. * @example
  30648. *
  30649. * function Foo() {
  30650. * this.a = 1;
  30651. * this.b = 2;
  30652. * }
  30653. *
  30654. * Foo.prototype.c = 3;
  30655. *
  30656. * _.toPairsIn(new Foo);
  30657. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  30658. */
  30659. var toPairsIn = createToPairs(keysIn);
  30660. /**
  30661. * An alternative to `_.reduce`; this method transforms `object` to a new
  30662. * `accumulator` object which is the result of running each of its own
  30663. * enumerable string keyed properties thru `iteratee`, with each invocation
  30664. * potentially mutating the `accumulator` object. If `accumulator` is not
  30665. * provided, a new object with the same `[[Prototype]]` will be used. The
  30666. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  30667. * Iteratee functions may exit iteration early by explicitly returning `false`.
  30668. *
  30669. * @static
  30670. * @memberOf _
  30671. * @since 1.3.0
  30672. * @category Object
  30673. * @param {Object} object The object to iterate over.
  30674. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30675. * @param {*} [accumulator] The custom accumulator value.
  30676. * @returns {*} Returns the accumulated value.
  30677. * @example
  30678. *
  30679. * _.transform([2, 3, 4], function(result, n) {
  30680. * result.push(n *= n);
  30681. * return n % 2 == 0;
  30682. * }, []);
  30683. * // => [4, 9]
  30684. *
  30685. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  30686. * (result[value] || (result[value] = [])).push(key);
  30687. * }, {});
  30688. * // => { '1': ['a', 'c'], '2': ['b'] }
  30689. */
  30690. function transform(object, iteratee, accumulator) {
  30691. var isArr = isArray(object),
  30692. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  30693. iteratee = getIteratee(iteratee, 4);
  30694. if (accumulator == null) {
  30695. var Ctor = object && object.constructor;
  30696. if (isArrLike) {
  30697. accumulator = isArr ? new Ctor : [];
  30698. }
  30699. else if (isObject(object)) {
  30700. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  30701. }
  30702. else {
  30703. accumulator = {};
  30704. }
  30705. }
  30706. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  30707. return iteratee(accumulator, value, index, object);
  30708. });
  30709. return accumulator;
  30710. }
  30711. /**
  30712. * Removes the property at `path` of `object`.
  30713. *
  30714. * **Note:** This method mutates `object`.
  30715. *
  30716. * @static
  30717. * @memberOf _
  30718. * @since 4.0.0
  30719. * @category Object
  30720. * @param {Object} object The object to modify.
  30721. * @param {Array|string} path The path of the property to unset.
  30722. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  30723. * @example
  30724. *
  30725. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  30726. * _.unset(object, 'a[0].b.c');
  30727. * // => true
  30728. *
  30729. * console.log(object);
  30730. * // => { 'a': [{ 'b': {} }] };
  30731. *
  30732. * _.unset(object, ['a', '0', 'b', 'c']);
  30733. * // => true
  30734. *
  30735. * console.log(object);
  30736. * // => { 'a': [{ 'b': {} }] };
  30737. */
  30738. function unset(object, path) {
  30739. return object == null ? true : baseUnset(object, path);
  30740. }
  30741. /**
  30742. * This method is like `_.set` except that accepts `updater` to produce the
  30743. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  30744. * is invoked with one argument: (value).
  30745. *
  30746. * **Note:** This method mutates `object`.
  30747. *
  30748. * @static
  30749. * @memberOf _
  30750. * @since 4.6.0
  30751. * @category Object
  30752. * @param {Object} object The object to modify.
  30753. * @param {Array|string} path The path of the property to set.
  30754. * @param {Function} updater The function to produce the updated value.
  30755. * @returns {Object} Returns `object`.
  30756. * @example
  30757. *
  30758. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30759. *
  30760. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  30761. * console.log(object.a[0].b.c);
  30762. * // => 9
  30763. *
  30764. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  30765. * console.log(object.x[0].y.z);
  30766. * // => 0
  30767. */
  30768. function update(object, path, updater) {
  30769. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  30770. }
  30771. /**
  30772. * This method is like `_.update` except that it accepts `customizer` which is
  30773. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30774. * path creation is handled by the method instead. The `customizer` is invoked
  30775. * with three arguments: (nsValue, key, nsObject).
  30776. *
  30777. * **Note:** This method mutates `object`.
  30778. *
  30779. * @static
  30780. * @memberOf _
  30781. * @since 4.6.0
  30782. * @category Object
  30783. * @param {Object} object The object to modify.
  30784. * @param {Array|string} path The path of the property to set.
  30785. * @param {Function} updater The function to produce the updated value.
  30786. * @param {Function} [customizer] The function to customize assigned values.
  30787. * @returns {Object} Returns `object`.
  30788. * @example
  30789. *
  30790. * var object = {};
  30791. *
  30792. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  30793. * // => { '0': { '1': 'a' } }
  30794. */
  30795. function updateWith(object, path, updater, customizer) {
  30796. customizer = typeof customizer == 'function' ? customizer : undefined;
  30797. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  30798. }
  30799. /**
  30800. * Creates an array of the own enumerable string keyed property values of `object`.
  30801. *
  30802. * **Note:** Non-object values are coerced to objects.
  30803. *
  30804. * @static
  30805. * @since 0.1.0
  30806. * @memberOf _
  30807. * @category Object
  30808. * @param {Object} object The object to query.
  30809. * @returns {Array} Returns the array of property values.
  30810. * @example
  30811. *
  30812. * function Foo() {
  30813. * this.a = 1;
  30814. * this.b = 2;
  30815. * }
  30816. *
  30817. * Foo.prototype.c = 3;
  30818. *
  30819. * _.values(new Foo);
  30820. * // => [1, 2] (iteration order is not guaranteed)
  30821. *
  30822. * _.values('hi');
  30823. * // => ['h', 'i']
  30824. */
  30825. function values(object) {
  30826. return object == null ? [] : baseValues(object, keys(object));
  30827. }
  30828. /**
  30829. * Creates an array of the own and inherited enumerable string keyed property
  30830. * values of `object`.
  30831. *
  30832. * **Note:** Non-object values are coerced to objects.
  30833. *
  30834. * @static
  30835. * @memberOf _
  30836. * @since 3.0.0
  30837. * @category Object
  30838. * @param {Object} object The object to query.
  30839. * @returns {Array} Returns the array of property values.
  30840. * @example
  30841. *
  30842. * function Foo() {
  30843. * this.a = 1;
  30844. * this.b = 2;
  30845. * }
  30846. *
  30847. * Foo.prototype.c = 3;
  30848. *
  30849. * _.valuesIn(new Foo);
  30850. * // => [1, 2, 3] (iteration order is not guaranteed)
  30851. */
  30852. function valuesIn(object) {
  30853. return object == null ? [] : baseValues(object, keysIn(object));
  30854. }
  30855. /*------------------------------------------------------------------------*/
  30856. /**
  30857. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  30858. *
  30859. * @static
  30860. * @memberOf _
  30861. * @since 4.0.0
  30862. * @category Number
  30863. * @param {number} number The number to clamp.
  30864. * @param {number} [lower] The lower bound.
  30865. * @param {number} upper The upper bound.
  30866. * @returns {number} Returns the clamped number.
  30867. * @example
  30868. *
  30869. * _.clamp(-10, -5, 5);
  30870. * // => -5
  30871. *
  30872. * _.clamp(10, -5, 5);
  30873. * // => 5
  30874. */
  30875. function clamp(number, lower, upper) {
  30876. if (upper === undefined) {
  30877. upper = lower;
  30878. lower = undefined;
  30879. }
  30880. if (upper !== undefined) {
  30881. upper = toNumber(upper);
  30882. upper = upper === upper ? upper : 0;
  30883. }
  30884. if (lower !== undefined) {
  30885. lower = toNumber(lower);
  30886. lower = lower === lower ? lower : 0;
  30887. }
  30888. return baseClamp(toNumber(number), lower, upper);
  30889. }
  30890. /**
  30891. * Checks if `n` is between `start` and up to, but not including, `end`. If
  30892. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  30893. * If `start` is greater than `end` the params are swapped to support
  30894. * negative ranges.
  30895. *
  30896. * @static
  30897. * @memberOf _
  30898. * @since 3.3.0
  30899. * @category Number
  30900. * @param {number} number The number to check.
  30901. * @param {number} [start=0] The start of the range.
  30902. * @param {number} end The end of the range.
  30903. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  30904. * @see _.range, _.rangeRight
  30905. * @example
  30906. *
  30907. * _.inRange(3, 2, 4);
  30908. * // => true
  30909. *
  30910. * _.inRange(4, 8);
  30911. * // => true
  30912. *
  30913. * _.inRange(4, 2);
  30914. * // => false
  30915. *
  30916. * _.inRange(2, 2);
  30917. * // => false
  30918. *
  30919. * _.inRange(1.2, 2);
  30920. * // => true
  30921. *
  30922. * _.inRange(5.2, 4);
  30923. * // => false
  30924. *
  30925. * _.inRange(-3, -2, -6);
  30926. * // => true
  30927. */
  30928. function inRange(number, start, end) {
  30929. start = toFinite(start);
  30930. if (end === undefined) {
  30931. end = start;
  30932. start = 0;
  30933. } else {
  30934. end = toFinite(end);
  30935. }
  30936. number = toNumber(number);
  30937. return baseInRange(number, start, end);
  30938. }
  30939. /**
  30940. * Produces a random number between the inclusive `lower` and `upper` bounds.
  30941. * If only one argument is provided a number between `0` and the given number
  30942. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  30943. * floats, a floating-point number is returned instead of an integer.
  30944. *
  30945. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  30946. * floating-point values which can produce unexpected results.
  30947. *
  30948. * @static
  30949. * @memberOf _
  30950. * @since 0.7.0
  30951. * @category Number
  30952. * @param {number} [lower=0] The lower bound.
  30953. * @param {number} [upper=1] The upper bound.
  30954. * @param {boolean} [floating] Specify returning a floating-point number.
  30955. * @returns {number} Returns the random number.
  30956. * @example
  30957. *
  30958. * _.random(0, 5);
  30959. * // => an integer between 0 and 5
  30960. *
  30961. * _.random(5);
  30962. * // => also an integer between 0 and 5
  30963. *
  30964. * _.random(5, true);
  30965. * // => a floating-point number between 0 and 5
  30966. *
  30967. * _.random(1.2, 5.2);
  30968. * // => a floating-point number between 1.2 and 5.2
  30969. */
  30970. function random(lower, upper, floating) {
  30971. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  30972. upper = floating = undefined;
  30973. }
  30974. if (floating === undefined) {
  30975. if (typeof upper == 'boolean') {
  30976. floating = upper;
  30977. upper = undefined;
  30978. }
  30979. else if (typeof lower == 'boolean') {
  30980. floating = lower;
  30981. lower = undefined;
  30982. }
  30983. }
  30984. if (lower === undefined && upper === undefined) {
  30985. lower = 0;
  30986. upper = 1;
  30987. }
  30988. else {
  30989. lower = toFinite(lower);
  30990. if (upper === undefined) {
  30991. upper = lower;
  30992. lower = 0;
  30993. } else {
  30994. upper = toFinite(upper);
  30995. }
  30996. }
  30997. if (lower > upper) {
  30998. var temp = lower;
  30999. lower = upper;
  31000. upper = temp;
  31001. }
  31002. if (floating || lower % 1 || upper % 1) {
  31003. var rand = nativeRandom();
  31004. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  31005. }
  31006. return baseRandom(lower, upper);
  31007. }
  31008. /*------------------------------------------------------------------------*/
  31009. /**
  31010. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  31011. *
  31012. * @static
  31013. * @memberOf _
  31014. * @since 3.0.0
  31015. * @category String
  31016. * @param {string} [string=''] The string to convert.
  31017. * @returns {string} Returns the camel cased string.
  31018. * @example
  31019. *
  31020. * _.camelCase('Foo Bar');
  31021. * // => 'fooBar'
  31022. *
  31023. * _.camelCase('--foo-bar--');
  31024. * // => 'fooBar'
  31025. *
  31026. * _.camelCase('__FOO_BAR__');
  31027. * // => 'fooBar'
  31028. */
  31029. var camelCase = createCompounder(function(result, word, index) {
  31030. word = word.toLowerCase();
  31031. return result + (index ? capitalize(word) : word);
  31032. });
  31033. /**
  31034. * Converts the first character of `string` to upper case and the remaining
  31035. * to lower case.
  31036. *
  31037. * @static
  31038. * @memberOf _
  31039. * @since 3.0.0
  31040. * @category String
  31041. * @param {string} [string=''] The string to capitalize.
  31042. * @returns {string} Returns the capitalized string.
  31043. * @example
  31044. *
  31045. * _.capitalize('FRED');
  31046. * // => 'Fred'
  31047. */
  31048. function capitalize(string) {
  31049. return upperFirst(toString(string).toLowerCase());
  31050. }
  31051. /**
  31052. * Deburrs `string` by converting
  31053. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  31054. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  31055. * letters to basic Latin letters and removing
  31056. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  31057. *
  31058. * @static
  31059. * @memberOf _
  31060. * @since 3.0.0
  31061. * @category String
  31062. * @param {string} [string=''] The string to deburr.
  31063. * @returns {string} Returns the deburred string.
  31064. * @example
  31065. *
  31066. * _.deburr('déjà vu');
  31067. * // => 'deja vu'
  31068. */
  31069. function deburr(string) {
  31070. string = toString(string);
  31071. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  31072. }
  31073. /**
  31074. * Checks if `string` ends with the given target string.
  31075. *
  31076. * @static
  31077. * @memberOf _
  31078. * @since 3.0.0
  31079. * @category String
  31080. * @param {string} [string=''] The string to inspect.
  31081. * @param {string} [target] The string to search for.
  31082. * @param {number} [position=string.length] The position to search up to.
  31083. * @returns {boolean} Returns `true` if `string` ends with `target`,
  31084. * else `false`.
  31085. * @example
  31086. *
  31087. * _.endsWith('abc', 'c');
  31088. * // => true
  31089. *
  31090. * _.endsWith('abc', 'b');
  31091. * // => false
  31092. *
  31093. * _.endsWith('abc', 'b', 2);
  31094. * // => true
  31095. */
  31096. function endsWith(string, target, position) {
  31097. string = toString(string);
  31098. target = baseToString(target);
  31099. var length = string.length;
  31100. position = position === undefined
  31101. ? length
  31102. : baseClamp(toInteger(position), 0, length);
  31103. var end = position;
  31104. position -= target.length;
  31105. return position >= 0 && string.slice(position, end) == target;
  31106. }
  31107. /**
  31108. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  31109. * corresponding HTML entities.
  31110. *
  31111. * **Note:** No other characters are escaped. To escape additional
  31112. * characters use a third-party library like [_he_](https://mths.be/he).
  31113. *
  31114. * Though the ">" character is escaped for symmetry, characters like
  31115. * ">" and "/" don't need escaping in HTML and have no special meaning
  31116. * unless they're part of a tag or unquoted attribute value. See
  31117. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  31118. * (under "semi-related fun fact") for more details.
  31119. *
  31120. * When working with HTML you should always
  31121. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  31122. * XSS vectors.
  31123. *
  31124. * @static
  31125. * @since 0.1.0
  31126. * @memberOf _
  31127. * @category String
  31128. * @param {string} [string=''] The string to escape.
  31129. * @returns {string} Returns the escaped string.
  31130. * @example
  31131. *
  31132. * _.escape('fred, barney, & pebbles');
  31133. * // => 'fred, barney, &amp; pebbles'
  31134. */
  31135. function escape(string) {
  31136. string = toString(string);
  31137. return (string && reHasUnescapedHtml.test(string))
  31138. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  31139. : string;
  31140. }
  31141. /**
  31142. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  31143. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  31144. *
  31145. * @static
  31146. * @memberOf _
  31147. * @since 3.0.0
  31148. * @category String
  31149. * @param {string} [string=''] The string to escape.
  31150. * @returns {string} Returns the escaped string.
  31151. * @example
  31152. *
  31153. * _.escapeRegExp('[lodash](https://lodash.com/)');
  31154. * // => '\[lodash\]\(https://lodash\.com/\)'
  31155. */
  31156. function escapeRegExp(string) {
  31157. string = toString(string);
  31158. return (string && reHasRegExpChar.test(string))
  31159. ? string.replace(reRegExpChar, '\\$&')
  31160. : string;
  31161. }
  31162. /**
  31163. * Converts `string` to
  31164. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  31165. *
  31166. * @static
  31167. * @memberOf _
  31168. * @since 3.0.0
  31169. * @category String
  31170. * @param {string} [string=''] The string to convert.
  31171. * @returns {string} Returns the kebab cased string.
  31172. * @example
  31173. *
  31174. * _.kebabCase('Foo Bar');
  31175. * // => 'foo-bar'
  31176. *
  31177. * _.kebabCase('fooBar');
  31178. * // => 'foo-bar'
  31179. *
  31180. * _.kebabCase('__FOO_BAR__');
  31181. * // => 'foo-bar'
  31182. */
  31183. var kebabCase = createCompounder(function(result, word, index) {
  31184. return result + (index ? '-' : '') + word.toLowerCase();
  31185. });
  31186. /**
  31187. * Converts `string`, as space separated words, to lower case.
  31188. *
  31189. * @static
  31190. * @memberOf _
  31191. * @since 4.0.0
  31192. * @category String
  31193. * @param {string} [string=''] The string to convert.
  31194. * @returns {string} Returns the lower cased string.
  31195. * @example
  31196. *
  31197. * _.lowerCase('--Foo-Bar--');
  31198. * // => 'foo bar'
  31199. *
  31200. * _.lowerCase('fooBar');
  31201. * // => 'foo bar'
  31202. *
  31203. * _.lowerCase('__FOO_BAR__');
  31204. * // => 'foo bar'
  31205. */
  31206. var lowerCase = createCompounder(function(result, word, index) {
  31207. return result + (index ? ' ' : '') + word.toLowerCase();
  31208. });
  31209. /**
  31210. * Converts the first character of `string` to lower case.
  31211. *
  31212. * @static
  31213. * @memberOf _
  31214. * @since 4.0.0
  31215. * @category String
  31216. * @param {string} [string=''] The string to convert.
  31217. * @returns {string} Returns the converted string.
  31218. * @example
  31219. *
  31220. * _.lowerFirst('Fred');
  31221. * // => 'fred'
  31222. *
  31223. * _.lowerFirst('FRED');
  31224. * // => 'fRED'
  31225. */
  31226. var lowerFirst = createCaseFirst('toLowerCase');
  31227. /**
  31228. * Pads `string` on the left and right sides if it's shorter than `length`.
  31229. * Padding characters are truncated if they can't be evenly divided by `length`.
  31230. *
  31231. * @static
  31232. * @memberOf _
  31233. * @since 3.0.0
  31234. * @category String
  31235. * @param {string} [string=''] The string to pad.
  31236. * @param {number} [length=0] The padding length.
  31237. * @param {string} [chars=' '] The string used as padding.
  31238. * @returns {string} Returns the padded string.
  31239. * @example
  31240. *
  31241. * _.pad('abc', 8);
  31242. * // => ' abc '
  31243. *
  31244. * _.pad('abc', 8, '_-');
  31245. * // => '_-abc_-_'
  31246. *
  31247. * _.pad('abc', 3);
  31248. * // => 'abc'
  31249. */
  31250. function pad(string, length, chars) {
  31251. string = toString(string);
  31252. length = toInteger(length);
  31253. var strLength = length ? stringSize(string) : 0;
  31254. if (!length || strLength >= length) {
  31255. return string;
  31256. }
  31257. var mid = (length - strLength) / 2;
  31258. return (
  31259. createPadding(nativeFloor(mid), chars) +
  31260. string +
  31261. createPadding(nativeCeil(mid), chars)
  31262. );
  31263. }
  31264. /**
  31265. * Pads `string` on the right side if it's shorter than `length`. Padding
  31266. * characters are truncated if they exceed `length`.
  31267. *
  31268. * @static
  31269. * @memberOf _
  31270. * @since 4.0.0
  31271. * @category String
  31272. * @param {string} [string=''] The string to pad.
  31273. * @param {number} [length=0] The padding length.
  31274. * @param {string} [chars=' '] The string used as padding.
  31275. * @returns {string} Returns the padded string.
  31276. * @example
  31277. *
  31278. * _.padEnd('abc', 6);
  31279. * // => 'abc '
  31280. *
  31281. * _.padEnd('abc', 6, '_-');
  31282. * // => 'abc_-_'
  31283. *
  31284. * _.padEnd('abc', 3);
  31285. * // => 'abc'
  31286. */
  31287. function padEnd(string, length, chars) {
  31288. string = toString(string);
  31289. length = toInteger(length);
  31290. var strLength = length ? stringSize(string) : 0;
  31291. return (length && strLength < length)
  31292. ? (string + createPadding(length - strLength, chars))
  31293. : string;
  31294. }
  31295. /**
  31296. * Pads `string` on the left side if it's shorter than `length`. Padding
  31297. * characters are truncated if they exceed `length`.
  31298. *
  31299. * @static
  31300. * @memberOf _
  31301. * @since 4.0.0
  31302. * @category String
  31303. * @param {string} [string=''] The string to pad.
  31304. * @param {number} [length=0] The padding length.
  31305. * @param {string} [chars=' '] The string used as padding.
  31306. * @returns {string} Returns the padded string.
  31307. * @example
  31308. *
  31309. * _.padStart('abc', 6);
  31310. * // => ' abc'
  31311. *
  31312. * _.padStart('abc', 6, '_-');
  31313. * // => '_-_abc'
  31314. *
  31315. * _.padStart('abc', 3);
  31316. * // => 'abc'
  31317. */
  31318. function padStart(string, length, chars) {
  31319. string = toString(string);
  31320. length = toInteger(length);
  31321. var strLength = length ? stringSize(string) : 0;
  31322. return (length && strLength < length)
  31323. ? (createPadding(length - strLength, chars) + string)
  31324. : string;
  31325. }
  31326. /**
  31327. * Converts `string` to an integer of the specified radix. If `radix` is
  31328. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  31329. * hexadecimal, in which case a `radix` of `16` is used.
  31330. *
  31331. * **Note:** This method aligns with the
  31332. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  31333. *
  31334. * @static
  31335. * @memberOf _
  31336. * @since 1.1.0
  31337. * @category String
  31338. * @param {string} string The string to convert.
  31339. * @param {number} [radix=10] The radix to interpret `value` by.
  31340. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31341. * @returns {number} Returns the converted integer.
  31342. * @example
  31343. *
  31344. * _.parseInt('08');
  31345. * // => 8
  31346. *
  31347. * _.map(['6', '08', '10'], _.parseInt);
  31348. * // => [6, 8, 10]
  31349. */
  31350. function parseInt(string, radix, guard) {
  31351. if (guard || radix == null) {
  31352. radix = 0;
  31353. } else if (radix) {
  31354. radix = +radix;
  31355. }
  31356. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  31357. }
  31358. /**
  31359. * Repeats the given string `n` times.
  31360. *
  31361. * @static
  31362. * @memberOf _
  31363. * @since 3.0.0
  31364. * @category String
  31365. * @param {string} [string=''] The string to repeat.
  31366. * @param {number} [n=1] The number of times to repeat the string.
  31367. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31368. * @returns {string} Returns the repeated string.
  31369. * @example
  31370. *
  31371. * _.repeat('*', 3);
  31372. * // => '***'
  31373. *
  31374. * _.repeat('abc', 2);
  31375. * // => 'abcabc'
  31376. *
  31377. * _.repeat('abc', 0);
  31378. * // => ''
  31379. */
  31380. function repeat(string, n, guard) {
  31381. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  31382. n = 1;
  31383. } else {
  31384. n = toInteger(n);
  31385. }
  31386. return baseRepeat(toString(string), n);
  31387. }
  31388. /**
  31389. * Replaces matches for `pattern` in `string` with `replacement`.
  31390. *
  31391. * **Note:** This method is based on
  31392. * [`String#replace`](https://mdn.io/String/replace).
  31393. *
  31394. * @static
  31395. * @memberOf _
  31396. * @since 4.0.0
  31397. * @category String
  31398. * @param {string} [string=''] The string to modify.
  31399. * @param {RegExp|string} pattern The pattern to replace.
  31400. * @param {Function|string} replacement The match replacement.
  31401. * @returns {string} Returns the modified string.
  31402. * @example
  31403. *
  31404. * _.replace('Hi Fred', 'Fred', 'Barney');
  31405. * // => 'Hi Barney'
  31406. */
  31407. function replace() {
  31408. var args = arguments,
  31409. string = toString(args[0]);
  31410. return args.length < 3 ? string : string.replace(args[1], args[2]);
  31411. }
  31412. /**
  31413. * Converts `string` to
  31414. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  31415. *
  31416. * @static
  31417. * @memberOf _
  31418. * @since 3.0.0
  31419. * @category String
  31420. * @param {string} [string=''] The string to convert.
  31421. * @returns {string} Returns the snake cased string.
  31422. * @example
  31423. *
  31424. * _.snakeCase('Foo Bar');
  31425. * // => 'foo_bar'
  31426. *
  31427. * _.snakeCase('fooBar');
  31428. * // => 'foo_bar'
  31429. *
  31430. * _.snakeCase('--FOO-BAR--');
  31431. * // => 'foo_bar'
  31432. */
  31433. var snakeCase = createCompounder(function(result, word, index) {
  31434. return result + (index ? '_' : '') + word.toLowerCase();
  31435. });
  31436. /**
  31437. * Splits `string` by `separator`.
  31438. *
  31439. * **Note:** This method is based on
  31440. * [`String#split`](https://mdn.io/String/split).
  31441. *
  31442. * @static
  31443. * @memberOf _
  31444. * @since 4.0.0
  31445. * @category String
  31446. * @param {string} [string=''] The string to split.
  31447. * @param {RegExp|string} separator The separator pattern to split by.
  31448. * @param {number} [limit] The length to truncate results to.
  31449. * @returns {Array} Returns the string segments.
  31450. * @example
  31451. *
  31452. * _.split('a-b-c', '-', 2);
  31453. * // => ['a', 'b']
  31454. */
  31455. function split(string, separator, limit) {
  31456. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  31457. separator = limit = undefined;
  31458. }
  31459. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  31460. if (!limit) {
  31461. return [];
  31462. }
  31463. string = toString(string);
  31464. if (string && (
  31465. typeof separator == 'string' ||
  31466. (separator != null && !isRegExp(separator))
  31467. )) {
  31468. separator = baseToString(separator);
  31469. if (!separator && hasUnicode(string)) {
  31470. return castSlice(stringToArray(string), 0, limit);
  31471. }
  31472. }
  31473. return string.split(separator, limit);
  31474. }
  31475. /**
  31476. * Converts `string` to
  31477. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  31478. *
  31479. * @static
  31480. * @memberOf _
  31481. * @since 3.1.0
  31482. * @category String
  31483. * @param {string} [string=''] The string to convert.
  31484. * @returns {string} Returns the start cased string.
  31485. * @example
  31486. *
  31487. * _.startCase('--foo-bar--');
  31488. * // => 'Foo Bar'
  31489. *
  31490. * _.startCase('fooBar');
  31491. * // => 'Foo Bar'
  31492. *
  31493. * _.startCase('__FOO_BAR__');
  31494. * // => 'FOO BAR'
  31495. */
  31496. var startCase = createCompounder(function(result, word, index) {
  31497. return result + (index ? ' ' : '') + upperFirst(word);
  31498. });
  31499. /**
  31500. * Checks if `string` starts with the given target string.
  31501. *
  31502. * @static
  31503. * @memberOf _
  31504. * @since 3.0.0
  31505. * @category String
  31506. * @param {string} [string=''] The string to inspect.
  31507. * @param {string} [target] The string to search for.
  31508. * @param {number} [position=0] The position to search from.
  31509. * @returns {boolean} Returns `true` if `string` starts with `target`,
  31510. * else `false`.
  31511. * @example
  31512. *
  31513. * _.startsWith('abc', 'a');
  31514. * // => true
  31515. *
  31516. * _.startsWith('abc', 'b');
  31517. * // => false
  31518. *
  31519. * _.startsWith('abc', 'b', 1);
  31520. * // => true
  31521. */
  31522. function startsWith(string, target, position) {
  31523. string = toString(string);
  31524. position = position == null
  31525. ? 0
  31526. : baseClamp(toInteger(position), 0, string.length);
  31527. target = baseToString(target);
  31528. return string.slice(position, position + target.length) == target;
  31529. }
  31530. /**
  31531. * Creates a compiled template function that can interpolate data properties
  31532. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  31533. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  31534. * properties may be accessed as free variables in the template. If a setting
  31535. * object is given, it takes precedence over `_.templateSettings` values.
  31536. *
  31537. * **Note:** In the development build `_.template` utilizes
  31538. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  31539. * for easier debugging.
  31540. *
  31541. * For more information on precompiling templates see
  31542. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  31543. *
  31544. * For more information on Chrome extension sandboxes see
  31545. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  31546. *
  31547. * @static
  31548. * @since 0.1.0
  31549. * @memberOf _
  31550. * @category String
  31551. * @param {string} [string=''] The template string.
  31552. * @param {Object} [options={}] The options object.
  31553. * @param {RegExp} [options.escape=_.templateSettings.escape]
  31554. * The HTML "escape" delimiter.
  31555. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  31556. * The "evaluate" delimiter.
  31557. * @param {Object} [options.imports=_.templateSettings.imports]
  31558. * An object to import into the template as free variables.
  31559. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  31560. * The "interpolate" delimiter.
  31561. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  31562. * The sourceURL of the compiled template.
  31563. * @param {string} [options.variable='obj']
  31564. * The data object variable name.
  31565. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31566. * @returns {Function} Returns the compiled template function.
  31567. * @example
  31568. *
  31569. * // Use the "interpolate" delimiter to create a compiled template.
  31570. * var compiled = _.template('hello <%= user %>!');
  31571. * compiled({ 'user': 'fred' });
  31572. * // => 'hello fred!'
  31573. *
  31574. * // Use the HTML "escape" delimiter to escape data property values.
  31575. * var compiled = _.template('<b><%- value %></b>');
  31576. * compiled({ 'value': '<script>' });
  31577. * // => '<b>&lt;script&gt;</b>'
  31578. *
  31579. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  31580. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  31581. * compiled({ 'users': ['fred', 'barney'] });
  31582. * // => '<li>fred</li><li>barney</li>'
  31583. *
  31584. * // Use the internal `print` function in "evaluate" delimiters.
  31585. * var compiled = _.template('<% print("hello " + user); %>!');
  31586. * compiled({ 'user': 'barney' });
  31587. * // => 'hello barney!'
  31588. *
  31589. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  31590. * // Disable support by replacing the "interpolate" delimiter.
  31591. * var compiled = _.template('hello ${ user }!');
  31592. * compiled({ 'user': 'pebbles' });
  31593. * // => 'hello pebbles!'
  31594. *
  31595. * // Use backslashes to treat delimiters as plain text.
  31596. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  31597. * compiled({ 'value': 'ignored' });
  31598. * // => '<%- value %>'
  31599. *
  31600. * // Use the `imports` option to import `jQuery` as `jq`.
  31601. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  31602. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  31603. * compiled({ 'users': ['fred', 'barney'] });
  31604. * // => '<li>fred</li><li>barney</li>'
  31605. *
  31606. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  31607. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  31608. * compiled(data);
  31609. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  31610. *
  31611. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  31612. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  31613. * compiled.source;
  31614. * // => function(data) {
  31615. * // var __t, __p = '';
  31616. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  31617. * // return __p;
  31618. * // }
  31619. *
  31620. * // Use custom template delimiters.
  31621. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  31622. * var compiled = _.template('hello {{ user }}!');
  31623. * compiled({ 'user': 'mustache' });
  31624. * // => 'hello mustache!'
  31625. *
  31626. * // Use the `source` property to inline compiled templates for meaningful
  31627. * // line numbers in error messages and stack traces.
  31628. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  31629. * var JST = {\
  31630. * "main": ' + _.template(mainText).source + '\
  31631. * };\
  31632. * ');
  31633. */
  31634. function template(string, options, guard) {
  31635. // Based on John Resig's `tmpl` implementation
  31636. // (http://ejohn.org/blog/javascript-micro-templating/)
  31637. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  31638. var settings = lodash.templateSettings;
  31639. if (guard && isIterateeCall(string, options, guard)) {
  31640. options = undefined;
  31641. }
  31642. string = toString(string);
  31643. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  31644. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  31645. importsKeys = keys(imports),
  31646. importsValues = baseValues(imports, importsKeys);
  31647. var isEscaping,
  31648. isEvaluating,
  31649. index = 0,
  31650. interpolate = options.interpolate || reNoMatch,
  31651. source = "__p += '";
  31652. // Compile the regexp to match each delimiter.
  31653. var reDelimiters = RegExp(
  31654. (options.escape || reNoMatch).source + '|' +
  31655. interpolate.source + '|' +
  31656. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  31657. (options.evaluate || reNoMatch).source + '|$'
  31658. , 'g');
  31659. // Use a sourceURL for easier debugging.
  31660. // The sourceURL gets injected into the source that's eval-ed, so be careful
  31661. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  31662. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  31663. var sourceURL = '//# sourceURL=' +
  31664. (hasOwnProperty.call(options, 'sourceURL')
  31665. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  31666. : ('lodash.templateSources[' + (++templateCounter) + ']')
  31667. ) + '\n';
  31668. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  31669. interpolateValue || (interpolateValue = esTemplateValue);
  31670. // Escape characters that can't be included in string literals.
  31671. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  31672. // Replace delimiters with snippets.
  31673. if (escapeValue) {
  31674. isEscaping = true;
  31675. source += "' +\n__e(" + escapeValue + ") +\n'";
  31676. }
  31677. if (evaluateValue) {
  31678. isEvaluating = true;
  31679. source += "';\n" + evaluateValue + ";\n__p += '";
  31680. }
  31681. if (interpolateValue) {
  31682. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  31683. }
  31684. index = offset + match.length;
  31685. // The JS engine embedded in Adobe products needs `match` returned in
  31686. // order to produce the correct `offset` value.
  31687. return match;
  31688. });
  31689. source += "';\n";
  31690. // If `variable` is not specified wrap a with-statement around the generated
  31691. // code to add the data object to the top of the scope chain.
  31692. // Like with sourceURL, we take care to not check the option's prototype,
  31693. // as this configuration is a code injection vector.
  31694. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  31695. if (!variable) {
  31696. source = 'with (obj) {\n' + source + '\n}\n';
  31697. }
  31698. // Cleanup code by stripping empty strings.
  31699. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  31700. .replace(reEmptyStringMiddle, '$1')
  31701. .replace(reEmptyStringTrailing, '$1;');
  31702. // Frame code as the function body.
  31703. source = 'function(' + (variable || 'obj') + ') {\n' +
  31704. (variable
  31705. ? ''
  31706. : 'obj || (obj = {});\n'
  31707. ) +
  31708. "var __t, __p = ''" +
  31709. (isEscaping
  31710. ? ', __e = _.escape'
  31711. : ''
  31712. ) +
  31713. (isEvaluating
  31714. ? ', __j = Array.prototype.join;\n' +
  31715. "function print() { __p += __j.call(arguments, '') }\n"
  31716. : ';\n'
  31717. ) +
  31718. source +
  31719. 'return __p\n}';
  31720. var result = attempt(function() {
  31721. return Function(importsKeys, sourceURL + 'return ' + source)
  31722. .apply(undefined, importsValues);
  31723. });
  31724. // Provide the compiled function's source by its `toString` method or
  31725. // the `source` property as a convenience for inlining compiled templates.
  31726. result.source = source;
  31727. if (isError(result)) {
  31728. throw result;
  31729. }
  31730. return result;
  31731. }
  31732. /**
  31733. * Converts `string`, as a whole, to lower case just like
  31734. * [String#toLowerCase](https://mdn.io/toLowerCase).
  31735. *
  31736. * @static
  31737. * @memberOf _
  31738. * @since 4.0.0
  31739. * @category String
  31740. * @param {string} [string=''] The string to convert.
  31741. * @returns {string} Returns the lower cased string.
  31742. * @example
  31743. *
  31744. * _.toLower('--Foo-Bar--');
  31745. * // => '--foo-bar--'
  31746. *
  31747. * _.toLower('fooBar');
  31748. * // => 'foobar'
  31749. *
  31750. * _.toLower('__FOO_BAR__');
  31751. * // => '__foo_bar__'
  31752. */
  31753. function toLower(value) {
  31754. return toString(value).toLowerCase();
  31755. }
  31756. /**
  31757. * Converts `string`, as a whole, to upper case just like
  31758. * [String#toUpperCase](https://mdn.io/toUpperCase).
  31759. *
  31760. * @static
  31761. * @memberOf _
  31762. * @since 4.0.0
  31763. * @category String
  31764. * @param {string} [string=''] The string to convert.
  31765. * @returns {string} Returns the upper cased string.
  31766. * @example
  31767. *
  31768. * _.toUpper('--foo-bar--');
  31769. * // => '--FOO-BAR--'
  31770. *
  31771. * _.toUpper('fooBar');
  31772. * // => 'FOOBAR'
  31773. *
  31774. * _.toUpper('__foo_bar__');
  31775. * // => '__FOO_BAR__'
  31776. */
  31777. function toUpper(value) {
  31778. return toString(value).toUpperCase();
  31779. }
  31780. /**
  31781. * Removes leading and trailing whitespace or specified characters from `string`.
  31782. *
  31783. * @static
  31784. * @memberOf _
  31785. * @since 3.0.0
  31786. * @category String
  31787. * @param {string} [string=''] The string to trim.
  31788. * @param {string} [chars=whitespace] The characters to trim.
  31789. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31790. * @returns {string} Returns the trimmed string.
  31791. * @example
  31792. *
  31793. * _.trim(' abc ');
  31794. * // => 'abc'
  31795. *
  31796. * _.trim('-_-abc-_-', '_-');
  31797. * // => 'abc'
  31798. *
  31799. * _.map([' foo ', ' bar '], _.trim);
  31800. * // => ['foo', 'bar']
  31801. */
  31802. function trim(string, chars, guard) {
  31803. string = toString(string);
  31804. if (string && (guard || chars === undefined)) {
  31805. return string.replace(reTrim, '');
  31806. }
  31807. if (!string || !(chars = baseToString(chars))) {
  31808. return string;
  31809. }
  31810. var strSymbols = stringToArray(string),
  31811. chrSymbols = stringToArray(chars),
  31812. start = charsStartIndex(strSymbols, chrSymbols),
  31813. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  31814. return castSlice(strSymbols, start, end).join('');
  31815. }
  31816. /**
  31817. * Removes trailing whitespace or specified characters from `string`.
  31818. *
  31819. * @static
  31820. * @memberOf _
  31821. * @since 4.0.0
  31822. * @category String
  31823. * @param {string} [string=''] The string to trim.
  31824. * @param {string} [chars=whitespace] The characters to trim.
  31825. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31826. * @returns {string} Returns the trimmed string.
  31827. * @example
  31828. *
  31829. * _.trimEnd(' abc ');
  31830. * // => ' abc'
  31831. *
  31832. * _.trimEnd('-_-abc-_-', '_-');
  31833. * // => '-_-abc'
  31834. */
  31835. function trimEnd(string, chars, guard) {
  31836. string = toString(string);
  31837. if (string && (guard || chars === undefined)) {
  31838. return string.replace(reTrimEnd, '');
  31839. }
  31840. if (!string || !(chars = baseToString(chars))) {
  31841. return string;
  31842. }
  31843. var strSymbols = stringToArray(string),
  31844. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  31845. return castSlice(strSymbols, 0, end).join('');
  31846. }
  31847. /**
  31848. * Removes leading whitespace or specified characters from `string`.
  31849. *
  31850. * @static
  31851. * @memberOf _
  31852. * @since 4.0.0
  31853. * @category String
  31854. * @param {string} [string=''] The string to trim.
  31855. * @param {string} [chars=whitespace] The characters to trim.
  31856. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31857. * @returns {string} Returns the trimmed string.
  31858. * @example
  31859. *
  31860. * _.trimStart(' abc ');
  31861. * // => 'abc '
  31862. *
  31863. * _.trimStart('-_-abc-_-', '_-');
  31864. * // => 'abc-_-'
  31865. */
  31866. function trimStart(string, chars, guard) {
  31867. string = toString(string);
  31868. if (string && (guard || chars === undefined)) {
  31869. return string.replace(reTrimStart, '');
  31870. }
  31871. if (!string || !(chars = baseToString(chars))) {
  31872. return string;
  31873. }
  31874. var strSymbols = stringToArray(string),
  31875. start = charsStartIndex(strSymbols, stringToArray(chars));
  31876. return castSlice(strSymbols, start).join('');
  31877. }
  31878. /**
  31879. * Truncates `string` if it's longer than the given maximum string length.
  31880. * The last characters of the truncated string are replaced with the omission
  31881. * string which defaults to "...".
  31882. *
  31883. * @static
  31884. * @memberOf _
  31885. * @since 4.0.0
  31886. * @category String
  31887. * @param {string} [string=''] The string to truncate.
  31888. * @param {Object} [options={}] The options object.
  31889. * @param {number} [options.length=30] The maximum string length.
  31890. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  31891. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  31892. * @returns {string} Returns the truncated string.
  31893. * @example
  31894. *
  31895. * _.truncate('hi-diddly-ho there, neighborino');
  31896. * // => 'hi-diddly-ho there, neighbo...'
  31897. *
  31898. * _.truncate('hi-diddly-ho there, neighborino', {
  31899. * 'length': 24,
  31900. * 'separator': ' '
  31901. * });
  31902. * // => 'hi-diddly-ho there,...'
  31903. *
  31904. * _.truncate('hi-diddly-ho there, neighborino', {
  31905. * 'length': 24,
  31906. * 'separator': /,? +/
  31907. * });
  31908. * // => 'hi-diddly-ho there...'
  31909. *
  31910. * _.truncate('hi-diddly-ho there, neighborino', {
  31911. * 'omission': ' [...]'
  31912. * });
  31913. * // => 'hi-diddly-ho there, neig [...]'
  31914. */
  31915. function truncate(string, options) {
  31916. var length = DEFAULT_TRUNC_LENGTH,
  31917. omission = DEFAULT_TRUNC_OMISSION;
  31918. if (isObject(options)) {
  31919. var separator = 'separator' in options ? options.separator : separator;
  31920. length = 'length' in options ? toInteger(options.length) : length;
  31921. omission = 'omission' in options ? baseToString(options.omission) : omission;
  31922. }
  31923. string = toString(string);
  31924. var strLength = string.length;
  31925. if (hasUnicode(string)) {
  31926. var strSymbols = stringToArray(string);
  31927. strLength = strSymbols.length;
  31928. }
  31929. if (length >= strLength) {
  31930. return string;
  31931. }
  31932. var end = length - stringSize(omission);
  31933. if (end < 1) {
  31934. return omission;
  31935. }
  31936. var result = strSymbols
  31937. ? castSlice(strSymbols, 0, end).join('')
  31938. : string.slice(0, end);
  31939. if (separator === undefined) {
  31940. return result + omission;
  31941. }
  31942. if (strSymbols) {
  31943. end += (result.length - end);
  31944. }
  31945. if (isRegExp(separator)) {
  31946. if (string.slice(end).search(separator)) {
  31947. var match,
  31948. substring = result;
  31949. if (!separator.global) {
  31950. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  31951. }
  31952. separator.lastIndex = 0;
  31953. while ((match = separator.exec(substring))) {
  31954. var newEnd = match.index;
  31955. }
  31956. result = result.slice(0, newEnd === undefined ? end : newEnd);
  31957. }
  31958. } else if (string.indexOf(baseToString(separator), end) != end) {
  31959. var index = result.lastIndexOf(separator);
  31960. if (index > -1) {
  31961. result = result.slice(0, index);
  31962. }
  31963. }
  31964. return result + omission;
  31965. }
  31966. /**
  31967. * The inverse of `_.escape`; this method converts the HTML entities
  31968. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  31969. * their corresponding characters.
  31970. *
  31971. * **Note:** No other HTML entities are unescaped. To unescape additional
  31972. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  31973. *
  31974. * @static
  31975. * @memberOf _
  31976. * @since 0.6.0
  31977. * @category String
  31978. * @param {string} [string=''] The string to unescape.
  31979. * @returns {string} Returns the unescaped string.
  31980. * @example
  31981. *
  31982. * _.unescape('fred, barney, &amp; pebbles');
  31983. * // => 'fred, barney, & pebbles'
  31984. */
  31985. function unescape(string) {
  31986. string = toString(string);
  31987. return (string && reHasEscapedHtml.test(string))
  31988. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  31989. : string;
  31990. }
  31991. /**
  31992. * Converts `string`, as space separated words, to upper case.
  31993. *
  31994. * @static
  31995. * @memberOf _
  31996. * @since 4.0.0
  31997. * @category String
  31998. * @param {string} [string=''] The string to convert.
  31999. * @returns {string} Returns the upper cased string.
  32000. * @example
  32001. *
  32002. * _.upperCase('--foo-bar');
  32003. * // => 'FOO BAR'
  32004. *
  32005. * _.upperCase('fooBar');
  32006. * // => 'FOO BAR'
  32007. *
  32008. * _.upperCase('__foo_bar__');
  32009. * // => 'FOO BAR'
  32010. */
  32011. var upperCase = createCompounder(function(result, word, index) {
  32012. return result + (index ? ' ' : '') + word.toUpperCase();
  32013. });
  32014. /**
  32015. * Converts the first character of `string` to upper case.
  32016. *
  32017. * @static
  32018. * @memberOf _
  32019. * @since 4.0.0
  32020. * @category String
  32021. * @param {string} [string=''] The string to convert.
  32022. * @returns {string} Returns the converted string.
  32023. * @example
  32024. *
  32025. * _.upperFirst('fred');
  32026. * // => 'Fred'
  32027. *
  32028. * _.upperFirst('FRED');
  32029. * // => 'FRED'
  32030. */
  32031. var upperFirst = createCaseFirst('toUpperCase');
  32032. /**
  32033. * Splits `string` into an array of its words.
  32034. *
  32035. * @static
  32036. * @memberOf _
  32037. * @since 3.0.0
  32038. * @category String
  32039. * @param {string} [string=''] The string to inspect.
  32040. * @param {RegExp|string} [pattern] The pattern to match words.
  32041. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  32042. * @returns {Array} Returns the words of `string`.
  32043. * @example
  32044. *
  32045. * _.words('fred, barney, & pebbles');
  32046. * // => ['fred', 'barney', 'pebbles']
  32047. *
  32048. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  32049. * // => ['fred', 'barney', '&', 'pebbles']
  32050. */
  32051. function words(string, pattern, guard) {
  32052. string = toString(string);
  32053. pattern = guard ? undefined : pattern;
  32054. if (pattern === undefined) {
  32055. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  32056. }
  32057. return string.match(pattern) || [];
  32058. }
  32059. /*------------------------------------------------------------------------*/
  32060. /**
  32061. * Attempts to invoke `func`, returning either the result or the caught error
  32062. * object. Any additional arguments are provided to `func` when it's invoked.
  32063. *
  32064. * @static
  32065. * @memberOf _
  32066. * @since 3.0.0
  32067. * @category Util
  32068. * @param {Function} func The function to attempt.
  32069. * @param {...*} [args] The arguments to invoke `func` with.
  32070. * @returns {*} Returns the `func` result or error object.
  32071. * @example
  32072. *
  32073. * // Avoid throwing errors for invalid selectors.
  32074. * var elements = _.attempt(function(selector) {
  32075. * return document.querySelectorAll(selector);
  32076. * }, '>_>');
  32077. *
  32078. * if (_.isError(elements)) {
  32079. * elements = [];
  32080. * }
  32081. */
  32082. var attempt = baseRest(function(func, args) {
  32083. try {
  32084. return apply(func, undefined, args);
  32085. } catch (e) {
  32086. return isError(e) ? e : new Error(e);
  32087. }
  32088. });
  32089. /**
  32090. * Binds methods of an object to the object itself, overwriting the existing
  32091. * method.
  32092. *
  32093. * **Note:** This method doesn't set the "length" property of bound functions.
  32094. *
  32095. * @static
  32096. * @since 0.1.0
  32097. * @memberOf _
  32098. * @category Util
  32099. * @param {Object} object The object to bind and assign the bound methods to.
  32100. * @param {...(string|string[])} methodNames The object method names to bind.
  32101. * @returns {Object} Returns `object`.
  32102. * @example
  32103. *
  32104. * var view = {
  32105. * 'label': 'docs',
  32106. * 'click': function() {
  32107. * console.log('clicked ' + this.label);
  32108. * }
  32109. * };
  32110. *
  32111. * _.bindAll(view, ['click']);
  32112. * jQuery(element).on('click', view.click);
  32113. * // => Logs 'clicked docs' when clicked.
  32114. */
  32115. var bindAll = flatRest(function(object, methodNames) {
  32116. arrayEach(methodNames, function(key) {
  32117. key = toKey(key);
  32118. baseAssignValue(object, key, bind(object[key], object));
  32119. });
  32120. return object;
  32121. });
  32122. /**
  32123. * Creates a function that iterates over `pairs` and invokes the corresponding
  32124. * function of the first predicate to return truthy. The predicate-function
  32125. * pairs are invoked with the `this` binding and arguments of the created
  32126. * function.
  32127. *
  32128. * @static
  32129. * @memberOf _
  32130. * @since 4.0.0
  32131. * @category Util
  32132. * @param {Array} pairs The predicate-function pairs.
  32133. * @returns {Function} Returns the new composite function.
  32134. * @example
  32135. *
  32136. * var func = _.cond([
  32137. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  32138. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  32139. * [_.stubTrue, _.constant('no match')]
  32140. * ]);
  32141. *
  32142. * func({ 'a': 1, 'b': 2 });
  32143. * // => 'matches A'
  32144. *
  32145. * func({ 'a': 0, 'b': 1 });
  32146. * // => 'matches B'
  32147. *
  32148. * func({ 'a': '1', 'b': '2' });
  32149. * // => 'no match'
  32150. */
  32151. function cond(pairs) {
  32152. var length = pairs == null ? 0 : pairs.length,
  32153. toIteratee = getIteratee();
  32154. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  32155. if (typeof pair[1] != 'function') {
  32156. throw new TypeError(FUNC_ERROR_TEXT);
  32157. }
  32158. return [toIteratee(pair[0]), pair[1]];
  32159. });
  32160. return baseRest(function(args) {
  32161. var index = -1;
  32162. while (++index < length) {
  32163. var pair = pairs[index];
  32164. if (apply(pair[0], this, args)) {
  32165. return apply(pair[1], this, args);
  32166. }
  32167. }
  32168. });
  32169. }
  32170. /**
  32171. * Creates a function that invokes the predicate properties of `source` with
  32172. * the corresponding property values of a given object, returning `true` if
  32173. * all predicates return truthy, else `false`.
  32174. *
  32175. * **Note:** The created function is equivalent to `_.conformsTo` with
  32176. * `source` partially applied.
  32177. *
  32178. * @static
  32179. * @memberOf _
  32180. * @since 4.0.0
  32181. * @category Util
  32182. * @param {Object} source The object of property predicates to conform to.
  32183. * @returns {Function} Returns the new spec function.
  32184. * @example
  32185. *
  32186. * var objects = [
  32187. * { 'a': 2, 'b': 1 },
  32188. * { 'a': 1, 'b': 2 }
  32189. * ];
  32190. *
  32191. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  32192. * // => [{ 'a': 1, 'b': 2 }]
  32193. */
  32194. function conforms(source) {
  32195. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  32196. }
  32197. /**
  32198. * Creates a function that returns `value`.
  32199. *
  32200. * @static
  32201. * @memberOf _
  32202. * @since 2.4.0
  32203. * @category Util
  32204. * @param {*} value The value to return from the new function.
  32205. * @returns {Function} Returns the new constant function.
  32206. * @example
  32207. *
  32208. * var objects = _.times(2, _.constant({ 'a': 1 }));
  32209. *
  32210. * console.log(objects);
  32211. * // => [{ 'a': 1 }, { 'a': 1 }]
  32212. *
  32213. * console.log(objects[0] === objects[1]);
  32214. * // => true
  32215. */
  32216. function constant(value) {
  32217. return function() {
  32218. return value;
  32219. };
  32220. }
  32221. /**
  32222. * Checks `value` to determine whether a default value should be returned in
  32223. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  32224. * or `undefined`.
  32225. *
  32226. * @static
  32227. * @memberOf _
  32228. * @since 4.14.0
  32229. * @category Util
  32230. * @param {*} value The value to check.
  32231. * @param {*} defaultValue The default value.
  32232. * @returns {*} Returns the resolved value.
  32233. * @example
  32234. *
  32235. * _.defaultTo(1, 10);
  32236. * // => 1
  32237. *
  32238. * _.defaultTo(undefined, 10);
  32239. * // => 10
  32240. */
  32241. function defaultTo(value, defaultValue) {
  32242. return (value == null || value !== value) ? defaultValue : value;
  32243. }
  32244. /**
  32245. * Creates a function that returns the result of invoking the given functions
  32246. * with the `this` binding of the created function, where each successive
  32247. * invocation is supplied the return value of the previous.
  32248. *
  32249. * @static
  32250. * @memberOf _
  32251. * @since 3.0.0
  32252. * @category Util
  32253. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32254. * @returns {Function} Returns the new composite function.
  32255. * @see _.flowRight
  32256. * @example
  32257. *
  32258. * function square(n) {
  32259. * return n * n;
  32260. * }
  32261. *
  32262. * var addSquare = _.flow([_.add, square]);
  32263. * addSquare(1, 2);
  32264. * // => 9
  32265. */
  32266. var flow = createFlow();
  32267. /**
  32268. * This method is like `_.flow` except that it creates a function that
  32269. * invokes the given functions from right to left.
  32270. *
  32271. * @static
  32272. * @since 3.0.0
  32273. * @memberOf _
  32274. * @category Util
  32275. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32276. * @returns {Function} Returns the new composite function.
  32277. * @see _.flow
  32278. * @example
  32279. *
  32280. * function square(n) {
  32281. * return n * n;
  32282. * }
  32283. *
  32284. * var addSquare = _.flowRight([square, _.add]);
  32285. * addSquare(1, 2);
  32286. * // => 9
  32287. */
  32288. var flowRight = createFlow(true);
  32289. /**
  32290. * This method returns the first argument it receives.
  32291. *
  32292. * @static
  32293. * @since 0.1.0
  32294. * @memberOf _
  32295. * @category Util
  32296. * @param {*} value Any value.
  32297. * @returns {*} Returns `value`.
  32298. * @example
  32299. *
  32300. * var object = { 'a': 1 };
  32301. *
  32302. * console.log(_.identity(object) === object);
  32303. * // => true
  32304. */
  32305. function identity(value) {
  32306. return value;
  32307. }
  32308. /**
  32309. * Creates a function that invokes `func` with the arguments of the created
  32310. * function. If `func` is a property name, the created function returns the
  32311. * property value for a given element. If `func` is an array or object, the
  32312. * created function returns `true` for elements that contain the equivalent
  32313. * source properties, otherwise it returns `false`.
  32314. *
  32315. * @static
  32316. * @since 4.0.0
  32317. * @memberOf _
  32318. * @category Util
  32319. * @param {*} [func=_.identity] The value to convert to a callback.
  32320. * @returns {Function} Returns the callback.
  32321. * @example
  32322. *
  32323. * var users = [
  32324. * { 'user': 'barney', 'age': 36, 'active': true },
  32325. * { 'user': 'fred', 'age': 40, 'active': false }
  32326. * ];
  32327. *
  32328. * // The `_.matches` iteratee shorthand.
  32329. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  32330. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  32331. *
  32332. * // The `_.matchesProperty` iteratee shorthand.
  32333. * _.filter(users, _.iteratee(['user', 'fred']));
  32334. * // => [{ 'user': 'fred', 'age': 40 }]
  32335. *
  32336. * // The `_.property` iteratee shorthand.
  32337. * _.map(users, _.iteratee('user'));
  32338. * // => ['barney', 'fred']
  32339. *
  32340. * // Create custom iteratee shorthands.
  32341. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  32342. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  32343. * return func.test(string);
  32344. * };
  32345. * });
  32346. *
  32347. * _.filter(['abc', 'def'], /ef/);
  32348. * // => ['def']
  32349. */
  32350. function iteratee(func) {
  32351. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  32352. }
  32353. /**
  32354. * Creates a function that performs a partial deep comparison between a given
  32355. * object and `source`, returning `true` if the given object has equivalent
  32356. * property values, else `false`.
  32357. *
  32358. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  32359. * partially applied.
  32360. *
  32361. * Partial comparisons will match empty array and empty object `source`
  32362. * values against any array or object value, respectively. See `_.isEqual`
  32363. * for a list of supported value comparisons.
  32364. *
  32365. * @static
  32366. * @memberOf _
  32367. * @since 3.0.0
  32368. * @category Util
  32369. * @param {Object} source The object of property values to match.
  32370. * @returns {Function} Returns the new spec function.
  32371. * @example
  32372. *
  32373. * var objects = [
  32374. * { 'a': 1, 'b': 2, 'c': 3 },
  32375. * { 'a': 4, 'b': 5, 'c': 6 }
  32376. * ];
  32377. *
  32378. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  32379. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  32380. */
  32381. function matches(source) {
  32382. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  32383. }
  32384. /**
  32385. * Creates a function that performs a partial deep comparison between the
  32386. * value at `path` of a given object to `srcValue`, returning `true` if the
  32387. * object value is equivalent, else `false`.
  32388. *
  32389. * **Note:** Partial comparisons will match empty array and empty object
  32390. * `srcValue` values against any array or object value, respectively. See
  32391. * `_.isEqual` for a list of supported value comparisons.
  32392. *
  32393. * @static
  32394. * @memberOf _
  32395. * @since 3.2.0
  32396. * @category Util
  32397. * @param {Array|string} path The path of the property to get.
  32398. * @param {*} srcValue The value to match.
  32399. * @returns {Function} Returns the new spec function.
  32400. * @example
  32401. *
  32402. * var objects = [
  32403. * { 'a': 1, 'b': 2, 'c': 3 },
  32404. * { 'a': 4, 'b': 5, 'c': 6 }
  32405. * ];
  32406. *
  32407. * _.find(objects, _.matchesProperty('a', 4));
  32408. * // => { 'a': 4, 'b': 5, 'c': 6 }
  32409. */
  32410. function matchesProperty(path, srcValue) {
  32411. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  32412. }
  32413. /**
  32414. * Creates a function that invokes the method at `path` of a given object.
  32415. * Any additional arguments are provided to the invoked method.
  32416. *
  32417. * @static
  32418. * @memberOf _
  32419. * @since 3.7.0
  32420. * @category Util
  32421. * @param {Array|string} path The path of the method to invoke.
  32422. * @param {...*} [args] The arguments to invoke the method with.
  32423. * @returns {Function} Returns the new invoker function.
  32424. * @example
  32425. *
  32426. * var objects = [
  32427. * { 'a': { 'b': _.constant(2) } },
  32428. * { 'a': { 'b': _.constant(1) } }
  32429. * ];
  32430. *
  32431. * _.map(objects, _.method('a.b'));
  32432. * // => [2, 1]
  32433. *
  32434. * _.map(objects, _.method(['a', 'b']));
  32435. * // => [2, 1]
  32436. */
  32437. var method = baseRest(function(path, args) {
  32438. return function(object) {
  32439. return baseInvoke(object, path, args);
  32440. };
  32441. });
  32442. /**
  32443. * The opposite of `_.method`; this method creates a function that invokes
  32444. * the method at a given path of `object`. Any additional arguments are
  32445. * provided to the invoked method.
  32446. *
  32447. * @static
  32448. * @memberOf _
  32449. * @since 3.7.0
  32450. * @category Util
  32451. * @param {Object} object The object to query.
  32452. * @param {...*} [args] The arguments to invoke the method with.
  32453. * @returns {Function} Returns the new invoker function.
  32454. * @example
  32455. *
  32456. * var array = _.times(3, _.constant),
  32457. * object = { 'a': array, 'b': array, 'c': array };
  32458. *
  32459. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  32460. * // => [2, 0]
  32461. *
  32462. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  32463. * // => [2, 0]
  32464. */
  32465. var methodOf = baseRest(function(object, args) {
  32466. return function(path) {
  32467. return baseInvoke(object, path, args);
  32468. };
  32469. });
  32470. /**
  32471. * Adds all own enumerable string keyed function properties of a source
  32472. * object to the destination object. If `object` is a function, then methods
  32473. * are added to its prototype as well.
  32474. *
  32475. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  32476. * avoid conflicts caused by modifying the original.
  32477. *
  32478. * @static
  32479. * @since 0.1.0
  32480. * @memberOf _
  32481. * @category Util
  32482. * @param {Function|Object} [object=lodash] The destination object.
  32483. * @param {Object} source The object of functions to add.
  32484. * @param {Object} [options={}] The options object.
  32485. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  32486. * @returns {Function|Object} Returns `object`.
  32487. * @example
  32488. *
  32489. * function vowels(string) {
  32490. * return _.filter(string, function(v) {
  32491. * return /[aeiou]/i.test(v);
  32492. * });
  32493. * }
  32494. *
  32495. * _.mixin({ 'vowels': vowels });
  32496. * _.vowels('fred');
  32497. * // => ['e']
  32498. *
  32499. * _('fred').vowels().value();
  32500. * // => ['e']
  32501. *
  32502. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  32503. * _('fred').vowels();
  32504. * // => ['e']
  32505. */
  32506. function mixin(object, source, options) {
  32507. var props = keys(source),
  32508. methodNames = baseFunctions(source, props);
  32509. if (options == null &&
  32510. !(isObject(source) && (methodNames.length || !props.length))) {
  32511. options = source;
  32512. source = object;
  32513. object = this;
  32514. methodNames = baseFunctions(source, keys(source));
  32515. }
  32516. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  32517. isFunc = isFunction(object);
  32518. arrayEach(methodNames, function(methodName) {
  32519. var func = source[methodName];
  32520. object[methodName] = func;
  32521. if (isFunc) {
  32522. object.prototype[methodName] = function() {
  32523. var chainAll = this.__chain__;
  32524. if (chain || chainAll) {
  32525. var result = object(this.__wrapped__),
  32526. actions = result.__actions__ = copyArray(this.__actions__);
  32527. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  32528. result.__chain__ = chainAll;
  32529. return result;
  32530. }
  32531. return func.apply(object, arrayPush([this.value()], arguments));
  32532. };
  32533. }
  32534. });
  32535. return object;
  32536. }
  32537. /**
  32538. * Reverts the `_` variable to its previous value and returns a reference to
  32539. * the `lodash` function.
  32540. *
  32541. * @static
  32542. * @since 0.1.0
  32543. * @memberOf _
  32544. * @category Util
  32545. * @returns {Function} Returns the `lodash` function.
  32546. * @example
  32547. *
  32548. * var lodash = _.noConflict();
  32549. */
  32550. function noConflict() {
  32551. if (root._ === this) {
  32552. root._ = oldDash;
  32553. }
  32554. return this;
  32555. }
  32556. /**
  32557. * This method returns `undefined`.
  32558. *
  32559. * @static
  32560. * @memberOf _
  32561. * @since 2.3.0
  32562. * @category Util
  32563. * @example
  32564. *
  32565. * _.times(2, _.noop);
  32566. * // => [undefined, undefined]
  32567. */
  32568. function noop() {
  32569. // No operation performed.
  32570. }
  32571. /**
  32572. * Creates a function that gets the argument at index `n`. If `n` is negative,
  32573. * the nth argument from the end is returned.
  32574. *
  32575. * @static
  32576. * @memberOf _
  32577. * @since 4.0.0
  32578. * @category Util
  32579. * @param {number} [n=0] The index of the argument to return.
  32580. * @returns {Function} Returns the new pass-thru function.
  32581. * @example
  32582. *
  32583. * var func = _.nthArg(1);
  32584. * func('a', 'b', 'c', 'd');
  32585. * // => 'b'
  32586. *
  32587. * var func = _.nthArg(-2);
  32588. * func('a', 'b', 'c', 'd');
  32589. * // => 'c'
  32590. */
  32591. function nthArg(n) {
  32592. n = toInteger(n);
  32593. return baseRest(function(args) {
  32594. return baseNth(args, n);
  32595. });
  32596. }
  32597. /**
  32598. * Creates a function that invokes `iteratees` with the arguments it receives
  32599. * and returns their results.
  32600. *
  32601. * @static
  32602. * @memberOf _
  32603. * @since 4.0.0
  32604. * @category Util
  32605. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  32606. * The iteratees to invoke.
  32607. * @returns {Function} Returns the new function.
  32608. * @example
  32609. *
  32610. * var func = _.over([Math.max, Math.min]);
  32611. *
  32612. * func(1, 2, 3, 4);
  32613. * // => [4, 1]
  32614. */
  32615. var over = createOver(arrayMap);
  32616. /**
  32617. * Creates a function that checks if **all** of the `predicates` return
  32618. * truthy when invoked with the arguments it receives.
  32619. *
  32620. * @static
  32621. * @memberOf _
  32622. * @since 4.0.0
  32623. * @category Util
  32624. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32625. * The predicates to check.
  32626. * @returns {Function} Returns the new function.
  32627. * @example
  32628. *
  32629. * var func = _.overEvery([Boolean, isFinite]);
  32630. *
  32631. * func('1');
  32632. * // => true
  32633. *
  32634. * func(null);
  32635. * // => false
  32636. *
  32637. * func(NaN);
  32638. * // => false
  32639. */
  32640. var overEvery = createOver(arrayEvery);
  32641. /**
  32642. * Creates a function that checks if **any** of the `predicates` return
  32643. * truthy when invoked with the arguments it receives.
  32644. *
  32645. * @static
  32646. * @memberOf _
  32647. * @since 4.0.0
  32648. * @category Util
  32649. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32650. * The predicates to check.
  32651. * @returns {Function} Returns the new function.
  32652. * @example
  32653. *
  32654. * var func = _.overSome([Boolean, isFinite]);
  32655. *
  32656. * func('1');
  32657. * // => true
  32658. *
  32659. * func(null);
  32660. * // => true
  32661. *
  32662. * func(NaN);
  32663. * // => false
  32664. */
  32665. var overSome = createOver(arraySome);
  32666. /**
  32667. * Creates a function that returns the value at `path` of a given object.
  32668. *
  32669. * @static
  32670. * @memberOf _
  32671. * @since 2.4.0
  32672. * @category Util
  32673. * @param {Array|string} path The path of the property to get.
  32674. * @returns {Function} Returns the new accessor function.
  32675. * @example
  32676. *
  32677. * var objects = [
  32678. * { 'a': { 'b': 2 } },
  32679. * { 'a': { 'b': 1 } }
  32680. * ];
  32681. *
  32682. * _.map(objects, _.property('a.b'));
  32683. * // => [2, 1]
  32684. *
  32685. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  32686. * // => [1, 2]
  32687. */
  32688. function property(path) {
  32689. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  32690. }
  32691. /**
  32692. * The opposite of `_.property`; this method creates a function that returns
  32693. * the value at a given path of `object`.
  32694. *
  32695. * @static
  32696. * @memberOf _
  32697. * @since 3.0.0
  32698. * @category Util
  32699. * @param {Object} object The object to query.
  32700. * @returns {Function} Returns the new accessor function.
  32701. * @example
  32702. *
  32703. * var array = [0, 1, 2],
  32704. * object = { 'a': array, 'b': array, 'c': array };
  32705. *
  32706. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  32707. * // => [2, 0]
  32708. *
  32709. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  32710. * // => [2, 0]
  32711. */
  32712. function propertyOf(object) {
  32713. return function(path) {
  32714. return object == null ? undefined : baseGet(object, path);
  32715. };
  32716. }
  32717. /**
  32718. * Creates an array of numbers (positive and/or negative) progressing from
  32719. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  32720. * `start` is specified without an `end` or `step`. If `end` is not specified,
  32721. * it's set to `start` with `start` then set to `0`.
  32722. *
  32723. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  32724. * floating-point values which can produce unexpected results.
  32725. *
  32726. * @static
  32727. * @since 0.1.0
  32728. * @memberOf _
  32729. * @category Util
  32730. * @param {number} [start=0] The start of the range.
  32731. * @param {number} end The end of the range.
  32732. * @param {number} [step=1] The value to increment or decrement by.
  32733. * @returns {Array} Returns the range of numbers.
  32734. * @see _.inRange, _.rangeRight
  32735. * @example
  32736. *
  32737. * _.range(4);
  32738. * // => [0, 1, 2, 3]
  32739. *
  32740. * _.range(-4);
  32741. * // => [0, -1, -2, -3]
  32742. *
  32743. * _.range(1, 5);
  32744. * // => [1, 2, 3, 4]
  32745. *
  32746. * _.range(0, 20, 5);
  32747. * // => [0, 5, 10, 15]
  32748. *
  32749. * _.range(0, -4, -1);
  32750. * // => [0, -1, -2, -3]
  32751. *
  32752. * _.range(1, 4, 0);
  32753. * // => [1, 1, 1]
  32754. *
  32755. * _.range(0);
  32756. * // => []
  32757. */
  32758. var range = createRange();
  32759. /**
  32760. * This method is like `_.range` except that it populates values in
  32761. * descending order.
  32762. *
  32763. * @static
  32764. * @memberOf _
  32765. * @since 4.0.0
  32766. * @category Util
  32767. * @param {number} [start=0] The start of the range.
  32768. * @param {number} end The end of the range.
  32769. * @param {number} [step=1] The value to increment or decrement by.
  32770. * @returns {Array} Returns the range of numbers.
  32771. * @see _.inRange, _.range
  32772. * @example
  32773. *
  32774. * _.rangeRight(4);
  32775. * // => [3, 2, 1, 0]
  32776. *
  32777. * _.rangeRight(-4);
  32778. * // => [-3, -2, -1, 0]
  32779. *
  32780. * _.rangeRight(1, 5);
  32781. * // => [4, 3, 2, 1]
  32782. *
  32783. * _.rangeRight(0, 20, 5);
  32784. * // => [15, 10, 5, 0]
  32785. *
  32786. * _.rangeRight(0, -4, -1);
  32787. * // => [-3, -2, -1, 0]
  32788. *
  32789. * _.rangeRight(1, 4, 0);
  32790. * // => [1, 1, 1]
  32791. *
  32792. * _.rangeRight(0);
  32793. * // => []
  32794. */
  32795. var rangeRight = createRange(true);
  32796. /**
  32797. * This method returns a new empty array.
  32798. *
  32799. * @static
  32800. * @memberOf _
  32801. * @since 4.13.0
  32802. * @category Util
  32803. * @returns {Array} Returns the new empty array.
  32804. * @example
  32805. *
  32806. * var arrays = _.times(2, _.stubArray);
  32807. *
  32808. * console.log(arrays);
  32809. * // => [[], []]
  32810. *
  32811. * console.log(arrays[0] === arrays[1]);
  32812. * // => false
  32813. */
  32814. function stubArray() {
  32815. return [];
  32816. }
  32817. /**
  32818. * This method returns `false`.
  32819. *
  32820. * @static
  32821. * @memberOf _
  32822. * @since 4.13.0
  32823. * @category Util
  32824. * @returns {boolean} Returns `false`.
  32825. * @example
  32826. *
  32827. * _.times(2, _.stubFalse);
  32828. * // => [false, false]
  32829. */
  32830. function stubFalse() {
  32831. return false;
  32832. }
  32833. /**
  32834. * This method returns a new empty object.
  32835. *
  32836. * @static
  32837. * @memberOf _
  32838. * @since 4.13.0
  32839. * @category Util
  32840. * @returns {Object} Returns the new empty object.
  32841. * @example
  32842. *
  32843. * var objects = _.times(2, _.stubObject);
  32844. *
  32845. * console.log(objects);
  32846. * // => [{}, {}]
  32847. *
  32848. * console.log(objects[0] === objects[1]);
  32849. * // => false
  32850. */
  32851. function stubObject() {
  32852. return {};
  32853. }
  32854. /**
  32855. * This method returns an empty string.
  32856. *
  32857. * @static
  32858. * @memberOf _
  32859. * @since 4.13.0
  32860. * @category Util
  32861. * @returns {string} Returns the empty string.
  32862. * @example
  32863. *
  32864. * _.times(2, _.stubString);
  32865. * // => ['', '']
  32866. */
  32867. function stubString() {
  32868. return '';
  32869. }
  32870. /**
  32871. * This method returns `true`.
  32872. *
  32873. * @static
  32874. * @memberOf _
  32875. * @since 4.13.0
  32876. * @category Util
  32877. * @returns {boolean} Returns `true`.
  32878. * @example
  32879. *
  32880. * _.times(2, _.stubTrue);
  32881. * // => [true, true]
  32882. */
  32883. function stubTrue() {
  32884. return true;
  32885. }
  32886. /**
  32887. * Invokes the iteratee `n` times, returning an array of the results of
  32888. * each invocation. The iteratee is invoked with one argument; (index).
  32889. *
  32890. * @static
  32891. * @since 0.1.0
  32892. * @memberOf _
  32893. * @category Util
  32894. * @param {number} n The number of times to invoke `iteratee`.
  32895. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  32896. * @returns {Array} Returns the array of results.
  32897. * @example
  32898. *
  32899. * _.times(3, String);
  32900. * // => ['0', '1', '2']
  32901. *
  32902. * _.times(4, _.constant(0));
  32903. * // => [0, 0, 0, 0]
  32904. */
  32905. function times(n, iteratee) {
  32906. n = toInteger(n);
  32907. if (n < 1 || n > MAX_SAFE_INTEGER) {
  32908. return [];
  32909. }
  32910. var index = MAX_ARRAY_LENGTH,
  32911. length = nativeMin(n, MAX_ARRAY_LENGTH);
  32912. iteratee = getIteratee(iteratee);
  32913. n -= MAX_ARRAY_LENGTH;
  32914. var result = baseTimes(length, iteratee);
  32915. while (++index < n) {
  32916. iteratee(index);
  32917. }
  32918. return result;
  32919. }
  32920. /**
  32921. * Converts `value` to a property path array.
  32922. *
  32923. * @static
  32924. * @memberOf _
  32925. * @since 4.0.0
  32926. * @category Util
  32927. * @param {*} value The value to convert.
  32928. * @returns {Array} Returns the new property path array.
  32929. * @example
  32930. *
  32931. * _.toPath('a.b.c');
  32932. * // => ['a', 'b', 'c']
  32933. *
  32934. * _.toPath('a[0].b.c');
  32935. * // => ['a', '0', 'b', 'c']
  32936. */
  32937. function toPath(value) {
  32938. if (isArray(value)) {
  32939. return arrayMap(value, toKey);
  32940. }
  32941. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  32942. }
  32943. /**
  32944. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  32945. *
  32946. * @static
  32947. * @since 0.1.0
  32948. * @memberOf _
  32949. * @category Util
  32950. * @param {string} [prefix=''] The value to prefix the ID with.
  32951. * @returns {string} Returns the unique ID.
  32952. * @example
  32953. *
  32954. * _.uniqueId('contact_');
  32955. * // => 'contact_104'
  32956. *
  32957. * _.uniqueId();
  32958. * // => '105'
  32959. */
  32960. function uniqueId(prefix) {
  32961. var id = ++idCounter;
  32962. return toString(prefix) + id;
  32963. }
  32964. /*------------------------------------------------------------------------*/
  32965. /**
  32966. * Adds two numbers.
  32967. *
  32968. * @static
  32969. * @memberOf _
  32970. * @since 3.4.0
  32971. * @category Math
  32972. * @param {number} augend The first number in an addition.
  32973. * @param {number} addend The second number in an addition.
  32974. * @returns {number} Returns the total.
  32975. * @example
  32976. *
  32977. * _.add(6, 4);
  32978. * // => 10
  32979. */
  32980. var add = createMathOperation(function(augend, addend) {
  32981. return augend + addend;
  32982. }, 0);
  32983. /**
  32984. * Computes `number` rounded up to `precision`.
  32985. *
  32986. * @static
  32987. * @memberOf _
  32988. * @since 3.10.0
  32989. * @category Math
  32990. * @param {number} number The number to round up.
  32991. * @param {number} [precision=0] The precision to round up to.
  32992. * @returns {number} Returns the rounded up number.
  32993. * @example
  32994. *
  32995. * _.ceil(4.006);
  32996. * // => 5
  32997. *
  32998. * _.ceil(6.004, 2);
  32999. * // => 6.01
  33000. *
  33001. * _.ceil(6040, -2);
  33002. * // => 6100
  33003. */
  33004. var ceil = createRound('ceil');
  33005. /**
  33006. * Divide two numbers.
  33007. *
  33008. * @static
  33009. * @memberOf _
  33010. * @since 4.7.0
  33011. * @category Math
  33012. * @param {number} dividend The first number in a division.
  33013. * @param {number} divisor The second number in a division.
  33014. * @returns {number} Returns the quotient.
  33015. * @example
  33016. *
  33017. * _.divide(6, 4);
  33018. * // => 1.5
  33019. */
  33020. var divide = createMathOperation(function(dividend, divisor) {
  33021. return dividend / divisor;
  33022. }, 1);
  33023. /**
  33024. * Computes `number` rounded down to `precision`.
  33025. *
  33026. * @static
  33027. * @memberOf _
  33028. * @since 3.10.0
  33029. * @category Math
  33030. * @param {number} number The number to round down.
  33031. * @param {number} [precision=0] The precision to round down to.
  33032. * @returns {number} Returns the rounded down number.
  33033. * @example
  33034. *
  33035. * _.floor(4.006);
  33036. * // => 4
  33037. *
  33038. * _.floor(0.046, 2);
  33039. * // => 0.04
  33040. *
  33041. * _.floor(4060, -2);
  33042. * // => 4000
  33043. */
  33044. var floor = createRound('floor');
  33045. /**
  33046. * Computes the maximum value of `array`. If `array` is empty or falsey,
  33047. * `undefined` is returned.
  33048. *
  33049. * @static
  33050. * @since 0.1.0
  33051. * @memberOf _
  33052. * @category Math
  33053. * @param {Array} array The array to iterate over.
  33054. * @returns {*} Returns the maximum value.
  33055. * @example
  33056. *
  33057. * _.max([4, 2, 8, 6]);
  33058. * // => 8
  33059. *
  33060. * _.max([]);
  33061. * // => undefined
  33062. */
  33063. function max(array) {
  33064. return (array && array.length)
  33065. ? baseExtremum(array, identity, baseGt)
  33066. : undefined;
  33067. }
  33068. /**
  33069. * This method is like `_.max` except that it accepts `iteratee` which is
  33070. * invoked for each element in `array` to generate the criterion by which
  33071. * the value is ranked. The iteratee is invoked with one argument: (value).
  33072. *
  33073. * @static
  33074. * @memberOf _
  33075. * @since 4.0.0
  33076. * @category Math
  33077. * @param {Array} array The array to iterate over.
  33078. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33079. * @returns {*} Returns the maximum value.
  33080. * @example
  33081. *
  33082. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33083. *
  33084. * _.maxBy(objects, function(o) { return o.n; });
  33085. * // => { 'n': 2 }
  33086. *
  33087. * // The `_.property` iteratee shorthand.
  33088. * _.maxBy(objects, 'n');
  33089. * // => { 'n': 2 }
  33090. */
  33091. function maxBy(array, iteratee) {
  33092. return (array && array.length)
  33093. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  33094. : undefined;
  33095. }
  33096. /**
  33097. * Computes the mean of the values in `array`.
  33098. *
  33099. * @static
  33100. * @memberOf _
  33101. * @since 4.0.0
  33102. * @category Math
  33103. * @param {Array} array The array to iterate over.
  33104. * @returns {number} Returns the mean.
  33105. * @example
  33106. *
  33107. * _.mean([4, 2, 8, 6]);
  33108. * // => 5
  33109. */
  33110. function mean(array) {
  33111. return baseMean(array, identity);
  33112. }
  33113. /**
  33114. * This method is like `_.mean` except that it accepts `iteratee` which is
  33115. * invoked for each element in `array` to generate the value to be averaged.
  33116. * The iteratee is invoked with one argument: (value).
  33117. *
  33118. * @static
  33119. * @memberOf _
  33120. * @since 4.7.0
  33121. * @category Math
  33122. * @param {Array} array The array to iterate over.
  33123. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33124. * @returns {number} Returns the mean.
  33125. * @example
  33126. *
  33127. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33128. *
  33129. * _.meanBy(objects, function(o) { return o.n; });
  33130. * // => 5
  33131. *
  33132. * // The `_.property` iteratee shorthand.
  33133. * _.meanBy(objects, 'n');
  33134. * // => 5
  33135. */
  33136. function meanBy(array, iteratee) {
  33137. return baseMean(array, getIteratee(iteratee, 2));
  33138. }
  33139. /**
  33140. * Computes the minimum value of `array`. If `array` is empty or falsey,
  33141. * `undefined` is returned.
  33142. *
  33143. * @static
  33144. * @since 0.1.0
  33145. * @memberOf _
  33146. * @category Math
  33147. * @param {Array} array The array to iterate over.
  33148. * @returns {*} Returns the minimum value.
  33149. * @example
  33150. *
  33151. * _.min([4, 2, 8, 6]);
  33152. * // => 2
  33153. *
  33154. * _.min([]);
  33155. * // => undefined
  33156. */
  33157. function min(array) {
  33158. return (array && array.length)
  33159. ? baseExtremum(array, identity, baseLt)
  33160. : undefined;
  33161. }
  33162. /**
  33163. * This method is like `_.min` except that it accepts `iteratee` which is
  33164. * invoked for each element in `array` to generate the criterion by which
  33165. * the value is ranked. The iteratee is invoked with one argument: (value).
  33166. *
  33167. * @static
  33168. * @memberOf _
  33169. * @since 4.0.0
  33170. * @category Math
  33171. * @param {Array} array The array to iterate over.
  33172. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33173. * @returns {*} Returns the minimum value.
  33174. * @example
  33175. *
  33176. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33177. *
  33178. * _.minBy(objects, function(o) { return o.n; });
  33179. * // => { 'n': 1 }
  33180. *
  33181. * // The `_.property` iteratee shorthand.
  33182. * _.minBy(objects, 'n');
  33183. * // => { 'n': 1 }
  33184. */
  33185. function minBy(array, iteratee) {
  33186. return (array && array.length)
  33187. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  33188. : undefined;
  33189. }
  33190. /**
  33191. * Multiply two numbers.
  33192. *
  33193. * @static
  33194. * @memberOf _
  33195. * @since 4.7.0
  33196. * @category Math
  33197. * @param {number} multiplier The first number in a multiplication.
  33198. * @param {number} multiplicand The second number in a multiplication.
  33199. * @returns {number} Returns the product.
  33200. * @example
  33201. *
  33202. * _.multiply(6, 4);
  33203. * // => 24
  33204. */
  33205. var multiply = createMathOperation(function(multiplier, multiplicand) {
  33206. return multiplier * multiplicand;
  33207. }, 1);
  33208. /**
  33209. * Computes `number` rounded to `precision`.
  33210. *
  33211. * @static
  33212. * @memberOf _
  33213. * @since 3.10.0
  33214. * @category Math
  33215. * @param {number} number The number to round.
  33216. * @param {number} [precision=0] The precision to round to.
  33217. * @returns {number} Returns the rounded number.
  33218. * @example
  33219. *
  33220. * _.round(4.006);
  33221. * // => 4
  33222. *
  33223. * _.round(4.006, 2);
  33224. * // => 4.01
  33225. *
  33226. * _.round(4060, -2);
  33227. * // => 4100
  33228. */
  33229. var round = createRound('round');
  33230. /**
  33231. * Subtract two numbers.
  33232. *
  33233. * @static
  33234. * @memberOf _
  33235. * @since 4.0.0
  33236. * @category Math
  33237. * @param {number} minuend The first number in a subtraction.
  33238. * @param {number} subtrahend The second number in a subtraction.
  33239. * @returns {number} Returns the difference.
  33240. * @example
  33241. *
  33242. * _.subtract(6, 4);
  33243. * // => 2
  33244. */
  33245. var subtract = createMathOperation(function(minuend, subtrahend) {
  33246. return minuend - subtrahend;
  33247. }, 0);
  33248. /**
  33249. * Computes the sum of the values in `array`.
  33250. *
  33251. * @static
  33252. * @memberOf _
  33253. * @since 3.4.0
  33254. * @category Math
  33255. * @param {Array} array The array to iterate over.
  33256. * @returns {number} Returns the sum.
  33257. * @example
  33258. *
  33259. * _.sum([4, 2, 8, 6]);
  33260. * // => 20
  33261. */
  33262. function sum(array) {
  33263. return (array && array.length)
  33264. ? baseSum(array, identity)
  33265. : 0;
  33266. }
  33267. /**
  33268. * This method is like `_.sum` except that it accepts `iteratee` which is
  33269. * invoked for each element in `array` to generate the value to be summed.
  33270. * The iteratee is invoked with one argument: (value).
  33271. *
  33272. * @static
  33273. * @memberOf _
  33274. * @since 4.0.0
  33275. * @category Math
  33276. * @param {Array} array The array to iterate over.
  33277. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33278. * @returns {number} Returns the sum.
  33279. * @example
  33280. *
  33281. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33282. *
  33283. * _.sumBy(objects, function(o) { return o.n; });
  33284. * // => 20
  33285. *
  33286. * // The `_.property` iteratee shorthand.
  33287. * _.sumBy(objects, 'n');
  33288. * // => 20
  33289. */
  33290. function sumBy(array, iteratee) {
  33291. return (array && array.length)
  33292. ? baseSum(array, getIteratee(iteratee, 2))
  33293. : 0;
  33294. }
  33295. /*------------------------------------------------------------------------*/
  33296. // Add methods that return wrapped values in chain sequences.
  33297. lodash.after = after;
  33298. lodash.ary = ary;
  33299. lodash.assign = assign;
  33300. lodash.assignIn = assignIn;
  33301. lodash.assignInWith = assignInWith;
  33302. lodash.assignWith = assignWith;
  33303. lodash.at = at;
  33304. lodash.before = before;
  33305. lodash.bind = bind;
  33306. lodash.bindAll = bindAll;
  33307. lodash.bindKey = bindKey;
  33308. lodash.castArray = castArray;
  33309. lodash.chain = chain;
  33310. lodash.chunk = chunk;
  33311. lodash.compact = compact;
  33312. lodash.concat = concat;
  33313. lodash.cond = cond;
  33314. lodash.conforms = conforms;
  33315. lodash.constant = constant;
  33316. lodash.countBy = countBy;
  33317. lodash.create = create;
  33318. lodash.curry = curry;
  33319. lodash.curryRight = curryRight;
  33320. lodash.debounce = debounce;
  33321. lodash.defaults = defaults;
  33322. lodash.defaultsDeep = defaultsDeep;
  33323. lodash.defer = defer;
  33324. lodash.delay = delay;
  33325. lodash.difference = difference;
  33326. lodash.differenceBy = differenceBy;
  33327. lodash.differenceWith = differenceWith;
  33328. lodash.drop = drop;
  33329. lodash.dropRight = dropRight;
  33330. lodash.dropRightWhile = dropRightWhile;
  33331. lodash.dropWhile = dropWhile;
  33332. lodash.fill = fill;
  33333. lodash.filter = filter;
  33334. lodash.flatMap = flatMap;
  33335. lodash.flatMapDeep = flatMapDeep;
  33336. lodash.flatMapDepth = flatMapDepth;
  33337. lodash.flatten = flatten;
  33338. lodash.flattenDeep = flattenDeep;
  33339. lodash.flattenDepth = flattenDepth;
  33340. lodash.flip = flip;
  33341. lodash.flow = flow;
  33342. lodash.flowRight = flowRight;
  33343. lodash.fromPairs = fromPairs;
  33344. lodash.functions = functions;
  33345. lodash.functionsIn = functionsIn;
  33346. lodash.groupBy = groupBy;
  33347. lodash.initial = initial;
  33348. lodash.intersection = intersection;
  33349. lodash.intersectionBy = intersectionBy;
  33350. lodash.intersectionWith = intersectionWith;
  33351. lodash.invert = invert;
  33352. lodash.invertBy = invertBy;
  33353. lodash.invokeMap = invokeMap;
  33354. lodash.iteratee = iteratee;
  33355. lodash.keyBy = keyBy;
  33356. lodash.keys = keys;
  33357. lodash.keysIn = keysIn;
  33358. lodash.map = map;
  33359. lodash.mapKeys = mapKeys;
  33360. lodash.mapValues = mapValues;
  33361. lodash.matches = matches;
  33362. lodash.matchesProperty = matchesProperty;
  33363. lodash.memoize = memoize;
  33364. lodash.merge = merge;
  33365. lodash.mergeWith = mergeWith;
  33366. lodash.method = method;
  33367. lodash.methodOf = methodOf;
  33368. lodash.mixin = mixin;
  33369. lodash.negate = negate;
  33370. lodash.nthArg = nthArg;
  33371. lodash.omit = omit;
  33372. lodash.omitBy = omitBy;
  33373. lodash.once = once;
  33374. lodash.orderBy = orderBy;
  33375. lodash.over = over;
  33376. lodash.overArgs = overArgs;
  33377. lodash.overEvery = overEvery;
  33378. lodash.overSome = overSome;
  33379. lodash.partial = partial;
  33380. lodash.partialRight = partialRight;
  33381. lodash.partition = partition;
  33382. lodash.pick = pick;
  33383. lodash.pickBy = pickBy;
  33384. lodash.property = property;
  33385. lodash.propertyOf = propertyOf;
  33386. lodash.pull = pull;
  33387. lodash.pullAll = pullAll;
  33388. lodash.pullAllBy = pullAllBy;
  33389. lodash.pullAllWith = pullAllWith;
  33390. lodash.pullAt = pullAt;
  33391. lodash.range = range;
  33392. lodash.rangeRight = rangeRight;
  33393. lodash.rearg = rearg;
  33394. lodash.reject = reject;
  33395. lodash.remove = remove;
  33396. lodash.rest = rest;
  33397. lodash.reverse = reverse;
  33398. lodash.sampleSize = sampleSize;
  33399. lodash.set = set;
  33400. lodash.setWith = setWith;
  33401. lodash.shuffle = shuffle;
  33402. lodash.slice = slice;
  33403. lodash.sortBy = sortBy;
  33404. lodash.sortedUniq = sortedUniq;
  33405. lodash.sortedUniqBy = sortedUniqBy;
  33406. lodash.split = split;
  33407. lodash.spread = spread;
  33408. lodash.tail = tail;
  33409. lodash.take = take;
  33410. lodash.takeRight = takeRight;
  33411. lodash.takeRightWhile = takeRightWhile;
  33412. lodash.takeWhile = takeWhile;
  33413. lodash.tap = tap;
  33414. lodash.throttle = throttle;
  33415. lodash.thru = thru;
  33416. lodash.toArray = toArray;
  33417. lodash.toPairs = toPairs;
  33418. lodash.toPairsIn = toPairsIn;
  33419. lodash.toPath = toPath;
  33420. lodash.toPlainObject = toPlainObject;
  33421. lodash.transform = transform;
  33422. lodash.unary = unary;
  33423. lodash.union = union;
  33424. lodash.unionBy = unionBy;
  33425. lodash.unionWith = unionWith;
  33426. lodash.uniq = uniq;
  33427. lodash.uniqBy = uniqBy;
  33428. lodash.uniqWith = uniqWith;
  33429. lodash.unset = unset;
  33430. lodash.unzip = unzip;
  33431. lodash.unzipWith = unzipWith;
  33432. lodash.update = update;
  33433. lodash.updateWith = updateWith;
  33434. lodash.values = values;
  33435. lodash.valuesIn = valuesIn;
  33436. lodash.without = without;
  33437. lodash.words = words;
  33438. lodash.wrap = wrap;
  33439. lodash.xor = xor;
  33440. lodash.xorBy = xorBy;
  33441. lodash.xorWith = xorWith;
  33442. lodash.zip = zip;
  33443. lodash.zipObject = zipObject;
  33444. lodash.zipObjectDeep = zipObjectDeep;
  33445. lodash.zipWith = zipWith;
  33446. // Add aliases.
  33447. lodash.entries = toPairs;
  33448. lodash.entriesIn = toPairsIn;
  33449. lodash.extend = assignIn;
  33450. lodash.extendWith = assignInWith;
  33451. // Add methods to `lodash.prototype`.
  33452. mixin(lodash, lodash);
  33453. /*------------------------------------------------------------------------*/
  33454. // Add methods that return unwrapped values in chain sequences.
  33455. lodash.add = add;
  33456. lodash.attempt = attempt;
  33457. lodash.camelCase = camelCase;
  33458. lodash.capitalize = capitalize;
  33459. lodash.ceil = ceil;
  33460. lodash.clamp = clamp;
  33461. lodash.clone = clone;
  33462. lodash.cloneDeep = cloneDeep;
  33463. lodash.cloneDeepWith = cloneDeepWith;
  33464. lodash.cloneWith = cloneWith;
  33465. lodash.conformsTo = conformsTo;
  33466. lodash.deburr = deburr;
  33467. lodash.defaultTo = defaultTo;
  33468. lodash.divide = divide;
  33469. lodash.endsWith = endsWith;
  33470. lodash.eq = eq;
  33471. lodash.escape = escape;
  33472. lodash.escapeRegExp = escapeRegExp;
  33473. lodash.every = every;
  33474. lodash.find = find;
  33475. lodash.findIndex = findIndex;
  33476. lodash.findKey = findKey;
  33477. lodash.findLast = findLast;
  33478. lodash.findLastIndex = findLastIndex;
  33479. lodash.findLastKey = findLastKey;
  33480. lodash.floor = floor;
  33481. lodash.forEach = forEach;
  33482. lodash.forEachRight = forEachRight;
  33483. lodash.forIn = forIn;
  33484. lodash.forInRight = forInRight;
  33485. lodash.forOwn = forOwn;
  33486. lodash.forOwnRight = forOwnRight;
  33487. lodash.get = get;
  33488. lodash.gt = gt;
  33489. lodash.gte = gte;
  33490. lodash.has = has;
  33491. lodash.hasIn = hasIn;
  33492. lodash.head = head;
  33493. lodash.identity = identity;
  33494. lodash.includes = includes;
  33495. lodash.indexOf = indexOf;
  33496. lodash.inRange = inRange;
  33497. lodash.invoke = invoke;
  33498. lodash.isArguments = isArguments;
  33499. lodash.isArray = isArray;
  33500. lodash.isArrayBuffer = isArrayBuffer;
  33501. lodash.isArrayLike = isArrayLike;
  33502. lodash.isArrayLikeObject = isArrayLikeObject;
  33503. lodash.isBoolean = isBoolean;
  33504. lodash.isBuffer = isBuffer;
  33505. lodash.isDate = isDate;
  33506. lodash.isElement = isElement;
  33507. lodash.isEmpty = isEmpty;
  33508. lodash.isEqual = isEqual;
  33509. lodash.isEqualWith = isEqualWith;
  33510. lodash.isError = isError;
  33511. lodash.isFinite = isFinite;
  33512. lodash.isFunction = isFunction;
  33513. lodash.isInteger = isInteger;
  33514. lodash.isLength = isLength;
  33515. lodash.isMap = isMap;
  33516. lodash.isMatch = isMatch;
  33517. lodash.isMatchWith = isMatchWith;
  33518. lodash.isNaN = isNaN;
  33519. lodash.isNative = isNative;
  33520. lodash.isNil = isNil;
  33521. lodash.isNull = isNull;
  33522. lodash.isNumber = isNumber;
  33523. lodash.isObject = isObject;
  33524. lodash.isObjectLike = isObjectLike;
  33525. lodash.isPlainObject = isPlainObject;
  33526. lodash.isRegExp = isRegExp;
  33527. lodash.isSafeInteger = isSafeInteger;
  33528. lodash.isSet = isSet;
  33529. lodash.isString = isString;
  33530. lodash.isSymbol = isSymbol;
  33531. lodash.isTypedArray = isTypedArray;
  33532. lodash.isUndefined = isUndefined;
  33533. lodash.isWeakMap = isWeakMap;
  33534. lodash.isWeakSet = isWeakSet;
  33535. lodash.join = join;
  33536. lodash.kebabCase = kebabCase;
  33537. lodash.last = last;
  33538. lodash.lastIndexOf = lastIndexOf;
  33539. lodash.lowerCase = lowerCase;
  33540. lodash.lowerFirst = lowerFirst;
  33541. lodash.lt = lt;
  33542. lodash.lte = lte;
  33543. lodash.max = max;
  33544. lodash.maxBy = maxBy;
  33545. lodash.mean = mean;
  33546. lodash.meanBy = meanBy;
  33547. lodash.min = min;
  33548. lodash.minBy = minBy;
  33549. lodash.stubArray = stubArray;
  33550. lodash.stubFalse = stubFalse;
  33551. lodash.stubObject = stubObject;
  33552. lodash.stubString = stubString;
  33553. lodash.stubTrue = stubTrue;
  33554. lodash.multiply = multiply;
  33555. lodash.nth = nth;
  33556. lodash.noConflict = noConflict;
  33557. lodash.noop = noop;
  33558. lodash.now = now;
  33559. lodash.pad = pad;
  33560. lodash.padEnd = padEnd;
  33561. lodash.padStart = padStart;
  33562. lodash.parseInt = parseInt;
  33563. lodash.random = random;
  33564. lodash.reduce = reduce;
  33565. lodash.reduceRight = reduceRight;
  33566. lodash.repeat = repeat;
  33567. lodash.replace = replace;
  33568. lodash.result = result;
  33569. lodash.round = round;
  33570. lodash.runInContext = runInContext;
  33571. lodash.sample = sample;
  33572. lodash.size = size;
  33573. lodash.snakeCase = snakeCase;
  33574. lodash.some = some;
  33575. lodash.sortedIndex = sortedIndex;
  33576. lodash.sortedIndexBy = sortedIndexBy;
  33577. lodash.sortedIndexOf = sortedIndexOf;
  33578. lodash.sortedLastIndex = sortedLastIndex;
  33579. lodash.sortedLastIndexBy = sortedLastIndexBy;
  33580. lodash.sortedLastIndexOf = sortedLastIndexOf;
  33581. lodash.startCase = startCase;
  33582. lodash.startsWith = startsWith;
  33583. lodash.subtract = subtract;
  33584. lodash.sum = sum;
  33585. lodash.sumBy = sumBy;
  33586. lodash.template = template;
  33587. lodash.times = times;
  33588. lodash.toFinite = toFinite;
  33589. lodash.toInteger = toInteger;
  33590. lodash.toLength = toLength;
  33591. lodash.toLower = toLower;
  33592. lodash.toNumber = toNumber;
  33593. lodash.toSafeInteger = toSafeInteger;
  33594. lodash.toString = toString;
  33595. lodash.toUpper = toUpper;
  33596. lodash.trim = trim;
  33597. lodash.trimEnd = trimEnd;
  33598. lodash.trimStart = trimStart;
  33599. lodash.truncate = truncate;
  33600. lodash.unescape = unescape;
  33601. lodash.uniqueId = uniqueId;
  33602. lodash.upperCase = upperCase;
  33603. lodash.upperFirst = upperFirst;
  33604. // Add aliases.
  33605. lodash.each = forEach;
  33606. lodash.eachRight = forEachRight;
  33607. lodash.first = head;
  33608. mixin(lodash, (function() {
  33609. var source = {};
  33610. baseForOwn(lodash, function(func, methodName) {
  33611. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  33612. source[methodName] = func;
  33613. }
  33614. });
  33615. return source;
  33616. }()), { 'chain': false });
  33617. /*------------------------------------------------------------------------*/
  33618. /**
  33619. * The semantic version number.
  33620. *
  33621. * @static
  33622. * @memberOf _
  33623. * @type {string}
  33624. */
  33625. lodash.VERSION = VERSION;
  33626. // Assign default placeholders.
  33627. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  33628. lodash[methodName].placeholder = lodash;
  33629. });
  33630. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  33631. arrayEach(['drop', 'take'], function(methodName, index) {
  33632. LazyWrapper.prototype[methodName] = function(n) {
  33633. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  33634. var result = (this.__filtered__ && !index)
  33635. ? new LazyWrapper(this)
  33636. : this.clone();
  33637. if (result.__filtered__) {
  33638. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  33639. } else {
  33640. result.__views__.push({
  33641. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  33642. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  33643. });
  33644. }
  33645. return result;
  33646. };
  33647. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  33648. return this.reverse()[methodName](n).reverse();
  33649. };
  33650. });
  33651. // Add `LazyWrapper` methods that accept an `iteratee` value.
  33652. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  33653. var type = index + 1,
  33654. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  33655. LazyWrapper.prototype[methodName] = function(iteratee) {
  33656. var result = this.clone();
  33657. result.__iteratees__.push({
  33658. 'iteratee': getIteratee(iteratee, 3),
  33659. 'type': type
  33660. });
  33661. result.__filtered__ = result.__filtered__ || isFilter;
  33662. return result;
  33663. };
  33664. });
  33665. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  33666. arrayEach(['head', 'last'], function(methodName, index) {
  33667. var takeName = 'take' + (index ? 'Right' : '');
  33668. LazyWrapper.prototype[methodName] = function() {
  33669. return this[takeName](1).value()[0];
  33670. };
  33671. });
  33672. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  33673. arrayEach(['initial', 'tail'], function(methodName, index) {
  33674. var dropName = 'drop' + (index ? '' : 'Right');
  33675. LazyWrapper.prototype[methodName] = function() {
  33676. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  33677. };
  33678. });
  33679. LazyWrapper.prototype.compact = function() {
  33680. return this.filter(identity);
  33681. };
  33682. LazyWrapper.prototype.find = function(predicate) {
  33683. return this.filter(predicate).head();
  33684. };
  33685. LazyWrapper.prototype.findLast = function(predicate) {
  33686. return this.reverse().find(predicate);
  33687. };
  33688. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  33689. if (typeof path == 'function') {
  33690. return new LazyWrapper(this);
  33691. }
  33692. return this.map(function(value) {
  33693. return baseInvoke(value, path, args);
  33694. });
  33695. });
  33696. LazyWrapper.prototype.reject = function(predicate) {
  33697. return this.filter(negate(getIteratee(predicate)));
  33698. };
  33699. LazyWrapper.prototype.slice = function(start, end) {
  33700. start = toInteger(start);
  33701. var result = this;
  33702. if (result.__filtered__ && (start > 0 || end < 0)) {
  33703. return new LazyWrapper(result);
  33704. }
  33705. if (start < 0) {
  33706. result = result.takeRight(-start);
  33707. } else if (start) {
  33708. result = result.drop(start);
  33709. }
  33710. if (end !== undefined) {
  33711. end = toInteger(end);
  33712. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  33713. }
  33714. return result;
  33715. };
  33716. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  33717. return this.reverse().takeWhile(predicate).reverse();
  33718. };
  33719. LazyWrapper.prototype.toArray = function() {
  33720. return this.take(MAX_ARRAY_LENGTH);
  33721. };
  33722. // Add `LazyWrapper` methods to `lodash.prototype`.
  33723. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33724. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  33725. isTaker = /^(?:head|last)$/.test(methodName),
  33726. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  33727. retUnwrapped = isTaker || /^find/.test(methodName);
  33728. if (!lodashFunc) {
  33729. return;
  33730. }
  33731. lodash.prototype[methodName] = function() {
  33732. var value = this.__wrapped__,
  33733. args = isTaker ? [1] : arguments,
  33734. isLazy = value instanceof LazyWrapper,
  33735. iteratee = args[0],
  33736. useLazy = isLazy || isArray(value);
  33737. var interceptor = function(value) {
  33738. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  33739. return (isTaker && chainAll) ? result[0] : result;
  33740. };
  33741. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  33742. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  33743. isLazy = useLazy = false;
  33744. }
  33745. var chainAll = this.__chain__,
  33746. isHybrid = !!this.__actions__.length,
  33747. isUnwrapped = retUnwrapped && !chainAll,
  33748. onlyLazy = isLazy && !isHybrid;
  33749. if (!retUnwrapped && useLazy) {
  33750. value = onlyLazy ? value : new LazyWrapper(this);
  33751. var result = func.apply(value, args);
  33752. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  33753. return new LodashWrapper(result, chainAll);
  33754. }
  33755. if (isUnwrapped && onlyLazy) {
  33756. return func.apply(this, args);
  33757. }
  33758. result = this.thru(interceptor);
  33759. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  33760. };
  33761. });
  33762. // Add `Array` methods to `lodash.prototype`.
  33763. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  33764. var func = arrayProto[methodName],
  33765. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  33766. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  33767. lodash.prototype[methodName] = function() {
  33768. var args = arguments;
  33769. if (retUnwrapped && !this.__chain__) {
  33770. var value = this.value();
  33771. return func.apply(isArray(value) ? value : [], args);
  33772. }
  33773. return this[chainName](function(value) {
  33774. return func.apply(isArray(value) ? value : [], args);
  33775. });
  33776. };
  33777. });
  33778. // Map minified method names to their real names.
  33779. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33780. var lodashFunc = lodash[methodName];
  33781. if (lodashFunc) {
  33782. var key = lodashFunc.name + '';
  33783. if (!hasOwnProperty.call(realNames, key)) {
  33784. realNames[key] = [];
  33785. }
  33786. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  33787. }
  33788. });
  33789. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  33790. 'name': 'wrapper',
  33791. 'func': undefined
  33792. }];
  33793. // Add methods to `LazyWrapper`.
  33794. LazyWrapper.prototype.clone = lazyClone;
  33795. LazyWrapper.prototype.reverse = lazyReverse;
  33796. LazyWrapper.prototype.value = lazyValue;
  33797. // Add chain sequence methods to the `lodash` wrapper.
  33798. lodash.prototype.at = wrapperAt;
  33799. lodash.prototype.chain = wrapperChain;
  33800. lodash.prototype.commit = wrapperCommit;
  33801. lodash.prototype.next = wrapperNext;
  33802. lodash.prototype.plant = wrapperPlant;
  33803. lodash.prototype.reverse = wrapperReverse;
  33804. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  33805. // Add lazy aliases.
  33806. lodash.prototype.first = lodash.prototype.head;
  33807. if (symIterator) {
  33808. lodash.prototype[symIterator] = wrapperToIterator;
  33809. }
  33810. return lodash;
  33811. });
  33812. /*--------------------------------------------------------------------------*/
  33813. // Export lodash.
  33814. var _ = runInContext();
  33815. // Some AMD build optimizers, like r.js, check for condition patterns like:
  33816. if (true) {
  33817. // Expose Lodash on the global object to prevent errors when Lodash is
  33818. // loaded by a script tag in the presence of an AMD loader.
  33819. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  33820. // Use `_.noConflict` to remove Lodash from the global object.
  33821. root._ = _;
  33822. // Define as an anonymous module so, through path mapping, it can be
  33823. // referenced as the "underscore" module.
  33824. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  33825. return _;
  33826. }).call(exports, __webpack_require__, exports, module),
  33827. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  33828. }
  33829. // Check for `exports` after `define` in case a build optimizer adds it.
  33830. else {}
  33831. }.call(this));
  33832. /* 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)))
  33833. /***/ }),
  33834. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  33835. /*!***************************************************!*\
  33836. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  33837. \***************************************************/
  33838. /*! exports provided: default */
  33839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33840. "use strict";
  33841. __webpack_require__.r(__webpack_exports__);
  33842. /* WEBPACK VAR INJECTION */(function(global) {/**!
  33843. * @fileOverview Kickass library to create and place poppers near their reference elements.
  33844. * @version 1.16.1
  33845. * @license
  33846. * Copyright (c) 2016 Federico Zivolo and contributors
  33847. *
  33848. * Permission is hereby granted, free of charge, to any person obtaining a copy
  33849. * of this software and associated documentation files (the "Software"), to deal
  33850. * in the Software without restriction, including without limitation the rights
  33851. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  33852. * copies of the Software, and to permit persons to whom the Software is
  33853. * furnished to do so, subject to the following conditions:
  33854. *
  33855. * The above copyright notice and this permission notice shall be included in all
  33856. * copies or substantial portions of the Software.
  33857. *
  33858. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  33859. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  33860. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  33861. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  33862. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  33863. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  33864. * SOFTWARE.
  33865. */
  33866. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  33867. var timeoutDuration = function () {
  33868. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  33869. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  33870. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  33871. return 1;
  33872. }
  33873. }
  33874. return 0;
  33875. }();
  33876. function microtaskDebounce(fn) {
  33877. var called = false;
  33878. return function () {
  33879. if (called) {
  33880. return;
  33881. }
  33882. called = true;
  33883. window.Promise.resolve().then(function () {
  33884. called = false;
  33885. fn();
  33886. });
  33887. };
  33888. }
  33889. function taskDebounce(fn) {
  33890. var scheduled = false;
  33891. return function () {
  33892. if (!scheduled) {
  33893. scheduled = true;
  33894. setTimeout(function () {
  33895. scheduled = false;
  33896. fn();
  33897. }, timeoutDuration);
  33898. }
  33899. };
  33900. }
  33901. var supportsMicroTasks = isBrowser && window.Promise;
  33902. /**
  33903. * Create a debounced version of a method, that's asynchronously deferred
  33904. * but called in the minimum time possible.
  33905. *
  33906. * @method
  33907. * @memberof Popper.Utils
  33908. * @argument {Function} fn
  33909. * @returns {Function}
  33910. */
  33911. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  33912. /**
  33913. * Check if the given variable is a function
  33914. * @method
  33915. * @memberof Popper.Utils
  33916. * @argument {Any} functionToCheck - variable to check
  33917. * @returns {Boolean} answer to: is a function?
  33918. */
  33919. function isFunction(functionToCheck) {
  33920. var getType = {};
  33921. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  33922. }
  33923. /**
  33924. * Get CSS computed property of the given element
  33925. * @method
  33926. * @memberof Popper.Utils
  33927. * @argument {Eement} element
  33928. * @argument {String} property
  33929. */
  33930. function getStyleComputedProperty(element, property) {
  33931. if (element.nodeType !== 1) {
  33932. return [];
  33933. }
  33934. // NOTE: 1 DOM access here
  33935. var window = element.ownerDocument.defaultView;
  33936. var css = window.getComputedStyle(element, null);
  33937. return property ? css[property] : css;
  33938. }
  33939. /**
  33940. * Returns the parentNode or the host of the element
  33941. * @method
  33942. * @memberof Popper.Utils
  33943. * @argument {Element} element
  33944. * @returns {Element} parent
  33945. */
  33946. function getParentNode(element) {
  33947. if (element.nodeName === 'HTML') {
  33948. return element;
  33949. }
  33950. return element.parentNode || element.host;
  33951. }
  33952. /**
  33953. * Returns the scrolling parent of the given element
  33954. * @method
  33955. * @memberof Popper.Utils
  33956. * @argument {Element} element
  33957. * @returns {Element} scroll parent
  33958. */
  33959. function getScrollParent(element) {
  33960. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  33961. if (!element) {
  33962. return document.body;
  33963. }
  33964. switch (element.nodeName) {
  33965. case 'HTML':
  33966. case 'BODY':
  33967. return element.ownerDocument.body;
  33968. case '#document':
  33969. return element.body;
  33970. }
  33971. // Firefox want us to check `-x` and `-y` variations as well
  33972. var _getStyleComputedProp = getStyleComputedProperty(element),
  33973. overflow = _getStyleComputedProp.overflow,
  33974. overflowX = _getStyleComputedProp.overflowX,
  33975. overflowY = _getStyleComputedProp.overflowY;
  33976. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  33977. return element;
  33978. }
  33979. return getScrollParent(getParentNode(element));
  33980. }
  33981. /**
  33982. * Returns the reference node of the reference object, or the reference object itself.
  33983. * @method
  33984. * @memberof Popper.Utils
  33985. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  33986. * @returns {Element} parent
  33987. */
  33988. function getReferenceNode(reference) {
  33989. return reference && reference.referenceNode ? reference.referenceNode : reference;
  33990. }
  33991. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  33992. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  33993. /**
  33994. * Determines if the browser is Internet Explorer
  33995. * @method
  33996. * @memberof Popper.Utils
  33997. * @param {Number} version to check
  33998. * @returns {Boolean} isIE
  33999. */
  34000. function isIE(version) {
  34001. if (version === 11) {
  34002. return isIE11;
  34003. }
  34004. if (version === 10) {
  34005. return isIE10;
  34006. }
  34007. return isIE11 || isIE10;
  34008. }
  34009. /**
  34010. * Returns the offset parent of the given element
  34011. * @method
  34012. * @memberof Popper.Utils
  34013. * @argument {Element} element
  34014. * @returns {Element} offset parent
  34015. */
  34016. function getOffsetParent(element) {
  34017. if (!element) {
  34018. return document.documentElement;
  34019. }
  34020. var noOffsetParent = isIE(10) ? document.body : null;
  34021. // NOTE: 1 DOM access here
  34022. var offsetParent = element.offsetParent || null;
  34023. // Skip hidden elements which don't have an offsetParent
  34024. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  34025. offsetParent = (element = element.nextElementSibling).offsetParent;
  34026. }
  34027. var nodeName = offsetParent && offsetParent.nodeName;
  34028. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  34029. return element ? element.ownerDocument.documentElement : document.documentElement;
  34030. }
  34031. // .offsetParent will return the closest TH, TD or TABLE in case
  34032. // no offsetParent is present, I hate this job...
  34033. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  34034. return getOffsetParent(offsetParent);
  34035. }
  34036. return offsetParent;
  34037. }
  34038. function isOffsetContainer(element) {
  34039. var nodeName = element.nodeName;
  34040. if (nodeName === 'BODY') {
  34041. return false;
  34042. }
  34043. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  34044. }
  34045. /**
  34046. * Finds the root node (document, shadowDOM root) of the given element
  34047. * @method
  34048. * @memberof Popper.Utils
  34049. * @argument {Element} node
  34050. * @returns {Element} root node
  34051. */
  34052. function getRoot(node) {
  34053. if (node.parentNode !== null) {
  34054. return getRoot(node.parentNode);
  34055. }
  34056. return node;
  34057. }
  34058. /**
  34059. * Finds the offset parent common to the two provided nodes
  34060. * @method
  34061. * @memberof Popper.Utils
  34062. * @argument {Element} element1
  34063. * @argument {Element} element2
  34064. * @returns {Element} common offset parent
  34065. */
  34066. function findCommonOffsetParent(element1, element2) {
  34067. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34068. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  34069. return document.documentElement;
  34070. }
  34071. // Here we make sure to give as "start" the element that comes first in the DOM
  34072. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  34073. var start = order ? element1 : element2;
  34074. var end = order ? element2 : element1;
  34075. // Get common ancestor container
  34076. var range = document.createRange();
  34077. range.setStart(start, 0);
  34078. range.setEnd(end, 0);
  34079. var commonAncestorContainer = range.commonAncestorContainer;
  34080. // Both nodes are inside #document
  34081. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  34082. if (isOffsetContainer(commonAncestorContainer)) {
  34083. return commonAncestorContainer;
  34084. }
  34085. return getOffsetParent(commonAncestorContainer);
  34086. }
  34087. // one of the nodes is inside shadowDOM, find which one
  34088. var element1root = getRoot(element1);
  34089. if (element1root.host) {
  34090. return findCommonOffsetParent(element1root.host, element2);
  34091. } else {
  34092. return findCommonOffsetParent(element1, getRoot(element2).host);
  34093. }
  34094. }
  34095. /**
  34096. * Gets the scroll value of the given element in the given side (top and left)
  34097. * @method
  34098. * @memberof Popper.Utils
  34099. * @argument {Element} element
  34100. * @argument {String} side `top` or `left`
  34101. * @returns {number} amount of scrolled pixels
  34102. */
  34103. function getScroll(element) {
  34104. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  34105. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  34106. var nodeName = element.nodeName;
  34107. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34108. var html = element.ownerDocument.documentElement;
  34109. var scrollingElement = element.ownerDocument.scrollingElement || html;
  34110. return scrollingElement[upperSide];
  34111. }
  34112. return element[upperSide];
  34113. }
  34114. /*
  34115. * Sum or subtract the element scroll values (left and top) from a given rect object
  34116. * @method
  34117. * @memberof Popper.Utils
  34118. * @param {Object} rect - Rect object you want to change
  34119. * @param {HTMLElement} element - The element from the function reads the scroll values
  34120. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  34121. * @return {Object} rect - The modifier rect object
  34122. */
  34123. function includeScroll(rect, element) {
  34124. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34125. var scrollTop = getScroll(element, 'top');
  34126. var scrollLeft = getScroll(element, 'left');
  34127. var modifier = subtract ? -1 : 1;
  34128. rect.top += scrollTop * modifier;
  34129. rect.bottom += scrollTop * modifier;
  34130. rect.left += scrollLeft * modifier;
  34131. rect.right += scrollLeft * modifier;
  34132. return rect;
  34133. }
  34134. /*
  34135. * Helper to detect borders of a given element
  34136. * @method
  34137. * @memberof Popper.Utils
  34138. * @param {CSSStyleDeclaration} styles
  34139. * Result of `getStyleComputedProperty` on the given element
  34140. * @param {String} axis - `x` or `y`
  34141. * @return {number} borders - The borders size of the given axis
  34142. */
  34143. function getBordersSize(styles, axis) {
  34144. var sideA = axis === 'x' ? 'Left' : 'Top';
  34145. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  34146. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  34147. }
  34148. function getSize(axis, body, html, computedStyle) {
  34149. 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);
  34150. }
  34151. function getWindowSizes(document) {
  34152. var body = document.body;
  34153. var html = document.documentElement;
  34154. var computedStyle = isIE(10) && getComputedStyle(html);
  34155. return {
  34156. height: getSize('Height', body, html, computedStyle),
  34157. width: getSize('Width', body, html, computedStyle)
  34158. };
  34159. }
  34160. var classCallCheck = function (instance, Constructor) {
  34161. if (!(instance instanceof Constructor)) {
  34162. throw new TypeError("Cannot call a class as a function");
  34163. }
  34164. };
  34165. var createClass = function () {
  34166. function defineProperties(target, props) {
  34167. for (var i = 0; i < props.length; i++) {
  34168. var descriptor = props[i];
  34169. descriptor.enumerable = descriptor.enumerable || false;
  34170. descriptor.configurable = true;
  34171. if ("value" in descriptor) descriptor.writable = true;
  34172. Object.defineProperty(target, descriptor.key, descriptor);
  34173. }
  34174. }
  34175. return function (Constructor, protoProps, staticProps) {
  34176. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  34177. if (staticProps) defineProperties(Constructor, staticProps);
  34178. return Constructor;
  34179. };
  34180. }();
  34181. var defineProperty = function (obj, key, value) {
  34182. if (key in obj) {
  34183. Object.defineProperty(obj, key, {
  34184. value: value,
  34185. enumerable: true,
  34186. configurable: true,
  34187. writable: true
  34188. });
  34189. } else {
  34190. obj[key] = value;
  34191. }
  34192. return obj;
  34193. };
  34194. var _extends = Object.assign || function (target) {
  34195. for (var i = 1; i < arguments.length; i++) {
  34196. var source = arguments[i];
  34197. for (var key in source) {
  34198. if (Object.prototype.hasOwnProperty.call(source, key)) {
  34199. target[key] = source[key];
  34200. }
  34201. }
  34202. }
  34203. return target;
  34204. };
  34205. /**
  34206. * Given element offsets, generate an output similar to getBoundingClientRect
  34207. * @method
  34208. * @memberof Popper.Utils
  34209. * @argument {Object} offsets
  34210. * @returns {Object} ClientRect like output
  34211. */
  34212. function getClientRect(offsets) {
  34213. return _extends({}, offsets, {
  34214. right: offsets.left + offsets.width,
  34215. bottom: offsets.top + offsets.height
  34216. });
  34217. }
  34218. /**
  34219. * Get bounding client rect of given element
  34220. * @method
  34221. * @memberof Popper.Utils
  34222. * @param {HTMLElement} element
  34223. * @return {Object} client rect
  34224. */
  34225. function getBoundingClientRect(element) {
  34226. var rect = {};
  34227. // IE10 10 FIX: Please, don't ask, the element isn't
  34228. // considered in DOM in some circumstances...
  34229. // This isn't reproducible in IE10 compatibility mode of IE11
  34230. try {
  34231. if (isIE(10)) {
  34232. rect = element.getBoundingClientRect();
  34233. var scrollTop = getScroll(element, 'top');
  34234. var scrollLeft = getScroll(element, 'left');
  34235. rect.top += scrollTop;
  34236. rect.left += scrollLeft;
  34237. rect.bottom += scrollTop;
  34238. rect.right += scrollLeft;
  34239. } else {
  34240. rect = element.getBoundingClientRect();
  34241. }
  34242. } catch (e) {}
  34243. var result = {
  34244. left: rect.left,
  34245. top: rect.top,
  34246. width: rect.right - rect.left,
  34247. height: rect.bottom - rect.top
  34248. };
  34249. // subtract scrollbar size from sizes
  34250. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  34251. var width = sizes.width || element.clientWidth || result.width;
  34252. var height = sizes.height || element.clientHeight || result.height;
  34253. var horizScrollbar = element.offsetWidth - width;
  34254. var vertScrollbar = element.offsetHeight - height;
  34255. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  34256. // we make this check conditional for performance reasons
  34257. if (horizScrollbar || vertScrollbar) {
  34258. var styles = getStyleComputedProperty(element);
  34259. horizScrollbar -= getBordersSize(styles, 'x');
  34260. vertScrollbar -= getBordersSize(styles, 'y');
  34261. result.width -= horizScrollbar;
  34262. result.height -= vertScrollbar;
  34263. }
  34264. return getClientRect(result);
  34265. }
  34266. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  34267. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34268. var isIE10 = isIE(10);
  34269. var isHTML = parent.nodeName === 'HTML';
  34270. var childrenRect = getBoundingClientRect(children);
  34271. var parentRect = getBoundingClientRect(parent);
  34272. var scrollParent = getScrollParent(children);
  34273. var styles = getStyleComputedProperty(parent);
  34274. var borderTopWidth = parseFloat(styles.borderTopWidth);
  34275. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  34276. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  34277. if (fixedPosition && isHTML) {
  34278. parentRect.top = Math.max(parentRect.top, 0);
  34279. parentRect.left = Math.max(parentRect.left, 0);
  34280. }
  34281. var offsets = getClientRect({
  34282. top: childrenRect.top - parentRect.top - borderTopWidth,
  34283. left: childrenRect.left - parentRect.left - borderLeftWidth,
  34284. width: childrenRect.width,
  34285. height: childrenRect.height
  34286. });
  34287. offsets.marginTop = 0;
  34288. offsets.marginLeft = 0;
  34289. // Subtract margins of documentElement in case it's being used as parent
  34290. // we do this only on HTML because it's the only element that behaves
  34291. // differently when margins are applied to it. The margins are included in
  34292. // the box of the documentElement, in the other cases not.
  34293. if (!isIE10 && isHTML) {
  34294. var marginTop = parseFloat(styles.marginTop);
  34295. var marginLeft = parseFloat(styles.marginLeft);
  34296. offsets.top -= borderTopWidth - marginTop;
  34297. offsets.bottom -= borderTopWidth - marginTop;
  34298. offsets.left -= borderLeftWidth - marginLeft;
  34299. offsets.right -= borderLeftWidth - marginLeft;
  34300. // Attach marginTop and marginLeft because in some circumstances we may need them
  34301. offsets.marginTop = marginTop;
  34302. offsets.marginLeft = marginLeft;
  34303. }
  34304. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  34305. offsets = includeScroll(offsets, parent);
  34306. }
  34307. return offsets;
  34308. }
  34309. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  34310. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34311. var html = element.ownerDocument.documentElement;
  34312. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  34313. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  34314. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  34315. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  34316. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  34317. var offset = {
  34318. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  34319. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  34320. width: width,
  34321. height: height
  34322. };
  34323. return getClientRect(offset);
  34324. }
  34325. /**
  34326. * Check if the given element is fixed or is inside a fixed parent
  34327. * @method
  34328. * @memberof Popper.Utils
  34329. * @argument {Element} element
  34330. * @argument {Element} customContainer
  34331. * @returns {Boolean} answer to "isFixed?"
  34332. */
  34333. function isFixed(element) {
  34334. var nodeName = element.nodeName;
  34335. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34336. return false;
  34337. }
  34338. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  34339. return true;
  34340. }
  34341. var parentNode = getParentNode(element);
  34342. if (!parentNode) {
  34343. return false;
  34344. }
  34345. return isFixed(parentNode);
  34346. }
  34347. /**
  34348. * Finds the first parent of an element that has a transformed property defined
  34349. * @method
  34350. * @memberof Popper.Utils
  34351. * @argument {Element} element
  34352. * @returns {Element} first transformed parent or documentElement
  34353. */
  34354. function getFixedPositionOffsetParent(element) {
  34355. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34356. if (!element || !element.parentElement || isIE()) {
  34357. return document.documentElement;
  34358. }
  34359. var el = element.parentElement;
  34360. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  34361. el = el.parentElement;
  34362. }
  34363. return el || document.documentElement;
  34364. }
  34365. /**
  34366. * Computed the boundaries limits and return them
  34367. * @method
  34368. * @memberof Popper.Utils
  34369. * @param {HTMLElement} popper
  34370. * @param {HTMLElement} reference
  34371. * @param {number} padding
  34372. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  34373. * @param {Boolean} fixedPosition - Is in fixed position mode
  34374. * @returns {Object} Coordinates of the boundaries
  34375. */
  34376. function getBoundaries(popper, reference, padding, boundariesElement) {
  34377. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  34378. // NOTE: 1 DOM access here
  34379. var boundaries = { top: 0, left: 0 };
  34380. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34381. // Handle viewport case
  34382. if (boundariesElement === 'viewport') {
  34383. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  34384. } else {
  34385. // Handle other cases based on DOM element used as boundaries
  34386. var boundariesNode = void 0;
  34387. if (boundariesElement === 'scrollParent') {
  34388. boundariesNode = getScrollParent(getParentNode(reference));
  34389. if (boundariesNode.nodeName === 'BODY') {
  34390. boundariesNode = popper.ownerDocument.documentElement;
  34391. }
  34392. } else if (boundariesElement === 'window') {
  34393. boundariesNode = popper.ownerDocument.documentElement;
  34394. } else {
  34395. boundariesNode = boundariesElement;
  34396. }
  34397. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  34398. // In case of HTML, we need a different computation
  34399. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  34400. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  34401. height = _getWindowSizes.height,
  34402. width = _getWindowSizes.width;
  34403. boundaries.top += offsets.top - offsets.marginTop;
  34404. boundaries.bottom = height + offsets.top;
  34405. boundaries.left += offsets.left - offsets.marginLeft;
  34406. boundaries.right = width + offsets.left;
  34407. } else {
  34408. // for all the other DOM elements, this one is good
  34409. boundaries = offsets;
  34410. }
  34411. }
  34412. // Add paddings
  34413. padding = padding || 0;
  34414. var isPaddingNumber = typeof padding === 'number';
  34415. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  34416. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  34417. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  34418. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  34419. return boundaries;
  34420. }
  34421. function getArea(_ref) {
  34422. var width = _ref.width,
  34423. height = _ref.height;
  34424. return width * height;
  34425. }
  34426. /**
  34427. * Utility used to transform the `auto` placement to the placement with more
  34428. * available space.
  34429. * @method
  34430. * @memberof Popper.Utils
  34431. * @argument {Object} data - The data object generated by update method
  34432. * @argument {Object} options - Modifiers configuration and options
  34433. * @returns {Object} The data object, properly modified
  34434. */
  34435. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  34436. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  34437. if (placement.indexOf('auto') === -1) {
  34438. return placement;
  34439. }
  34440. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  34441. var rects = {
  34442. top: {
  34443. width: boundaries.width,
  34444. height: refRect.top - boundaries.top
  34445. },
  34446. right: {
  34447. width: boundaries.right - refRect.right,
  34448. height: boundaries.height
  34449. },
  34450. bottom: {
  34451. width: boundaries.width,
  34452. height: boundaries.bottom - refRect.bottom
  34453. },
  34454. left: {
  34455. width: refRect.left - boundaries.left,
  34456. height: boundaries.height
  34457. }
  34458. };
  34459. var sortedAreas = Object.keys(rects).map(function (key) {
  34460. return _extends({
  34461. key: key
  34462. }, rects[key], {
  34463. area: getArea(rects[key])
  34464. });
  34465. }).sort(function (a, b) {
  34466. return b.area - a.area;
  34467. });
  34468. var filteredAreas = sortedAreas.filter(function (_ref2) {
  34469. var width = _ref2.width,
  34470. height = _ref2.height;
  34471. return width >= popper.clientWidth && height >= popper.clientHeight;
  34472. });
  34473. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  34474. var variation = placement.split('-')[1];
  34475. return computedPlacement + (variation ? '-' + variation : '');
  34476. }
  34477. /**
  34478. * Get offsets to the reference element
  34479. * @method
  34480. * @memberof Popper.Utils
  34481. * @param {Object} state
  34482. * @param {Element} popper - the popper element
  34483. * @param {Element} reference - the reference element (the popper will be relative to this)
  34484. * @param {Element} fixedPosition - is in fixed position mode
  34485. * @returns {Object} An object containing the offsets which will be applied to the popper
  34486. */
  34487. function getReferenceOffsets(state, popper, reference) {
  34488. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  34489. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34490. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  34491. }
  34492. /**
  34493. * Get the outer sizes of the given element (offset size + margins)
  34494. * @method
  34495. * @memberof Popper.Utils
  34496. * @argument {Element} element
  34497. * @returns {Object} object containing width and height properties
  34498. */
  34499. function getOuterSizes(element) {
  34500. var window = element.ownerDocument.defaultView;
  34501. var styles = window.getComputedStyle(element);
  34502. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  34503. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  34504. var result = {
  34505. width: element.offsetWidth + y,
  34506. height: element.offsetHeight + x
  34507. };
  34508. return result;
  34509. }
  34510. /**
  34511. * Get the opposite placement of the given one
  34512. * @method
  34513. * @memberof Popper.Utils
  34514. * @argument {String} placement
  34515. * @returns {String} flipped placement
  34516. */
  34517. function getOppositePlacement(placement) {
  34518. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  34519. return placement.replace(/left|right|bottom|top/g, function (matched) {
  34520. return hash[matched];
  34521. });
  34522. }
  34523. /**
  34524. * Get offsets to the popper
  34525. * @method
  34526. * @memberof Popper.Utils
  34527. * @param {Object} position - CSS position the Popper will get applied
  34528. * @param {HTMLElement} popper - the popper element
  34529. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  34530. * @param {String} placement - one of the valid placement options
  34531. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  34532. */
  34533. function getPopperOffsets(popper, referenceOffsets, placement) {
  34534. placement = placement.split('-')[0];
  34535. // Get popper node sizes
  34536. var popperRect = getOuterSizes(popper);
  34537. // Add position, width and height to our offsets object
  34538. var popperOffsets = {
  34539. width: popperRect.width,
  34540. height: popperRect.height
  34541. };
  34542. // depending by the popper placement we have to compute its offsets slightly differently
  34543. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  34544. var mainSide = isHoriz ? 'top' : 'left';
  34545. var secondarySide = isHoriz ? 'left' : 'top';
  34546. var measurement = isHoriz ? 'height' : 'width';
  34547. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  34548. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  34549. if (placement === secondarySide) {
  34550. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  34551. } else {
  34552. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  34553. }
  34554. return popperOffsets;
  34555. }
  34556. /**
  34557. * Mimics the `find` method of Array
  34558. * @method
  34559. * @memberof Popper.Utils
  34560. * @argument {Array} arr
  34561. * @argument prop
  34562. * @argument value
  34563. * @returns index or -1
  34564. */
  34565. function find(arr, check) {
  34566. // use native find if supported
  34567. if (Array.prototype.find) {
  34568. return arr.find(check);
  34569. }
  34570. // use `filter` to obtain the same behavior of `find`
  34571. return arr.filter(check)[0];
  34572. }
  34573. /**
  34574. * Return the index of the matching object
  34575. * @method
  34576. * @memberof Popper.Utils
  34577. * @argument {Array} arr
  34578. * @argument prop
  34579. * @argument value
  34580. * @returns index or -1
  34581. */
  34582. function findIndex(arr, prop, value) {
  34583. // use native findIndex if supported
  34584. if (Array.prototype.findIndex) {
  34585. return arr.findIndex(function (cur) {
  34586. return cur[prop] === value;
  34587. });
  34588. }
  34589. // use `find` + `indexOf` if `findIndex` isn't supported
  34590. var match = find(arr, function (obj) {
  34591. return obj[prop] === value;
  34592. });
  34593. return arr.indexOf(match);
  34594. }
  34595. /**
  34596. * Loop trough the list of modifiers and run them in order,
  34597. * each of them will then edit the data object.
  34598. * @method
  34599. * @memberof Popper.Utils
  34600. * @param {dataObject} data
  34601. * @param {Array} modifiers
  34602. * @param {String} ends - Optional modifier name used as stopper
  34603. * @returns {dataObject}
  34604. */
  34605. function runModifiers(modifiers, data, ends) {
  34606. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  34607. modifiersToRun.forEach(function (modifier) {
  34608. if (modifier['function']) {
  34609. // eslint-disable-line dot-notation
  34610. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  34611. }
  34612. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  34613. if (modifier.enabled && isFunction(fn)) {
  34614. // Add properties to offsets to make them a complete clientRect object
  34615. // we do this before each modifier to make sure the previous one doesn't
  34616. // mess with these values
  34617. data.offsets.popper = getClientRect(data.offsets.popper);
  34618. data.offsets.reference = getClientRect(data.offsets.reference);
  34619. data = fn(data, modifier);
  34620. }
  34621. });
  34622. return data;
  34623. }
  34624. /**
  34625. * Updates the position of the popper, computing the new offsets and applying
  34626. * the new style.<br />
  34627. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  34628. * @method
  34629. * @memberof Popper
  34630. */
  34631. function update() {
  34632. // if popper is destroyed, don't perform any further update
  34633. if (this.state.isDestroyed) {
  34634. return;
  34635. }
  34636. var data = {
  34637. instance: this,
  34638. styles: {},
  34639. arrowStyles: {},
  34640. attributes: {},
  34641. flipped: false,
  34642. offsets: {}
  34643. };
  34644. // compute reference element offsets
  34645. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  34646. // compute auto placement, store placement inside the data object,
  34647. // modifiers will be able to edit `placement` if needed
  34648. // and refer to originalPlacement to know the original value
  34649. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  34650. // store the computed placement inside `originalPlacement`
  34651. data.originalPlacement = data.placement;
  34652. data.positionFixed = this.options.positionFixed;
  34653. // compute the popper offsets
  34654. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  34655. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  34656. // run the modifiers
  34657. data = runModifiers(this.modifiers, data);
  34658. // the first `update` will call `onCreate` callback
  34659. // the other ones will call `onUpdate` callback
  34660. if (!this.state.isCreated) {
  34661. this.state.isCreated = true;
  34662. this.options.onCreate(data);
  34663. } else {
  34664. this.options.onUpdate(data);
  34665. }
  34666. }
  34667. /**
  34668. * Helper used to know if the given modifier is enabled.
  34669. * @method
  34670. * @memberof Popper.Utils
  34671. * @returns {Boolean}
  34672. */
  34673. function isModifierEnabled(modifiers, modifierName) {
  34674. return modifiers.some(function (_ref) {
  34675. var name = _ref.name,
  34676. enabled = _ref.enabled;
  34677. return enabled && name === modifierName;
  34678. });
  34679. }
  34680. /**
  34681. * Get the prefixed supported property name
  34682. * @method
  34683. * @memberof Popper.Utils
  34684. * @argument {String} property (camelCase)
  34685. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  34686. */
  34687. function getSupportedPropertyName(property) {
  34688. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  34689. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  34690. for (var i = 0; i < prefixes.length; i++) {
  34691. var prefix = prefixes[i];
  34692. var toCheck = prefix ? '' + prefix + upperProp : property;
  34693. if (typeof document.body.style[toCheck] !== 'undefined') {
  34694. return toCheck;
  34695. }
  34696. }
  34697. return null;
  34698. }
  34699. /**
  34700. * Destroys the popper.
  34701. * @method
  34702. * @memberof Popper
  34703. */
  34704. function destroy() {
  34705. this.state.isDestroyed = true;
  34706. // touch DOM only if `applyStyle` modifier is enabled
  34707. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  34708. this.popper.removeAttribute('x-placement');
  34709. this.popper.style.position = '';
  34710. this.popper.style.top = '';
  34711. this.popper.style.left = '';
  34712. this.popper.style.right = '';
  34713. this.popper.style.bottom = '';
  34714. this.popper.style.willChange = '';
  34715. this.popper.style[getSupportedPropertyName('transform')] = '';
  34716. }
  34717. this.disableEventListeners();
  34718. // remove the popper if user explicitly asked for the deletion on destroy
  34719. // do not use `remove` because IE11 doesn't support it
  34720. if (this.options.removeOnDestroy) {
  34721. this.popper.parentNode.removeChild(this.popper);
  34722. }
  34723. return this;
  34724. }
  34725. /**
  34726. * Get the window associated with the element
  34727. * @argument {Element} element
  34728. * @returns {Window}
  34729. */
  34730. function getWindow(element) {
  34731. var ownerDocument = element.ownerDocument;
  34732. return ownerDocument ? ownerDocument.defaultView : window;
  34733. }
  34734. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  34735. var isBody = scrollParent.nodeName === 'BODY';
  34736. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  34737. target.addEventListener(event, callback, { passive: true });
  34738. if (!isBody) {
  34739. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  34740. }
  34741. scrollParents.push(target);
  34742. }
  34743. /**
  34744. * Setup needed event listeners used to update the popper position
  34745. * @method
  34746. * @memberof Popper.Utils
  34747. * @private
  34748. */
  34749. function setupEventListeners(reference, options, state, updateBound) {
  34750. // Resize event listener on window
  34751. state.updateBound = updateBound;
  34752. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  34753. // Scroll event listener on scroll parents
  34754. var scrollElement = getScrollParent(reference);
  34755. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  34756. state.scrollElement = scrollElement;
  34757. state.eventsEnabled = true;
  34758. return state;
  34759. }
  34760. /**
  34761. * It will add resize/scroll events and start recalculating
  34762. * position of the popper element when they are triggered.
  34763. * @method
  34764. * @memberof Popper
  34765. */
  34766. function enableEventListeners() {
  34767. if (!this.state.eventsEnabled) {
  34768. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  34769. }
  34770. }
  34771. /**
  34772. * Remove event listeners used to update the popper position
  34773. * @method
  34774. * @memberof Popper.Utils
  34775. * @private
  34776. */
  34777. function removeEventListeners(reference, state) {
  34778. // Remove resize event listener on window
  34779. getWindow(reference).removeEventListener('resize', state.updateBound);
  34780. // Remove scroll event listener on scroll parents
  34781. state.scrollParents.forEach(function (target) {
  34782. target.removeEventListener('scroll', state.updateBound);
  34783. });
  34784. // Reset state
  34785. state.updateBound = null;
  34786. state.scrollParents = [];
  34787. state.scrollElement = null;
  34788. state.eventsEnabled = false;
  34789. return state;
  34790. }
  34791. /**
  34792. * It will remove resize/scroll events and won't recalculate popper position
  34793. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  34794. * unless you call `update` method manually.
  34795. * @method
  34796. * @memberof Popper
  34797. */
  34798. function disableEventListeners() {
  34799. if (this.state.eventsEnabled) {
  34800. cancelAnimationFrame(this.scheduleUpdate);
  34801. this.state = removeEventListeners(this.reference, this.state);
  34802. }
  34803. }
  34804. /**
  34805. * Tells if a given input is a number
  34806. * @method
  34807. * @memberof Popper.Utils
  34808. * @param {*} input to check
  34809. * @return {Boolean}
  34810. */
  34811. function isNumeric(n) {
  34812. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  34813. }
  34814. /**
  34815. * Set the style to the given popper
  34816. * @method
  34817. * @memberof Popper.Utils
  34818. * @argument {Element} element - Element to apply the style to
  34819. * @argument {Object} styles
  34820. * Object with a list of properties and values which will be applied to the element
  34821. */
  34822. function setStyles(element, styles) {
  34823. Object.keys(styles).forEach(function (prop) {
  34824. var unit = '';
  34825. // add unit if the value is numeric and is one of the following
  34826. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  34827. unit = 'px';
  34828. }
  34829. element.style[prop] = styles[prop] + unit;
  34830. });
  34831. }
  34832. /**
  34833. * Set the attributes to the given popper
  34834. * @method
  34835. * @memberof Popper.Utils
  34836. * @argument {Element} element - Element to apply the attributes to
  34837. * @argument {Object} styles
  34838. * Object with a list of properties and values which will be applied to the element
  34839. */
  34840. function setAttributes(element, attributes) {
  34841. Object.keys(attributes).forEach(function (prop) {
  34842. var value = attributes[prop];
  34843. if (value !== false) {
  34844. element.setAttribute(prop, attributes[prop]);
  34845. } else {
  34846. element.removeAttribute(prop);
  34847. }
  34848. });
  34849. }
  34850. /**
  34851. * @function
  34852. * @memberof Modifiers
  34853. * @argument {Object} data - The data object generated by `update` method
  34854. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  34855. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  34856. * @argument {Object} options - Modifiers configuration and options
  34857. * @returns {Object} The same data object
  34858. */
  34859. function applyStyle(data) {
  34860. // any property present in `data.styles` will be applied to the popper,
  34861. // in this way we can make the 3rd party modifiers add custom styles to it
  34862. // Be aware, modifiers could override the properties defined in the previous
  34863. // lines of this modifier!
  34864. setStyles(data.instance.popper, data.styles);
  34865. // any property present in `data.attributes` will be applied to the popper,
  34866. // they will be set as HTML attributes of the element
  34867. setAttributes(data.instance.popper, data.attributes);
  34868. // if arrowElement is defined and arrowStyles has some properties
  34869. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  34870. setStyles(data.arrowElement, data.arrowStyles);
  34871. }
  34872. return data;
  34873. }
  34874. /**
  34875. * Set the x-placement attribute before everything else because it could be used
  34876. * to add margins to the popper margins needs to be calculated to get the
  34877. * correct popper offsets.
  34878. * @method
  34879. * @memberof Popper.modifiers
  34880. * @param {HTMLElement} reference - The reference element used to position the popper
  34881. * @param {HTMLElement} popper - The HTML element used as popper
  34882. * @param {Object} options - Popper.js options
  34883. */
  34884. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  34885. // compute reference element offsets
  34886. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  34887. // compute auto placement, store placement inside the data object,
  34888. // modifiers will be able to edit `placement` if needed
  34889. // and refer to originalPlacement to know the original value
  34890. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  34891. popper.setAttribute('x-placement', placement);
  34892. // Apply `position` to popper before anything else because
  34893. // without the position applied we can't guarantee correct computations
  34894. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  34895. return options;
  34896. }
  34897. /**
  34898. * @function
  34899. * @memberof Popper.Utils
  34900. * @argument {Object} data - The data object generated by `update` method
  34901. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  34902. * @returns {Object} The popper's position offsets rounded
  34903. *
  34904. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  34905. * good as it can be within reason.
  34906. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  34907. *
  34908. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  34909. * as well on High DPI screens).
  34910. *
  34911. * Firefox prefers no rounding for positioning and does not have blurriness on
  34912. * high DPI screens.
  34913. *
  34914. * Only horizontal placement and left/right values need to be considered.
  34915. */
  34916. function getRoundedOffsets(data, shouldRound) {
  34917. var _data$offsets = data.offsets,
  34918. popper = _data$offsets.popper,
  34919. reference = _data$offsets.reference;
  34920. var round = Math.round,
  34921. floor = Math.floor;
  34922. var noRound = function noRound(v) {
  34923. return v;
  34924. };
  34925. var referenceWidth = round(reference.width);
  34926. var popperWidth = round(popper.width);
  34927. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  34928. var isVariation = data.placement.indexOf('-') !== -1;
  34929. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  34930. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  34931. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  34932. var verticalToInteger = !shouldRound ? noRound : round;
  34933. return {
  34934. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  34935. top: verticalToInteger(popper.top),
  34936. bottom: verticalToInteger(popper.bottom),
  34937. right: horizontalToInteger(popper.right)
  34938. };
  34939. }
  34940. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  34941. /**
  34942. * @function
  34943. * @memberof Modifiers
  34944. * @argument {Object} data - The data object generated by `update` method
  34945. * @argument {Object} options - Modifiers configuration and options
  34946. * @returns {Object} The data object, properly modified
  34947. */
  34948. function computeStyle(data, options) {
  34949. var x = options.x,
  34950. y = options.y;
  34951. var popper = data.offsets.popper;
  34952. // Remove this legacy support in Popper.js v2
  34953. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  34954. return modifier.name === 'applyStyle';
  34955. }).gpuAcceleration;
  34956. if (legacyGpuAccelerationOption !== undefined) {
  34957. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  34958. }
  34959. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  34960. var offsetParent = getOffsetParent(data.instance.popper);
  34961. var offsetParentRect = getBoundingClientRect(offsetParent);
  34962. // Styles
  34963. var styles = {
  34964. position: popper.position
  34965. };
  34966. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  34967. var sideA = x === 'bottom' ? 'top' : 'bottom';
  34968. var sideB = y === 'right' ? 'left' : 'right';
  34969. // if gpuAcceleration is set to `true` and transform is supported,
  34970. // we use `translate3d` to apply the position to the popper we
  34971. // automatically use the supported prefixed version if needed
  34972. var prefixedProperty = getSupportedPropertyName('transform');
  34973. // now, let's make a step back and look at this code closely (wtf?)
  34974. // If the content of the popper grows once it's been positioned, it
  34975. // may happen that the popper gets misplaced because of the new content
  34976. // overflowing its reference element
  34977. // To avoid this problem, we provide two options (x and y), which allow
  34978. // the consumer to define the offset origin.
  34979. // If we position a popper on top of a reference element, we can set
  34980. // `x` to `top` to make the popper grow towards its top instead of
  34981. // its bottom.
  34982. var left = void 0,
  34983. top = void 0;
  34984. if (sideA === 'bottom') {
  34985. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  34986. // and not the bottom of the html element
  34987. if (offsetParent.nodeName === 'HTML') {
  34988. top = -offsetParent.clientHeight + offsets.bottom;
  34989. } else {
  34990. top = -offsetParentRect.height + offsets.bottom;
  34991. }
  34992. } else {
  34993. top = offsets.top;
  34994. }
  34995. if (sideB === 'right') {
  34996. if (offsetParent.nodeName === 'HTML') {
  34997. left = -offsetParent.clientWidth + offsets.right;
  34998. } else {
  34999. left = -offsetParentRect.width + offsets.right;
  35000. }
  35001. } else {
  35002. left = offsets.left;
  35003. }
  35004. if (gpuAcceleration && prefixedProperty) {
  35005. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  35006. styles[sideA] = 0;
  35007. styles[sideB] = 0;
  35008. styles.willChange = 'transform';
  35009. } else {
  35010. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  35011. var invertTop = sideA === 'bottom' ? -1 : 1;
  35012. var invertLeft = sideB === 'right' ? -1 : 1;
  35013. styles[sideA] = top * invertTop;
  35014. styles[sideB] = left * invertLeft;
  35015. styles.willChange = sideA + ', ' + sideB;
  35016. }
  35017. // Attributes
  35018. var attributes = {
  35019. 'x-placement': data.placement
  35020. };
  35021. // Update `data` attributes, styles and arrowStyles
  35022. data.attributes = _extends({}, attributes, data.attributes);
  35023. data.styles = _extends({}, styles, data.styles);
  35024. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  35025. return data;
  35026. }
  35027. /**
  35028. * Helper used to know if the given modifier depends from another one.<br />
  35029. * It checks if the needed modifier is listed and enabled.
  35030. * @method
  35031. * @memberof Popper.Utils
  35032. * @param {Array} modifiers - list of modifiers
  35033. * @param {String} requestingName - name of requesting modifier
  35034. * @param {String} requestedName - name of requested modifier
  35035. * @returns {Boolean}
  35036. */
  35037. function isModifierRequired(modifiers, requestingName, requestedName) {
  35038. var requesting = find(modifiers, function (_ref) {
  35039. var name = _ref.name;
  35040. return name === requestingName;
  35041. });
  35042. var isRequired = !!requesting && modifiers.some(function (modifier) {
  35043. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  35044. });
  35045. if (!isRequired) {
  35046. var _requesting = '`' + requestingName + '`';
  35047. var requested = '`' + requestedName + '`';
  35048. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  35049. }
  35050. return isRequired;
  35051. }
  35052. /**
  35053. * @function
  35054. * @memberof Modifiers
  35055. * @argument {Object} data - The data object generated by update method
  35056. * @argument {Object} options - Modifiers configuration and options
  35057. * @returns {Object} The data object, properly modified
  35058. */
  35059. function arrow(data, options) {
  35060. var _data$offsets$arrow;
  35061. // arrow depends on keepTogether in order to work
  35062. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  35063. return data;
  35064. }
  35065. var arrowElement = options.element;
  35066. // if arrowElement is a string, suppose it's a CSS selector
  35067. if (typeof arrowElement === 'string') {
  35068. arrowElement = data.instance.popper.querySelector(arrowElement);
  35069. // if arrowElement is not found, don't run the modifier
  35070. if (!arrowElement) {
  35071. return data;
  35072. }
  35073. } else {
  35074. // if the arrowElement isn't a query selector we must check that the
  35075. // provided DOM node is child of its popper node
  35076. if (!data.instance.popper.contains(arrowElement)) {
  35077. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  35078. return data;
  35079. }
  35080. }
  35081. var placement = data.placement.split('-')[0];
  35082. var _data$offsets = data.offsets,
  35083. popper = _data$offsets.popper,
  35084. reference = _data$offsets.reference;
  35085. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  35086. var len = isVertical ? 'height' : 'width';
  35087. var sideCapitalized = isVertical ? 'Top' : 'Left';
  35088. var side = sideCapitalized.toLowerCase();
  35089. var altSide = isVertical ? 'left' : 'top';
  35090. var opSide = isVertical ? 'bottom' : 'right';
  35091. var arrowElementSize = getOuterSizes(arrowElement)[len];
  35092. //
  35093. // extends keepTogether behavior making sure the popper and its
  35094. // reference have enough pixels in conjunction
  35095. //
  35096. // top/left side
  35097. if (reference[opSide] - arrowElementSize < popper[side]) {
  35098. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  35099. }
  35100. // bottom/right side
  35101. if (reference[side] + arrowElementSize > popper[opSide]) {
  35102. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  35103. }
  35104. data.offsets.popper = getClientRect(data.offsets.popper);
  35105. // compute center of the popper
  35106. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  35107. // Compute the sideValue using the updated popper offsets
  35108. // take popper margin in account because we don't have this info available
  35109. var css = getStyleComputedProperty(data.instance.popper);
  35110. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  35111. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  35112. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  35113. // prevent arrowElement from being placed not contiguously to its popper
  35114. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  35115. data.arrowElement = arrowElement;
  35116. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  35117. return data;
  35118. }
  35119. /**
  35120. * Get the opposite placement variation of the given one
  35121. * @method
  35122. * @memberof Popper.Utils
  35123. * @argument {String} placement variation
  35124. * @returns {String} flipped placement variation
  35125. */
  35126. function getOppositeVariation(variation) {
  35127. if (variation === 'end') {
  35128. return 'start';
  35129. } else if (variation === 'start') {
  35130. return 'end';
  35131. }
  35132. return variation;
  35133. }
  35134. /**
  35135. * List of accepted placements to use as values of the `placement` option.<br />
  35136. * Valid placements are:
  35137. * - `auto`
  35138. * - `top`
  35139. * - `right`
  35140. * - `bottom`
  35141. * - `left`
  35142. *
  35143. * Each placement can have a variation from this list:
  35144. * - `-start`
  35145. * - `-end`
  35146. *
  35147. * Variations are interpreted easily if you think of them as the left to right
  35148. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  35149. * is right.<br />
  35150. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  35151. *
  35152. * Some valid examples are:
  35153. * - `top-end` (on top of reference, right aligned)
  35154. * - `right-start` (on right of reference, top aligned)
  35155. * - `bottom` (on bottom, centered)
  35156. * - `auto-end` (on the side with more space available, alignment depends by placement)
  35157. *
  35158. * @static
  35159. * @type {Array}
  35160. * @enum {String}
  35161. * @readonly
  35162. * @method placements
  35163. * @memberof Popper
  35164. */
  35165. 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'];
  35166. // Get rid of `auto` `auto-start` and `auto-end`
  35167. var validPlacements = placements.slice(3);
  35168. /**
  35169. * Given an initial placement, returns all the subsequent placements
  35170. * clockwise (or counter-clockwise).
  35171. *
  35172. * @method
  35173. * @memberof Popper.Utils
  35174. * @argument {String} placement - A valid placement (it accepts variations)
  35175. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  35176. * @returns {Array} placements including their variations
  35177. */
  35178. function clockwise(placement) {
  35179. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  35180. var index = validPlacements.indexOf(placement);
  35181. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  35182. return counter ? arr.reverse() : arr;
  35183. }
  35184. var BEHAVIORS = {
  35185. FLIP: 'flip',
  35186. CLOCKWISE: 'clockwise',
  35187. COUNTERCLOCKWISE: 'counterclockwise'
  35188. };
  35189. /**
  35190. * @function
  35191. * @memberof Modifiers
  35192. * @argument {Object} data - The data object generated by update method
  35193. * @argument {Object} options - Modifiers configuration and options
  35194. * @returns {Object} The data object, properly modified
  35195. */
  35196. function flip(data, options) {
  35197. // if `inner` modifier is enabled, we can't use the `flip` modifier
  35198. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  35199. return data;
  35200. }
  35201. if (data.flipped && data.placement === data.originalPlacement) {
  35202. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  35203. return data;
  35204. }
  35205. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  35206. var placement = data.placement.split('-')[0];
  35207. var placementOpposite = getOppositePlacement(placement);
  35208. var variation = data.placement.split('-')[1] || '';
  35209. var flipOrder = [];
  35210. switch (options.behavior) {
  35211. case BEHAVIORS.FLIP:
  35212. flipOrder = [placement, placementOpposite];
  35213. break;
  35214. case BEHAVIORS.CLOCKWISE:
  35215. flipOrder = clockwise(placement);
  35216. break;
  35217. case BEHAVIORS.COUNTERCLOCKWISE:
  35218. flipOrder = clockwise(placement, true);
  35219. break;
  35220. default:
  35221. flipOrder = options.behavior;
  35222. }
  35223. flipOrder.forEach(function (step, index) {
  35224. if (placement !== step || flipOrder.length === index + 1) {
  35225. return data;
  35226. }
  35227. placement = data.placement.split('-')[0];
  35228. placementOpposite = getOppositePlacement(placement);
  35229. var popperOffsets = data.offsets.popper;
  35230. var refOffsets = data.offsets.reference;
  35231. // using floor because the reference offsets may contain decimals we are not going to consider here
  35232. var floor = Math.floor;
  35233. 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);
  35234. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  35235. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  35236. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  35237. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  35238. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  35239. // flip the variation if required
  35240. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35241. // flips variation if reference element overflows boundaries
  35242. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  35243. // flips variation if popper content overflows boundaries
  35244. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  35245. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  35246. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  35247. // this boolean to detect any flip loop
  35248. data.flipped = true;
  35249. if (overlapsRef || overflowsBoundaries) {
  35250. placement = flipOrder[index + 1];
  35251. }
  35252. if (flippedVariation) {
  35253. variation = getOppositeVariation(variation);
  35254. }
  35255. data.placement = placement + (variation ? '-' + variation : '');
  35256. // this object contains `position`, we want to preserve it along with
  35257. // any additional property we may add in the future
  35258. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  35259. data = runModifiers(data.instance.modifiers, data, 'flip');
  35260. }
  35261. });
  35262. return data;
  35263. }
  35264. /**
  35265. * @function
  35266. * @memberof Modifiers
  35267. * @argument {Object} data - The data object generated by update method
  35268. * @argument {Object} options - Modifiers configuration and options
  35269. * @returns {Object} The data object, properly modified
  35270. */
  35271. function keepTogether(data) {
  35272. var _data$offsets = data.offsets,
  35273. popper = _data$offsets.popper,
  35274. reference = _data$offsets.reference;
  35275. var placement = data.placement.split('-')[0];
  35276. var floor = Math.floor;
  35277. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35278. var side = isVertical ? 'right' : 'bottom';
  35279. var opSide = isVertical ? 'left' : 'top';
  35280. var measurement = isVertical ? 'width' : 'height';
  35281. if (popper[side] < floor(reference[opSide])) {
  35282. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  35283. }
  35284. if (popper[opSide] > floor(reference[side])) {
  35285. data.offsets.popper[opSide] = floor(reference[side]);
  35286. }
  35287. return data;
  35288. }
  35289. /**
  35290. * Converts a string containing value + unit into a px value number
  35291. * @function
  35292. * @memberof {modifiers~offset}
  35293. * @private
  35294. * @argument {String} str - Value + unit string
  35295. * @argument {String} measurement - `height` or `width`
  35296. * @argument {Object} popperOffsets
  35297. * @argument {Object} referenceOffsets
  35298. * @returns {Number|String}
  35299. * Value in pixels, or original string if no values were extracted
  35300. */
  35301. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  35302. // separate value from unit
  35303. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  35304. var value = +split[1];
  35305. var unit = split[2];
  35306. // If it's not a number it's an operator, I guess
  35307. if (!value) {
  35308. return str;
  35309. }
  35310. if (unit.indexOf('%') === 0) {
  35311. var element = void 0;
  35312. switch (unit) {
  35313. case '%p':
  35314. element = popperOffsets;
  35315. break;
  35316. case '%':
  35317. case '%r':
  35318. default:
  35319. element = referenceOffsets;
  35320. }
  35321. var rect = getClientRect(element);
  35322. return rect[measurement] / 100 * value;
  35323. } else if (unit === 'vh' || unit === 'vw') {
  35324. // if is a vh or vw, we calculate the size based on the viewport
  35325. var size = void 0;
  35326. if (unit === 'vh') {
  35327. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  35328. } else {
  35329. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  35330. }
  35331. return size / 100 * value;
  35332. } else {
  35333. // if is an explicit pixel unit, we get rid of the unit and keep the value
  35334. // if is an implicit unit, it's px, and we return just the value
  35335. return value;
  35336. }
  35337. }
  35338. /**
  35339. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  35340. * @function
  35341. * @memberof {modifiers~offset}
  35342. * @private
  35343. * @argument {String} offset
  35344. * @argument {Object} popperOffsets
  35345. * @argument {Object} referenceOffsets
  35346. * @argument {String} basePlacement
  35347. * @returns {Array} a two cells array with x and y offsets in numbers
  35348. */
  35349. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  35350. var offsets = [0, 0];
  35351. // Use height if placement is left or right and index is 0 otherwise use width
  35352. // in this way the first offset will use an axis and the second one
  35353. // will use the other one
  35354. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  35355. // Split the offset string to obtain a list of values and operands
  35356. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  35357. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  35358. return frag.trim();
  35359. });
  35360. // Detect if the offset string contains a pair of values or a single one
  35361. // they could be separated by comma or space
  35362. var divider = fragments.indexOf(find(fragments, function (frag) {
  35363. return frag.search(/,|\s/) !== -1;
  35364. }));
  35365. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  35366. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  35367. }
  35368. // If divider is found, we divide the list of values and operands to divide
  35369. // them by ofset X and Y.
  35370. var splitRegex = /\s*,\s*|\s+/;
  35371. 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];
  35372. // Convert the values with units to absolute pixels to allow our computations
  35373. ops = ops.map(function (op, index) {
  35374. // Most of the units rely on the orientation of the popper
  35375. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  35376. var mergeWithPrevious = false;
  35377. return op
  35378. // This aggregates any `+` or `-` sign that aren't considered operators
  35379. // e.g.: 10 + +5 => [10, +, +5]
  35380. .reduce(function (a, b) {
  35381. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  35382. a[a.length - 1] = b;
  35383. mergeWithPrevious = true;
  35384. return a;
  35385. } else if (mergeWithPrevious) {
  35386. a[a.length - 1] += b;
  35387. mergeWithPrevious = false;
  35388. return a;
  35389. } else {
  35390. return a.concat(b);
  35391. }
  35392. }, [])
  35393. // Here we convert the string values into number values (in px)
  35394. .map(function (str) {
  35395. return toValue(str, measurement, popperOffsets, referenceOffsets);
  35396. });
  35397. });
  35398. // Loop trough the offsets arrays and execute the operations
  35399. ops.forEach(function (op, index) {
  35400. op.forEach(function (frag, index2) {
  35401. if (isNumeric(frag)) {
  35402. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  35403. }
  35404. });
  35405. });
  35406. return offsets;
  35407. }
  35408. /**
  35409. * @function
  35410. * @memberof Modifiers
  35411. * @argument {Object} data - The data object generated by update method
  35412. * @argument {Object} options - Modifiers configuration and options
  35413. * @argument {Number|String} options.offset=0
  35414. * The offset value as described in the modifier description
  35415. * @returns {Object} The data object, properly modified
  35416. */
  35417. function offset(data, _ref) {
  35418. var offset = _ref.offset;
  35419. var placement = data.placement,
  35420. _data$offsets = data.offsets,
  35421. popper = _data$offsets.popper,
  35422. reference = _data$offsets.reference;
  35423. var basePlacement = placement.split('-')[0];
  35424. var offsets = void 0;
  35425. if (isNumeric(+offset)) {
  35426. offsets = [+offset, 0];
  35427. } else {
  35428. offsets = parseOffset(offset, popper, reference, basePlacement);
  35429. }
  35430. if (basePlacement === 'left') {
  35431. popper.top += offsets[0];
  35432. popper.left -= offsets[1];
  35433. } else if (basePlacement === 'right') {
  35434. popper.top += offsets[0];
  35435. popper.left += offsets[1];
  35436. } else if (basePlacement === 'top') {
  35437. popper.left += offsets[0];
  35438. popper.top -= offsets[1];
  35439. } else if (basePlacement === 'bottom') {
  35440. popper.left += offsets[0];
  35441. popper.top += offsets[1];
  35442. }
  35443. data.popper = popper;
  35444. return data;
  35445. }
  35446. /**
  35447. * @function
  35448. * @memberof Modifiers
  35449. * @argument {Object} data - The data object generated by `update` method
  35450. * @argument {Object} options - Modifiers configuration and options
  35451. * @returns {Object} The data object, properly modified
  35452. */
  35453. function preventOverflow(data, options) {
  35454. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  35455. // If offsetParent is the reference element, we really want to
  35456. // go one step up and use the next offsetParent as reference to
  35457. // avoid to make this modifier completely useless and look like broken
  35458. if (data.instance.reference === boundariesElement) {
  35459. boundariesElement = getOffsetParent(boundariesElement);
  35460. }
  35461. // NOTE: DOM access here
  35462. // resets the popper's position so that the document size can be calculated excluding
  35463. // the size of the popper element itself
  35464. var transformProp = getSupportedPropertyName('transform');
  35465. var popperStyles = data.instance.popper.style; // assignment to help minification
  35466. var top = popperStyles.top,
  35467. left = popperStyles.left,
  35468. transform = popperStyles[transformProp];
  35469. popperStyles.top = '';
  35470. popperStyles.left = '';
  35471. popperStyles[transformProp] = '';
  35472. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  35473. // NOTE: DOM access here
  35474. // restores the original style properties after the offsets have been computed
  35475. popperStyles.top = top;
  35476. popperStyles.left = left;
  35477. popperStyles[transformProp] = transform;
  35478. options.boundaries = boundaries;
  35479. var order = options.priority;
  35480. var popper = data.offsets.popper;
  35481. var check = {
  35482. primary: function primary(placement) {
  35483. var value = popper[placement];
  35484. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  35485. value = Math.max(popper[placement], boundaries[placement]);
  35486. }
  35487. return defineProperty({}, placement, value);
  35488. },
  35489. secondary: function secondary(placement) {
  35490. var mainSide = placement === 'right' ? 'left' : 'top';
  35491. var value = popper[mainSide];
  35492. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  35493. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  35494. }
  35495. return defineProperty({}, mainSide, value);
  35496. }
  35497. };
  35498. order.forEach(function (placement) {
  35499. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  35500. popper = _extends({}, popper, check[side](placement));
  35501. });
  35502. data.offsets.popper = popper;
  35503. return data;
  35504. }
  35505. /**
  35506. * @function
  35507. * @memberof Modifiers
  35508. * @argument {Object} data - The data object generated by `update` method
  35509. * @argument {Object} options - Modifiers configuration and options
  35510. * @returns {Object} The data object, properly modified
  35511. */
  35512. function shift(data) {
  35513. var placement = data.placement;
  35514. var basePlacement = placement.split('-')[0];
  35515. var shiftvariation = placement.split('-')[1];
  35516. // if shift shiftvariation is specified, run the modifier
  35517. if (shiftvariation) {
  35518. var _data$offsets = data.offsets,
  35519. reference = _data$offsets.reference,
  35520. popper = _data$offsets.popper;
  35521. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  35522. var side = isVertical ? 'left' : 'top';
  35523. var measurement = isVertical ? 'width' : 'height';
  35524. var shiftOffsets = {
  35525. start: defineProperty({}, side, reference[side]),
  35526. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  35527. };
  35528. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  35529. }
  35530. return data;
  35531. }
  35532. /**
  35533. * @function
  35534. * @memberof Modifiers
  35535. * @argument {Object} data - The data object generated by update method
  35536. * @argument {Object} options - Modifiers configuration and options
  35537. * @returns {Object} The data object, properly modified
  35538. */
  35539. function hide(data) {
  35540. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  35541. return data;
  35542. }
  35543. var refRect = data.offsets.reference;
  35544. var bound = find(data.instance.modifiers, function (modifier) {
  35545. return modifier.name === 'preventOverflow';
  35546. }).boundaries;
  35547. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  35548. // Avoid unnecessary DOM access if visibility hasn't changed
  35549. if (data.hide === true) {
  35550. return data;
  35551. }
  35552. data.hide = true;
  35553. data.attributes['x-out-of-boundaries'] = '';
  35554. } else {
  35555. // Avoid unnecessary DOM access if visibility hasn't changed
  35556. if (data.hide === false) {
  35557. return data;
  35558. }
  35559. data.hide = false;
  35560. data.attributes['x-out-of-boundaries'] = false;
  35561. }
  35562. return data;
  35563. }
  35564. /**
  35565. * @function
  35566. * @memberof Modifiers
  35567. * @argument {Object} data - The data object generated by `update` method
  35568. * @argument {Object} options - Modifiers configuration and options
  35569. * @returns {Object} The data object, properly modified
  35570. */
  35571. function inner(data) {
  35572. var placement = data.placement;
  35573. var basePlacement = placement.split('-')[0];
  35574. var _data$offsets = data.offsets,
  35575. popper = _data$offsets.popper,
  35576. reference = _data$offsets.reference;
  35577. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  35578. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  35579. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  35580. data.placement = getOppositePlacement(placement);
  35581. data.offsets.popper = getClientRect(popper);
  35582. return data;
  35583. }
  35584. /**
  35585. * Modifier function, each modifier can have a function of this type assigned
  35586. * to its `fn` property.<br />
  35587. * These functions will be called on each update, this means that you must
  35588. * make sure they are performant enough to avoid performance bottlenecks.
  35589. *
  35590. * @function ModifierFn
  35591. * @argument {dataObject} data - The data object generated by `update` method
  35592. * @argument {Object} options - Modifiers configuration and options
  35593. * @returns {dataObject} The data object, properly modified
  35594. */
  35595. /**
  35596. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  35597. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  35598. * needed by the library.
  35599. *
  35600. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  35601. * All the other properties are configurations that could be tweaked.
  35602. * @namespace modifiers
  35603. */
  35604. var modifiers = {
  35605. /**
  35606. * Modifier used to shift the popper on the start or end of its reference
  35607. * element.<br />
  35608. * It will read the variation of the `placement` property.<br />
  35609. * It can be one either `-end` or `-start`.
  35610. * @memberof modifiers
  35611. * @inner
  35612. */
  35613. shift: {
  35614. /** @prop {number} order=100 - Index used to define the order of execution */
  35615. order: 100,
  35616. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35617. enabled: true,
  35618. /** @prop {ModifierFn} */
  35619. fn: shift
  35620. },
  35621. /**
  35622. * The `offset` modifier can shift your popper on both its axis.
  35623. *
  35624. * It accepts the following units:
  35625. * - `px` or unit-less, interpreted as pixels
  35626. * - `%` or `%r`, percentage relative to the length of the reference element
  35627. * - `%p`, percentage relative to the length of the popper element
  35628. * - `vw`, CSS viewport width unit
  35629. * - `vh`, CSS viewport height unit
  35630. *
  35631. * For length is intended the main axis relative to the placement of the popper.<br />
  35632. * This means that if the placement is `top` or `bottom`, the length will be the
  35633. * `width`. In case of `left` or `right`, it will be the `height`.
  35634. *
  35635. * You can provide a single value (as `Number` or `String`), or a pair of values
  35636. * as `String` divided by a comma or one (or more) white spaces.<br />
  35637. * The latter is a deprecated method because it leads to confusion and will be
  35638. * removed in v2.<br />
  35639. * Additionally, it accepts additions and subtractions between different units.
  35640. * Note that multiplications and divisions aren't supported.
  35641. *
  35642. * Valid examples are:
  35643. * ```
  35644. * 10
  35645. * '10%'
  35646. * '10, 10'
  35647. * '10%, 10'
  35648. * '10 + 10%'
  35649. * '10 - 5vh + 3%'
  35650. * '-10px + 5vh, 5px - 6%'
  35651. * ```
  35652. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  35653. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  35654. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  35655. *
  35656. * @memberof modifiers
  35657. * @inner
  35658. */
  35659. offset: {
  35660. /** @prop {number} order=200 - Index used to define the order of execution */
  35661. order: 200,
  35662. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35663. enabled: true,
  35664. /** @prop {ModifierFn} */
  35665. fn: offset,
  35666. /** @prop {Number|String} offset=0
  35667. * The offset value as described in the modifier description
  35668. */
  35669. offset: 0
  35670. },
  35671. /**
  35672. * Modifier used to prevent the popper from being positioned outside the boundary.
  35673. *
  35674. * A scenario exists where the reference itself is not within the boundaries.<br />
  35675. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  35676. * In this case we need to decide whether the popper should either:
  35677. *
  35678. * - detach from the reference and remain "trapped" in the boundaries, or
  35679. * - if it should ignore the boundary and "escape with its reference"
  35680. *
  35681. * When `escapeWithReference` is set to`true` and reference is completely
  35682. * outside its boundaries, the popper will overflow (or completely leave)
  35683. * the boundaries in order to remain attached to the edge of the reference.
  35684. *
  35685. * @memberof modifiers
  35686. * @inner
  35687. */
  35688. preventOverflow: {
  35689. /** @prop {number} order=300 - Index used to define the order of execution */
  35690. order: 300,
  35691. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35692. enabled: true,
  35693. /** @prop {ModifierFn} */
  35694. fn: preventOverflow,
  35695. /**
  35696. * @prop {Array} [priority=['left','right','top','bottom']]
  35697. * Popper will try to prevent overflow following these priorities by default,
  35698. * then, it could overflow on the left and on top of the `boundariesElement`
  35699. */
  35700. priority: ['left', 'right', 'top', 'bottom'],
  35701. /**
  35702. * @prop {number} padding=5
  35703. * Amount of pixel used to define a minimum distance between the boundaries
  35704. * and the popper. This makes sure the popper always has a little padding
  35705. * between the edges of its container
  35706. */
  35707. padding: 5,
  35708. /**
  35709. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  35710. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  35711. * `viewport` or any DOM element.
  35712. */
  35713. boundariesElement: 'scrollParent'
  35714. },
  35715. /**
  35716. * Modifier used to make sure the reference and its popper stay near each other
  35717. * without leaving any gap between the two. Especially useful when the arrow is
  35718. * enabled and you want to ensure that it points to its reference element.
  35719. * It cares only about the first axis. You can still have poppers with margin
  35720. * between the popper and its reference element.
  35721. * @memberof modifiers
  35722. * @inner
  35723. */
  35724. keepTogether: {
  35725. /** @prop {number} order=400 - Index used to define the order of execution */
  35726. order: 400,
  35727. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35728. enabled: true,
  35729. /** @prop {ModifierFn} */
  35730. fn: keepTogether
  35731. },
  35732. /**
  35733. * This modifier is used to move the `arrowElement` of the popper to make
  35734. * sure it is positioned between the reference element and its popper element.
  35735. * It will read the outer size of the `arrowElement` node to detect how many
  35736. * pixels of conjunction are needed.
  35737. *
  35738. * It has no effect if no `arrowElement` is provided.
  35739. * @memberof modifiers
  35740. * @inner
  35741. */
  35742. arrow: {
  35743. /** @prop {number} order=500 - Index used to define the order of execution */
  35744. order: 500,
  35745. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35746. enabled: true,
  35747. /** @prop {ModifierFn} */
  35748. fn: arrow,
  35749. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  35750. element: '[x-arrow]'
  35751. },
  35752. /**
  35753. * Modifier used to flip the popper's placement when it starts to overlap its
  35754. * reference element.
  35755. *
  35756. * Requires the `preventOverflow` modifier before it in order to work.
  35757. *
  35758. * **NOTE:** this modifier will interrupt the current update cycle and will
  35759. * restart it if it detects the need to flip the placement.
  35760. * @memberof modifiers
  35761. * @inner
  35762. */
  35763. flip: {
  35764. /** @prop {number} order=600 - Index used to define the order of execution */
  35765. order: 600,
  35766. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35767. enabled: true,
  35768. /** @prop {ModifierFn} */
  35769. fn: flip,
  35770. /**
  35771. * @prop {String|Array} behavior='flip'
  35772. * The behavior used to change the popper's placement. It can be one of
  35773. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  35774. * placements (with optional variations)
  35775. */
  35776. behavior: 'flip',
  35777. /**
  35778. * @prop {number} padding=5
  35779. * The popper will flip if it hits the edges of the `boundariesElement`
  35780. */
  35781. padding: 5,
  35782. /**
  35783. * @prop {String|HTMLElement} boundariesElement='viewport'
  35784. * The element which will define the boundaries of the popper position.
  35785. * The popper will never be placed outside of the defined boundaries
  35786. * (except if `keepTogether` is enabled)
  35787. */
  35788. boundariesElement: 'viewport',
  35789. /**
  35790. * @prop {Boolean} flipVariations=false
  35791. * The popper will switch placement variation between `-start` and `-end` when
  35792. * the reference element overlaps its boundaries.
  35793. *
  35794. * The original placement should have a set variation.
  35795. */
  35796. flipVariations: false,
  35797. /**
  35798. * @prop {Boolean} flipVariationsByContent=false
  35799. * The popper will switch placement variation between `-start` and `-end` when
  35800. * the popper element overlaps its reference boundaries.
  35801. *
  35802. * The original placement should have a set variation.
  35803. */
  35804. flipVariationsByContent: false
  35805. },
  35806. /**
  35807. * Modifier used to make the popper flow toward the inner of the reference element.
  35808. * By default, when this modifier is disabled, the popper will be placed outside
  35809. * the reference element.
  35810. * @memberof modifiers
  35811. * @inner
  35812. */
  35813. inner: {
  35814. /** @prop {number} order=700 - Index used to define the order of execution */
  35815. order: 700,
  35816. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  35817. enabled: false,
  35818. /** @prop {ModifierFn} */
  35819. fn: inner
  35820. },
  35821. /**
  35822. * Modifier used to hide the popper when its reference element is outside of the
  35823. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  35824. * be used to hide with a CSS selector the popper when its reference is
  35825. * out of boundaries.
  35826. *
  35827. * Requires the `preventOverflow` modifier before it in order to work.
  35828. * @memberof modifiers
  35829. * @inner
  35830. */
  35831. hide: {
  35832. /** @prop {number} order=800 - Index used to define the order of execution */
  35833. order: 800,
  35834. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35835. enabled: true,
  35836. /** @prop {ModifierFn} */
  35837. fn: hide
  35838. },
  35839. /**
  35840. * Computes the style that will be applied to the popper element to gets
  35841. * properly positioned.
  35842. *
  35843. * Note that this modifier will not touch the DOM, it just prepares the styles
  35844. * so that `applyStyle` modifier can apply it. This separation is useful
  35845. * in case you need to replace `applyStyle` with a custom implementation.
  35846. *
  35847. * This modifier has `850` as `order` value to maintain backward compatibility
  35848. * with previous versions of Popper.js. Expect the modifiers ordering method
  35849. * to change in future major versions of the library.
  35850. *
  35851. * @memberof modifiers
  35852. * @inner
  35853. */
  35854. computeStyle: {
  35855. /** @prop {number} order=850 - Index used to define the order of execution */
  35856. order: 850,
  35857. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35858. enabled: true,
  35859. /** @prop {ModifierFn} */
  35860. fn: computeStyle,
  35861. /**
  35862. * @prop {Boolean} gpuAcceleration=true
  35863. * If true, it uses the CSS 3D transformation to position the popper.
  35864. * Otherwise, it will use the `top` and `left` properties
  35865. */
  35866. gpuAcceleration: true,
  35867. /**
  35868. * @prop {string} [x='bottom']
  35869. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  35870. * Change this if your popper should grow in a direction different from `bottom`
  35871. */
  35872. x: 'bottom',
  35873. /**
  35874. * @prop {string} [x='left']
  35875. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  35876. * Change this if your popper should grow in a direction different from `right`
  35877. */
  35878. y: 'right'
  35879. },
  35880. /**
  35881. * Applies the computed styles to the popper element.
  35882. *
  35883. * All the DOM manipulations are limited to this modifier. This is useful in case
  35884. * you want to integrate Popper.js inside a framework or view library and you
  35885. * want to delegate all the DOM manipulations to it.
  35886. *
  35887. * Note that if you disable this modifier, you must make sure the popper element
  35888. * has its position set to `absolute` before Popper.js can do its work!
  35889. *
  35890. * Just disable this modifier and define your own to achieve the desired effect.
  35891. *
  35892. * @memberof modifiers
  35893. * @inner
  35894. */
  35895. applyStyle: {
  35896. /** @prop {number} order=900 - Index used to define the order of execution */
  35897. order: 900,
  35898. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35899. enabled: true,
  35900. /** @prop {ModifierFn} */
  35901. fn: applyStyle,
  35902. /** @prop {Function} */
  35903. onLoad: applyStyleOnLoad,
  35904. /**
  35905. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  35906. * @prop {Boolean} gpuAcceleration=true
  35907. * If true, it uses the CSS 3D transformation to position the popper.
  35908. * Otherwise, it will use the `top` and `left` properties
  35909. */
  35910. gpuAcceleration: undefined
  35911. }
  35912. };
  35913. /**
  35914. * The `dataObject` is an object containing all the information used by Popper.js.
  35915. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  35916. * @name dataObject
  35917. * @property {Object} data.instance The Popper.js instance
  35918. * @property {String} data.placement Placement applied to popper
  35919. * @property {String} data.originalPlacement Placement originally defined on init
  35920. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  35921. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  35922. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  35923. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35924. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35925. * @property {Object} data.boundaries Offsets of the popper boundaries
  35926. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  35927. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  35928. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  35929. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  35930. */
  35931. /**
  35932. * Default options provided to Popper.js constructor.<br />
  35933. * These can be overridden using the `options` argument of Popper.js.<br />
  35934. * To override an option, simply pass an object with the same
  35935. * structure of the `options` object, as the 3rd argument. For example:
  35936. * ```
  35937. * new Popper(ref, pop, {
  35938. * modifiers: {
  35939. * preventOverflow: { enabled: false }
  35940. * }
  35941. * })
  35942. * ```
  35943. * @type {Object}
  35944. * @static
  35945. * @memberof Popper
  35946. */
  35947. var Defaults = {
  35948. /**
  35949. * Popper's placement.
  35950. * @prop {Popper.placements} placement='bottom'
  35951. */
  35952. placement: 'bottom',
  35953. /**
  35954. * Set this to true if you want popper to position it self in 'fixed' mode
  35955. * @prop {Boolean} positionFixed=false
  35956. */
  35957. positionFixed: false,
  35958. /**
  35959. * Whether events (resize, scroll) are initially enabled.
  35960. * @prop {Boolean} eventsEnabled=true
  35961. */
  35962. eventsEnabled: true,
  35963. /**
  35964. * Set to true if you want to automatically remove the popper when
  35965. * you call the `destroy` method.
  35966. * @prop {Boolean} removeOnDestroy=false
  35967. */
  35968. removeOnDestroy: false,
  35969. /**
  35970. * Callback called when the popper is created.<br />
  35971. * By default, it is set to no-op.<br />
  35972. * Access Popper.js instance with `data.instance`.
  35973. * @prop {onCreate}
  35974. */
  35975. onCreate: function onCreate() {},
  35976. /**
  35977. * Callback called when the popper is updated. This callback is not called
  35978. * on the initialization/creation of the popper, but only on subsequent
  35979. * updates.<br />
  35980. * By default, it is set to no-op.<br />
  35981. * Access Popper.js instance with `data.instance`.
  35982. * @prop {onUpdate}
  35983. */
  35984. onUpdate: function onUpdate() {},
  35985. /**
  35986. * List of modifiers used to modify the offsets before they are applied to the popper.
  35987. * They provide most of the functionalities of Popper.js.
  35988. * @prop {modifiers}
  35989. */
  35990. modifiers: modifiers
  35991. };
  35992. /**
  35993. * @callback onCreate
  35994. * @param {dataObject} data
  35995. */
  35996. /**
  35997. * @callback onUpdate
  35998. * @param {dataObject} data
  35999. */
  36000. // Utils
  36001. // Methods
  36002. var Popper = function () {
  36003. /**
  36004. * Creates a new Popper.js instance.
  36005. * @class Popper
  36006. * @param {Element|referenceObject} reference - The reference element used to position the popper
  36007. * @param {Element} popper - The HTML / XML element used as the popper
  36008. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  36009. * @return {Object} instance - The generated Popper.js instance
  36010. */
  36011. function Popper(reference, popper) {
  36012. var _this = this;
  36013. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  36014. classCallCheck(this, Popper);
  36015. this.scheduleUpdate = function () {
  36016. return requestAnimationFrame(_this.update);
  36017. };
  36018. // make update() debounced, so that it only runs at most once-per-tick
  36019. this.update = debounce(this.update.bind(this));
  36020. // with {} we create a new object with the options inside it
  36021. this.options = _extends({}, Popper.Defaults, options);
  36022. // init state
  36023. this.state = {
  36024. isDestroyed: false,
  36025. isCreated: false,
  36026. scrollParents: []
  36027. };
  36028. // get reference and popper elements (allow jQuery wrappers)
  36029. this.reference = reference && reference.jquery ? reference[0] : reference;
  36030. this.popper = popper && popper.jquery ? popper[0] : popper;
  36031. // Deep merge modifiers options
  36032. this.options.modifiers = {};
  36033. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  36034. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  36035. });
  36036. // Refactoring modifiers' list (Object => Array)
  36037. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  36038. return _extends({
  36039. name: name
  36040. }, _this.options.modifiers[name]);
  36041. })
  36042. // sort the modifiers by order
  36043. .sort(function (a, b) {
  36044. return a.order - b.order;
  36045. });
  36046. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  36047. // such code is executed in the same order of its modifier
  36048. // they could add new properties to their options configuration
  36049. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  36050. this.modifiers.forEach(function (modifierOptions) {
  36051. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  36052. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  36053. }
  36054. });
  36055. // fire the first update to position the popper in the right place
  36056. this.update();
  36057. var eventsEnabled = this.options.eventsEnabled;
  36058. if (eventsEnabled) {
  36059. // setup event listeners, they will take care of update the position in specific situations
  36060. this.enableEventListeners();
  36061. }
  36062. this.state.eventsEnabled = eventsEnabled;
  36063. }
  36064. // We can't use class properties because they don't get listed in the
  36065. // class prototype and break stuff like Sinon stubs
  36066. createClass(Popper, [{
  36067. key: 'update',
  36068. value: function update$$1() {
  36069. return update.call(this);
  36070. }
  36071. }, {
  36072. key: 'destroy',
  36073. value: function destroy$$1() {
  36074. return destroy.call(this);
  36075. }
  36076. }, {
  36077. key: 'enableEventListeners',
  36078. value: function enableEventListeners$$1() {
  36079. return enableEventListeners.call(this);
  36080. }
  36081. }, {
  36082. key: 'disableEventListeners',
  36083. value: function disableEventListeners$$1() {
  36084. return disableEventListeners.call(this);
  36085. }
  36086. /**
  36087. * Schedules an update. It will run on the next UI update available.
  36088. * @method scheduleUpdate
  36089. * @memberof Popper
  36090. */
  36091. /**
  36092. * Collection of utilities useful when writing custom modifiers.
  36093. * Starting from version 1.7, this method is available only if you
  36094. * include `popper-utils.js` before `popper.js`.
  36095. *
  36096. * **DEPRECATION**: This way to access PopperUtils is deprecated
  36097. * and will be removed in v2! Use the PopperUtils module directly instead.
  36098. * Due to the high instability of the methods contained in Utils, we can't
  36099. * guarantee them to follow semver. Use them at your own risk!
  36100. * @static
  36101. * @private
  36102. * @type {Object}
  36103. * @deprecated since version 1.8
  36104. * @member Utils
  36105. * @memberof Popper
  36106. */
  36107. }]);
  36108. return Popper;
  36109. }();
  36110. /**
  36111. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  36112. * and lets you use it as replacement of a real DOM node.<br />
  36113. * You can use this method to position a popper relatively to a set of coordinates
  36114. * in case you don't have a DOM node to use as reference.
  36115. *
  36116. * ```
  36117. * new Popper(referenceObject, popperNode);
  36118. * ```
  36119. *
  36120. * NB: This feature isn't supported in Internet Explorer 10.
  36121. * @name referenceObject
  36122. * @property {Function} data.getBoundingClientRect
  36123. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  36124. * @property {number} data.clientWidth
  36125. * An ES6 getter that will return the width of the virtual reference element.
  36126. * @property {number} data.clientHeight
  36127. * An ES6 getter that will return the height of the virtual reference element.
  36128. */
  36129. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  36130. Popper.placements = placements;
  36131. Popper.Defaults = Defaults;
  36132. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  36133. //# sourceMappingURL=popper.js.map
  36134. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  36135. /***/ }),
  36136. /***/ "./node_modules/process/browser.js":
  36137. /*!*****************************************!*\
  36138. !*** ./node_modules/process/browser.js ***!
  36139. \*****************************************/
  36140. /*! no static exports found */
  36141. /***/ (function(module, exports) {
  36142. // shim for using process in browser
  36143. var process = module.exports = {};
  36144. // cached from whatever global is present so that test runners that stub it
  36145. // don't break things. But we need to wrap it in a try catch in case it is
  36146. // wrapped in strict mode code which doesn't define any globals. It's inside a
  36147. // function because try/catches deoptimize in certain engines.
  36148. var cachedSetTimeout;
  36149. var cachedClearTimeout;
  36150. function defaultSetTimout() {
  36151. throw new Error('setTimeout has not been defined');
  36152. }
  36153. function defaultClearTimeout () {
  36154. throw new Error('clearTimeout has not been defined');
  36155. }
  36156. (function () {
  36157. try {
  36158. if (typeof setTimeout === 'function') {
  36159. cachedSetTimeout = setTimeout;
  36160. } else {
  36161. cachedSetTimeout = defaultSetTimout;
  36162. }
  36163. } catch (e) {
  36164. cachedSetTimeout = defaultSetTimout;
  36165. }
  36166. try {
  36167. if (typeof clearTimeout === 'function') {
  36168. cachedClearTimeout = clearTimeout;
  36169. } else {
  36170. cachedClearTimeout = defaultClearTimeout;
  36171. }
  36172. } catch (e) {
  36173. cachedClearTimeout = defaultClearTimeout;
  36174. }
  36175. } ())
  36176. function runTimeout(fun) {
  36177. if (cachedSetTimeout === setTimeout) {
  36178. //normal enviroments in sane situations
  36179. return setTimeout(fun, 0);
  36180. }
  36181. // if setTimeout wasn't available but was latter defined
  36182. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  36183. cachedSetTimeout = setTimeout;
  36184. return setTimeout(fun, 0);
  36185. }
  36186. try {
  36187. // when when somebody has screwed with setTimeout but no I.E. maddness
  36188. return cachedSetTimeout(fun, 0);
  36189. } catch(e){
  36190. try {
  36191. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36192. return cachedSetTimeout.call(null, fun, 0);
  36193. } catch(e){
  36194. // 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
  36195. return cachedSetTimeout.call(this, fun, 0);
  36196. }
  36197. }
  36198. }
  36199. function runClearTimeout(marker) {
  36200. if (cachedClearTimeout === clearTimeout) {
  36201. //normal enviroments in sane situations
  36202. return clearTimeout(marker);
  36203. }
  36204. // if clearTimeout wasn't available but was latter defined
  36205. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  36206. cachedClearTimeout = clearTimeout;
  36207. return clearTimeout(marker);
  36208. }
  36209. try {
  36210. // when when somebody has screwed with setTimeout but no I.E. maddness
  36211. return cachedClearTimeout(marker);
  36212. } catch (e){
  36213. try {
  36214. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36215. return cachedClearTimeout.call(null, marker);
  36216. } catch (e){
  36217. // 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.
  36218. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  36219. return cachedClearTimeout.call(this, marker);
  36220. }
  36221. }
  36222. }
  36223. var queue = [];
  36224. var draining = false;
  36225. var currentQueue;
  36226. var queueIndex = -1;
  36227. function cleanUpNextTick() {
  36228. if (!draining || !currentQueue) {
  36229. return;
  36230. }
  36231. draining = false;
  36232. if (currentQueue.length) {
  36233. queue = currentQueue.concat(queue);
  36234. } else {
  36235. queueIndex = -1;
  36236. }
  36237. if (queue.length) {
  36238. drainQueue();
  36239. }
  36240. }
  36241. function drainQueue() {
  36242. if (draining) {
  36243. return;
  36244. }
  36245. var timeout = runTimeout(cleanUpNextTick);
  36246. draining = true;
  36247. var len = queue.length;
  36248. while(len) {
  36249. currentQueue = queue;
  36250. queue = [];
  36251. while (++queueIndex < len) {
  36252. if (currentQueue) {
  36253. currentQueue[queueIndex].run();
  36254. }
  36255. }
  36256. queueIndex = -1;
  36257. len = queue.length;
  36258. }
  36259. currentQueue = null;
  36260. draining = false;
  36261. runClearTimeout(timeout);
  36262. }
  36263. process.nextTick = function (fun) {
  36264. var args = new Array(arguments.length - 1);
  36265. if (arguments.length > 1) {
  36266. for (var i = 1; i < arguments.length; i++) {
  36267. args[i - 1] = arguments[i];
  36268. }
  36269. }
  36270. queue.push(new Item(fun, args));
  36271. if (queue.length === 1 && !draining) {
  36272. runTimeout(drainQueue);
  36273. }
  36274. };
  36275. // v8 likes predictible objects
  36276. function Item(fun, array) {
  36277. this.fun = fun;
  36278. this.array = array;
  36279. }
  36280. Item.prototype.run = function () {
  36281. this.fun.apply(null, this.array);
  36282. };
  36283. process.title = 'browser';
  36284. process.browser = true;
  36285. process.env = {};
  36286. process.argv = [];
  36287. process.version = ''; // empty string to avoid regexp issues
  36288. process.versions = {};
  36289. function noop() {}
  36290. process.on = noop;
  36291. process.addListener = noop;
  36292. process.once = noop;
  36293. process.off = noop;
  36294. process.removeListener = noop;
  36295. process.removeAllListeners = noop;
  36296. process.emit = noop;
  36297. process.prependListener = noop;
  36298. process.prependOnceListener = noop;
  36299. process.listeners = function (name) { return [] }
  36300. process.binding = function (name) {
  36301. throw new Error('process.binding is not supported');
  36302. };
  36303. process.cwd = function () { return '/' };
  36304. process.chdir = function (dir) {
  36305. throw new Error('process.chdir is not supported');
  36306. };
  36307. process.umask = function() { return 0; };
  36308. /***/ }),
  36309. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  36310. /*!***************************************************!*\
  36311. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  36312. \***************************************************/
  36313. /*! no static exports found */
  36314. /***/ (function(module, exports, __webpack_require__) {
  36315. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  36316. * Pusher JavaScript Library v5.0.3
  36317. * https://pusher.com/
  36318. *
  36319. * Copyright 2017, Pusher
  36320. * Released under the MIT licence.
  36321. */
  36322. (function webpackUniversalModuleDefinition(root, factory) {
  36323. if(true)
  36324. module.exports = factory();
  36325. else {}
  36326. })(window, function() {
  36327. return /******/ (function(modules) { // webpackBootstrap
  36328. /******/ // The module cache
  36329. /******/ var installedModules = {};
  36330. /******/
  36331. /******/ // The require function
  36332. /******/ function __webpack_require__(moduleId) {
  36333. /******/
  36334. /******/ // Check if module is in cache
  36335. /******/ if(installedModules[moduleId]) {
  36336. /******/ return installedModules[moduleId].exports;
  36337. /******/ }
  36338. /******/ // Create a new module (and put it into the cache)
  36339. /******/ var module = installedModules[moduleId] = {
  36340. /******/ i: moduleId,
  36341. /******/ l: false,
  36342. /******/ exports: {}
  36343. /******/ };
  36344. /******/
  36345. /******/ // Execute the module function
  36346. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  36347. /******/
  36348. /******/ // Flag the module as loaded
  36349. /******/ module.l = true;
  36350. /******/
  36351. /******/ // Return the exports of the module
  36352. /******/ return module.exports;
  36353. /******/ }
  36354. /******/
  36355. /******/
  36356. /******/ // expose the modules object (__webpack_modules__)
  36357. /******/ __webpack_require__.m = modules;
  36358. /******/
  36359. /******/ // expose the module cache
  36360. /******/ __webpack_require__.c = installedModules;
  36361. /******/
  36362. /******/ // define getter function for harmony exports
  36363. /******/ __webpack_require__.d = function(exports, name, getter) {
  36364. /******/ if(!__webpack_require__.o(exports, name)) {
  36365. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  36366. /******/ }
  36367. /******/ };
  36368. /******/
  36369. /******/ // define __esModule on exports
  36370. /******/ __webpack_require__.r = function(exports) {
  36371. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  36372. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  36373. /******/ }
  36374. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  36375. /******/ };
  36376. /******/
  36377. /******/ // create a fake namespace object
  36378. /******/ // mode & 1: value is a module id, require it
  36379. /******/ // mode & 2: merge all properties of value into the ns
  36380. /******/ // mode & 4: return value when already ns object
  36381. /******/ // mode & 8|1: behave like require
  36382. /******/ __webpack_require__.t = function(value, mode) {
  36383. /******/ if(mode & 1) value = __webpack_require__(value);
  36384. /******/ if(mode & 8) return value;
  36385. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  36386. /******/ var ns = Object.create(null);
  36387. /******/ __webpack_require__.r(ns);
  36388. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  36389. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  36390. /******/ return ns;
  36391. /******/ };
  36392. /******/
  36393. /******/ // getDefaultExport function for compatibility with non-harmony modules
  36394. /******/ __webpack_require__.n = function(module) {
  36395. /******/ var getter = module && module.__esModule ?
  36396. /******/ function getDefault() { return module['default']; } :
  36397. /******/ function getModuleExports() { return module; };
  36398. /******/ __webpack_require__.d(getter, 'a', getter);
  36399. /******/ return getter;
  36400. /******/ };
  36401. /******/
  36402. /******/ // Object.prototype.hasOwnProperty.call
  36403. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  36404. /******/
  36405. /******/ // __webpack_public_path__
  36406. /******/ __webpack_require__.p = "";
  36407. /******/
  36408. /******/
  36409. /******/ // Load entry module and return exports
  36410. /******/ return __webpack_require__(__webpack_require__.s = 2);
  36411. /******/ })
  36412. /************************************************************************/
  36413. /******/ ([
  36414. /* 0 */
  36415. /***/ (function(module, exports, __webpack_require__) {
  36416. (function(nacl) {
  36417. 'use strict';
  36418. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  36419. // Public domain.
  36420. //
  36421. // Implementation derived from TweetNaCl version 20140427.
  36422. // See for details: http://tweetnacl.cr.yp.to/
  36423. var gf = function(init) {
  36424. var i, r = new Float64Array(16);
  36425. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  36426. return r;
  36427. };
  36428. // Pluggable, initialized in high-level API below.
  36429. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  36430. var _0 = new Uint8Array(16);
  36431. var _9 = new Uint8Array(32); _9[0] = 9;
  36432. var gf0 = gf(),
  36433. gf1 = gf([1]),
  36434. _121665 = gf([0xdb41, 1]),
  36435. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  36436. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  36437. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  36438. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  36439. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  36440. function ts64(x, i, h, l) {
  36441. x[i] = (h >> 24) & 0xff;
  36442. x[i+1] = (h >> 16) & 0xff;
  36443. x[i+2] = (h >> 8) & 0xff;
  36444. x[i+3] = h & 0xff;
  36445. x[i+4] = (l >> 24) & 0xff;
  36446. x[i+5] = (l >> 16) & 0xff;
  36447. x[i+6] = (l >> 8) & 0xff;
  36448. x[i+7] = l & 0xff;
  36449. }
  36450. function vn(x, xi, y, yi, n) {
  36451. var i,d = 0;
  36452. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  36453. return (1 & ((d - 1) >>> 8)) - 1;
  36454. }
  36455. function crypto_verify_16(x, xi, y, yi) {
  36456. return vn(x,xi,y,yi,16);
  36457. }
  36458. function crypto_verify_32(x, xi, y, yi) {
  36459. return vn(x,xi,y,yi,32);
  36460. }
  36461. function core_salsa20(o, p, k, c) {
  36462. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36463. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36464. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36465. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36466. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36467. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36468. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36469. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36470. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36471. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36472. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36473. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36474. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36475. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36476. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36477. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36478. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36479. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36480. x15 = j15, u;
  36481. for (var i = 0; i < 20; i += 2) {
  36482. u = x0 + x12 | 0;
  36483. x4 ^= u<<7 | u>>>(32-7);
  36484. u = x4 + x0 | 0;
  36485. x8 ^= u<<9 | u>>>(32-9);
  36486. u = x8 + x4 | 0;
  36487. x12 ^= u<<13 | u>>>(32-13);
  36488. u = x12 + x8 | 0;
  36489. x0 ^= u<<18 | u>>>(32-18);
  36490. u = x5 + x1 | 0;
  36491. x9 ^= u<<7 | u>>>(32-7);
  36492. u = x9 + x5 | 0;
  36493. x13 ^= u<<9 | u>>>(32-9);
  36494. u = x13 + x9 | 0;
  36495. x1 ^= u<<13 | u>>>(32-13);
  36496. u = x1 + x13 | 0;
  36497. x5 ^= u<<18 | u>>>(32-18);
  36498. u = x10 + x6 | 0;
  36499. x14 ^= u<<7 | u>>>(32-7);
  36500. u = x14 + x10 | 0;
  36501. x2 ^= u<<9 | u>>>(32-9);
  36502. u = x2 + x14 | 0;
  36503. x6 ^= u<<13 | u>>>(32-13);
  36504. u = x6 + x2 | 0;
  36505. x10 ^= u<<18 | u>>>(32-18);
  36506. u = x15 + x11 | 0;
  36507. x3 ^= u<<7 | u>>>(32-7);
  36508. u = x3 + x15 | 0;
  36509. x7 ^= u<<9 | u>>>(32-9);
  36510. u = x7 + x3 | 0;
  36511. x11 ^= u<<13 | u>>>(32-13);
  36512. u = x11 + x7 | 0;
  36513. x15 ^= u<<18 | u>>>(32-18);
  36514. u = x0 + x3 | 0;
  36515. x1 ^= u<<7 | u>>>(32-7);
  36516. u = x1 + x0 | 0;
  36517. x2 ^= u<<9 | u>>>(32-9);
  36518. u = x2 + x1 | 0;
  36519. x3 ^= u<<13 | u>>>(32-13);
  36520. u = x3 + x2 | 0;
  36521. x0 ^= u<<18 | u>>>(32-18);
  36522. u = x5 + x4 | 0;
  36523. x6 ^= u<<7 | u>>>(32-7);
  36524. u = x6 + x5 | 0;
  36525. x7 ^= u<<9 | u>>>(32-9);
  36526. u = x7 + x6 | 0;
  36527. x4 ^= u<<13 | u>>>(32-13);
  36528. u = x4 + x7 | 0;
  36529. x5 ^= u<<18 | u>>>(32-18);
  36530. u = x10 + x9 | 0;
  36531. x11 ^= u<<7 | u>>>(32-7);
  36532. u = x11 + x10 | 0;
  36533. x8 ^= u<<9 | u>>>(32-9);
  36534. u = x8 + x11 | 0;
  36535. x9 ^= u<<13 | u>>>(32-13);
  36536. u = x9 + x8 | 0;
  36537. x10 ^= u<<18 | u>>>(32-18);
  36538. u = x15 + x14 | 0;
  36539. x12 ^= u<<7 | u>>>(32-7);
  36540. u = x12 + x15 | 0;
  36541. x13 ^= u<<9 | u>>>(32-9);
  36542. u = x13 + x12 | 0;
  36543. x14 ^= u<<13 | u>>>(32-13);
  36544. u = x14 + x13 | 0;
  36545. x15 ^= u<<18 | u>>>(32-18);
  36546. }
  36547. x0 = x0 + j0 | 0;
  36548. x1 = x1 + j1 | 0;
  36549. x2 = x2 + j2 | 0;
  36550. x3 = x3 + j3 | 0;
  36551. x4 = x4 + j4 | 0;
  36552. x5 = x5 + j5 | 0;
  36553. x6 = x6 + j6 | 0;
  36554. x7 = x7 + j7 | 0;
  36555. x8 = x8 + j8 | 0;
  36556. x9 = x9 + j9 | 0;
  36557. x10 = x10 + j10 | 0;
  36558. x11 = x11 + j11 | 0;
  36559. x12 = x12 + j12 | 0;
  36560. x13 = x13 + j13 | 0;
  36561. x14 = x14 + j14 | 0;
  36562. x15 = x15 + j15 | 0;
  36563. o[ 0] = x0 >>> 0 & 0xff;
  36564. o[ 1] = x0 >>> 8 & 0xff;
  36565. o[ 2] = x0 >>> 16 & 0xff;
  36566. o[ 3] = x0 >>> 24 & 0xff;
  36567. o[ 4] = x1 >>> 0 & 0xff;
  36568. o[ 5] = x1 >>> 8 & 0xff;
  36569. o[ 6] = x1 >>> 16 & 0xff;
  36570. o[ 7] = x1 >>> 24 & 0xff;
  36571. o[ 8] = x2 >>> 0 & 0xff;
  36572. o[ 9] = x2 >>> 8 & 0xff;
  36573. o[10] = x2 >>> 16 & 0xff;
  36574. o[11] = x2 >>> 24 & 0xff;
  36575. o[12] = x3 >>> 0 & 0xff;
  36576. o[13] = x3 >>> 8 & 0xff;
  36577. o[14] = x3 >>> 16 & 0xff;
  36578. o[15] = x3 >>> 24 & 0xff;
  36579. o[16] = x4 >>> 0 & 0xff;
  36580. o[17] = x4 >>> 8 & 0xff;
  36581. o[18] = x4 >>> 16 & 0xff;
  36582. o[19] = x4 >>> 24 & 0xff;
  36583. o[20] = x5 >>> 0 & 0xff;
  36584. o[21] = x5 >>> 8 & 0xff;
  36585. o[22] = x5 >>> 16 & 0xff;
  36586. o[23] = x5 >>> 24 & 0xff;
  36587. o[24] = x6 >>> 0 & 0xff;
  36588. o[25] = x6 >>> 8 & 0xff;
  36589. o[26] = x6 >>> 16 & 0xff;
  36590. o[27] = x6 >>> 24 & 0xff;
  36591. o[28] = x7 >>> 0 & 0xff;
  36592. o[29] = x7 >>> 8 & 0xff;
  36593. o[30] = x7 >>> 16 & 0xff;
  36594. o[31] = x7 >>> 24 & 0xff;
  36595. o[32] = x8 >>> 0 & 0xff;
  36596. o[33] = x8 >>> 8 & 0xff;
  36597. o[34] = x8 >>> 16 & 0xff;
  36598. o[35] = x8 >>> 24 & 0xff;
  36599. o[36] = x9 >>> 0 & 0xff;
  36600. o[37] = x9 >>> 8 & 0xff;
  36601. o[38] = x9 >>> 16 & 0xff;
  36602. o[39] = x9 >>> 24 & 0xff;
  36603. o[40] = x10 >>> 0 & 0xff;
  36604. o[41] = x10 >>> 8 & 0xff;
  36605. o[42] = x10 >>> 16 & 0xff;
  36606. o[43] = x10 >>> 24 & 0xff;
  36607. o[44] = x11 >>> 0 & 0xff;
  36608. o[45] = x11 >>> 8 & 0xff;
  36609. o[46] = x11 >>> 16 & 0xff;
  36610. o[47] = x11 >>> 24 & 0xff;
  36611. o[48] = x12 >>> 0 & 0xff;
  36612. o[49] = x12 >>> 8 & 0xff;
  36613. o[50] = x12 >>> 16 & 0xff;
  36614. o[51] = x12 >>> 24 & 0xff;
  36615. o[52] = x13 >>> 0 & 0xff;
  36616. o[53] = x13 >>> 8 & 0xff;
  36617. o[54] = x13 >>> 16 & 0xff;
  36618. o[55] = x13 >>> 24 & 0xff;
  36619. o[56] = x14 >>> 0 & 0xff;
  36620. o[57] = x14 >>> 8 & 0xff;
  36621. o[58] = x14 >>> 16 & 0xff;
  36622. o[59] = x14 >>> 24 & 0xff;
  36623. o[60] = x15 >>> 0 & 0xff;
  36624. o[61] = x15 >>> 8 & 0xff;
  36625. o[62] = x15 >>> 16 & 0xff;
  36626. o[63] = x15 >>> 24 & 0xff;
  36627. }
  36628. function core_hsalsa20(o,p,k,c) {
  36629. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36630. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36631. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36632. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36633. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36634. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36635. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36636. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36637. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36638. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36639. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36640. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36641. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36642. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36643. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36644. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36645. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36646. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36647. x15 = j15, u;
  36648. for (var i = 0; i < 20; i += 2) {
  36649. u = x0 + x12 | 0;
  36650. x4 ^= u<<7 | u>>>(32-7);
  36651. u = x4 + x0 | 0;
  36652. x8 ^= u<<9 | u>>>(32-9);
  36653. u = x8 + x4 | 0;
  36654. x12 ^= u<<13 | u>>>(32-13);
  36655. u = x12 + x8 | 0;
  36656. x0 ^= u<<18 | u>>>(32-18);
  36657. u = x5 + x1 | 0;
  36658. x9 ^= u<<7 | u>>>(32-7);
  36659. u = x9 + x5 | 0;
  36660. x13 ^= u<<9 | u>>>(32-9);
  36661. u = x13 + x9 | 0;
  36662. x1 ^= u<<13 | u>>>(32-13);
  36663. u = x1 + x13 | 0;
  36664. x5 ^= u<<18 | u>>>(32-18);
  36665. u = x10 + x6 | 0;
  36666. x14 ^= u<<7 | u>>>(32-7);
  36667. u = x14 + x10 | 0;
  36668. x2 ^= u<<9 | u>>>(32-9);
  36669. u = x2 + x14 | 0;
  36670. x6 ^= u<<13 | u>>>(32-13);
  36671. u = x6 + x2 | 0;
  36672. x10 ^= u<<18 | u>>>(32-18);
  36673. u = x15 + x11 | 0;
  36674. x3 ^= u<<7 | u>>>(32-7);
  36675. u = x3 + x15 | 0;
  36676. x7 ^= u<<9 | u>>>(32-9);
  36677. u = x7 + x3 | 0;
  36678. x11 ^= u<<13 | u>>>(32-13);
  36679. u = x11 + x7 | 0;
  36680. x15 ^= u<<18 | u>>>(32-18);
  36681. u = x0 + x3 | 0;
  36682. x1 ^= u<<7 | u>>>(32-7);
  36683. u = x1 + x0 | 0;
  36684. x2 ^= u<<9 | u>>>(32-9);
  36685. u = x2 + x1 | 0;
  36686. x3 ^= u<<13 | u>>>(32-13);
  36687. u = x3 + x2 | 0;
  36688. x0 ^= u<<18 | u>>>(32-18);
  36689. u = x5 + x4 | 0;
  36690. x6 ^= u<<7 | u>>>(32-7);
  36691. u = x6 + x5 | 0;
  36692. x7 ^= u<<9 | u>>>(32-9);
  36693. u = x7 + x6 | 0;
  36694. x4 ^= u<<13 | u>>>(32-13);
  36695. u = x4 + x7 | 0;
  36696. x5 ^= u<<18 | u>>>(32-18);
  36697. u = x10 + x9 | 0;
  36698. x11 ^= u<<7 | u>>>(32-7);
  36699. u = x11 + x10 | 0;
  36700. x8 ^= u<<9 | u>>>(32-9);
  36701. u = x8 + x11 | 0;
  36702. x9 ^= u<<13 | u>>>(32-13);
  36703. u = x9 + x8 | 0;
  36704. x10 ^= u<<18 | u>>>(32-18);
  36705. u = x15 + x14 | 0;
  36706. x12 ^= u<<7 | u>>>(32-7);
  36707. u = x12 + x15 | 0;
  36708. x13 ^= u<<9 | u>>>(32-9);
  36709. u = x13 + x12 | 0;
  36710. x14 ^= u<<13 | u>>>(32-13);
  36711. u = x14 + x13 | 0;
  36712. x15 ^= u<<18 | u>>>(32-18);
  36713. }
  36714. o[ 0] = x0 >>> 0 & 0xff;
  36715. o[ 1] = x0 >>> 8 & 0xff;
  36716. o[ 2] = x0 >>> 16 & 0xff;
  36717. o[ 3] = x0 >>> 24 & 0xff;
  36718. o[ 4] = x5 >>> 0 & 0xff;
  36719. o[ 5] = x5 >>> 8 & 0xff;
  36720. o[ 6] = x5 >>> 16 & 0xff;
  36721. o[ 7] = x5 >>> 24 & 0xff;
  36722. o[ 8] = x10 >>> 0 & 0xff;
  36723. o[ 9] = x10 >>> 8 & 0xff;
  36724. o[10] = x10 >>> 16 & 0xff;
  36725. o[11] = x10 >>> 24 & 0xff;
  36726. o[12] = x15 >>> 0 & 0xff;
  36727. o[13] = x15 >>> 8 & 0xff;
  36728. o[14] = x15 >>> 16 & 0xff;
  36729. o[15] = x15 >>> 24 & 0xff;
  36730. o[16] = x6 >>> 0 & 0xff;
  36731. o[17] = x6 >>> 8 & 0xff;
  36732. o[18] = x6 >>> 16 & 0xff;
  36733. o[19] = x6 >>> 24 & 0xff;
  36734. o[20] = x7 >>> 0 & 0xff;
  36735. o[21] = x7 >>> 8 & 0xff;
  36736. o[22] = x7 >>> 16 & 0xff;
  36737. o[23] = x7 >>> 24 & 0xff;
  36738. o[24] = x8 >>> 0 & 0xff;
  36739. o[25] = x8 >>> 8 & 0xff;
  36740. o[26] = x8 >>> 16 & 0xff;
  36741. o[27] = x8 >>> 24 & 0xff;
  36742. o[28] = x9 >>> 0 & 0xff;
  36743. o[29] = x9 >>> 8 & 0xff;
  36744. o[30] = x9 >>> 16 & 0xff;
  36745. o[31] = x9 >>> 24 & 0xff;
  36746. }
  36747. function crypto_core_salsa20(out,inp,k,c) {
  36748. core_salsa20(out,inp,k,c);
  36749. }
  36750. function crypto_core_hsalsa20(out,inp,k,c) {
  36751. core_hsalsa20(out,inp,k,c);
  36752. }
  36753. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  36754. // "expand 32-byte k"
  36755. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  36756. var z = new Uint8Array(16), x = new Uint8Array(64);
  36757. var u, i;
  36758. for (i = 0; i < 16; i++) z[i] = 0;
  36759. for (i = 0; i < 8; i++) z[i] = n[i];
  36760. while (b >= 64) {
  36761. crypto_core_salsa20(x,z,k,sigma);
  36762. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36763. u = 1;
  36764. for (i = 8; i < 16; i++) {
  36765. u = u + (z[i] & 0xff) | 0;
  36766. z[i] = u & 0xff;
  36767. u >>>= 8;
  36768. }
  36769. b -= 64;
  36770. cpos += 64;
  36771. mpos += 64;
  36772. }
  36773. if (b > 0) {
  36774. crypto_core_salsa20(x,z,k,sigma);
  36775. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36776. }
  36777. return 0;
  36778. }
  36779. function crypto_stream_salsa20(c,cpos,b,n,k) {
  36780. var z = new Uint8Array(16), x = new Uint8Array(64);
  36781. var u, i;
  36782. for (i = 0; i < 16; i++) z[i] = 0;
  36783. for (i = 0; i < 8; i++) z[i] = n[i];
  36784. while (b >= 64) {
  36785. crypto_core_salsa20(x,z,k,sigma);
  36786. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  36787. u = 1;
  36788. for (i = 8; i < 16; i++) {
  36789. u = u + (z[i] & 0xff) | 0;
  36790. z[i] = u & 0xff;
  36791. u >>>= 8;
  36792. }
  36793. b -= 64;
  36794. cpos += 64;
  36795. }
  36796. if (b > 0) {
  36797. crypto_core_salsa20(x,z,k,sigma);
  36798. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  36799. }
  36800. return 0;
  36801. }
  36802. function crypto_stream(c,cpos,d,n,k) {
  36803. var s = new Uint8Array(32);
  36804. crypto_core_hsalsa20(s,n,k,sigma);
  36805. var sn = new Uint8Array(8);
  36806. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36807. return crypto_stream_salsa20(c,cpos,d,sn,s);
  36808. }
  36809. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  36810. var s = new Uint8Array(32);
  36811. crypto_core_hsalsa20(s,n,k,sigma);
  36812. var sn = new Uint8Array(8);
  36813. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36814. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  36815. }
  36816. /*
  36817. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  36818. * https://github.com/floodyberry/poly1305-donna
  36819. */
  36820. var poly1305 = function(key) {
  36821. this.buffer = new Uint8Array(16);
  36822. this.r = new Uint16Array(10);
  36823. this.h = new Uint16Array(10);
  36824. this.pad = new Uint16Array(8);
  36825. this.leftover = 0;
  36826. this.fin = 0;
  36827. var t0, t1, t2, t3, t4, t5, t6, t7;
  36828. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  36829. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36830. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  36831. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36832. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  36833. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  36834. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36835. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  36836. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36837. this.r[9] = ((t7 >>> 5)) & 0x007f;
  36838. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  36839. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  36840. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  36841. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  36842. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  36843. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  36844. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  36845. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  36846. };
  36847. poly1305.prototype.blocks = function(m, mpos, bytes) {
  36848. var hibit = this.fin ? 0 : (1 << 11);
  36849. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  36850. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  36851. var h0 = this.h[0],
  36852. h1 = this.h[1],
  36853. h2 = this.h[2],
  36854. h3 = this.h[3],
  36855. h4 = this.h[4],
  36856. h5 = this.h[5],
  36857. h6 = this.h[6],
  36858. h7 = this.h[7],
  36859. h8 = this.h[8],
  36860. h9 = this.h[9];
  36861. var r0 = this.r[0],
  36862. r1 = this.r[1],
  36863. r2 = this.r[2],
  36864. r3 = this.r[3],
  36865. r4 = this.r[4],
  36866. r5 = this.r[5],
  36867. r6 = this.r[6],
  36868. r7 = this.r[7],
  36869. r8 = this.r[8],
  36870. r9 = this.r[9];
  36871. while (bytes >= 16) {
  36872. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  36873. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36874. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  36875. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36876. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  36877. h5 += ((t4 >>> 1)) & 0x1fff;
  36878. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36879. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  36880. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36881. h9 += ((t7 >>> 5)) | hibit;
  36882. c = 0;
  36883. d0 = c;
  36884. d0 += h0 * r0;
  36885. d0 += h1 * (5 * r9);
  36886. d0 += h2 * (5 * r8);
  36887. d0 += h3 * (5 * r7);
  36888. d0 += h4 * (5 * r6);
  36889. c = (d0 >>> 13); d0 &= 0x1fff;
  36890. d0 += h5 * (5 * r5);
  36891. d0 += h6 * (5 * r4);
  36892. d0 += h7 * (5 * r3);
  36893. d0 += h8 * (5 * r2);
  36894. d0 += h9 * (5 * r1);
  36895. c += (d0 >>> 13); d0 &= 0x1fff;
  36896. d1 = c;
  36897. d1 += h0 * r1;
  36898. d1 += h1 * r0;
  36899. d1 += h2 * (5 * r9);
  36900. d1 += h3 * (5 * r8);
  36901. d1 += h4 * (5 * r7);
  36902. c = (d1 >>> 13); d1 &= 0x1fff;
  36903. d1 += h5 * (5 * r6);
  36904. d1 += h6 * (5 * r5);
  36905. d1 += h7 * (5 * r4);
  36906. d1 += h8 * (5 * r3);
  36907. d1 += h9 * (5 * r2);
  36908. c += (d1 >>> 13); d1 &= 0x1fff;
  36909. d2 = c;
  36910. d2 += h0 * r2;
  36911. d2 += h1 * r1;
  36912. d2 += h2 * r0;
  36913. d2 += h3 * (5 * r9);
  36914. d2 += h4 * (5 * r8);
  36915. c = (d2 >>> 13); d2 &= 0x1fff;
  36916. d2 += h5 * (5 * r7);
  36917. d2 += h6 * (5 * r6);
  36918. d2 += h7 * (5 * r5);
  36919. d2 += h8 * (5 * r4);
  36920. d2 += h9 * (5 * r3);
  36921. c += (d2 >>> 13); d2 &= 0x1fff;
  36922. d3 = c;
  36923. d3 += h0 * r3;
  36924. d3 += h1 * r2;
  36925. d3 += h2 * r1;
  36926. d3 += h3 * r0;
  36927. d3 += h4 * (5 * r9);
  36928. c = (d3 >>> 13); d3 &= 0x1fff;
  36929. d3 += h5 * (5 * r8);
  36930. d3 += h6 * (5 * r7);
  36931. d3 += h7 * (5 * r6);
  36932. d3 += h8 * (5 * r5);
  36933. d3 += h9 * (5 * r4);
  36934. c += (d3 >>> 13); d3 &= 0x1fff;
  36935. d4 = c;
  36936. d4 += h0 * r4;
  36937. d4 += h1 * r3;
  36938. d4 += h2 * r2;
  36939. d4 += h3 * r1;
  36940. d4 += h4 * r0;
  36941. c = (d4 >>> 13); d4 &= 0x1fff;
  36942. d4 += h5 * (5 * r9);
  36943. d4 += h6 * (5 * r8);
  36944. d4 += h7 * (5 * r7);
  36945. d4 += h8 * (5 * r6);
  36946. d4 += h9 * (5 * r5);
  36947. c += (d4 >>> 13); d4 &= 0x1fff;
  36948. d5 = c;
  36949. d5 += h0 * r5;
  36950. d5 += h1 * r4;
  36951. d5 += h2 * r3;
  36952. d5 += h3 * r2;
  36953. d5 += h4 * r1;
  36954. c = (d5 >>> 13); d5 &= 0x1fff;
  36955. d5 += h5 * r0;
  36956. d5 += h6 * (5 * r9);
  36957. d5 += h7 * (5 * r8);
  36958. d5 += h8 * (5 * r7);
  36959. d5 += h9 * (5 * r6);
  36960. c += (d5 >>> 13); d5 &= 0x1fff;
  36961. d6 = c;
  36962. d6 += h0 * r6;
  36963. d6 += h1 * r5;
  36964. d6 += h2 * r4;
  36965. d6 += h3 * r3;
  36966. d6 += h4 * r2;
  36967. c = (d6 >>> 13); d6 &= 0x1fff;
  36968. d6 += h5 * r1;
  36969. d6 += h6 * r0;
  36970. d6 += h7 * (5 * r9);
  36971. d6 += h8 * (5 * r8);
  36972. d6 += h9 * (5 * r7);
  36973. c += (d6 >>> 13); d6 &= 0x1fff;
  36974. d7 = c;
  36975. d7 += h0 * r7;
  36976. d7 += h1 * r6;
  36977. d7 += h2 * r5;
  36978. d7 += h3 * r4;
  36979. d7 += h4 * r3;
  36980. c = (d7 >>> 13); d7 &= 0x1fff;
  36981. d7 += h5 * r2;
  36982. d7 += h6 * r1;
  36983. d7 += h7 * r0;
  36984. d7 += h8 * (5 * r9);
  36985. d7 += h9 * (5 * r8);
  36986. c += (d7 >>> 13); d7 &= 0x1fff;
  36987. d8 = c;
  36988. d8 += h0 * r8;
  36989. d8 += h1 * r7;
  36990. d8 += h2 * r6;
  36991. d8 += h3 * r5;
  36992. d8 += h4 * r4;
  36993. c = (d8 >>> 13); d8 &= 0x1fff;
  36994. d8 += h5 * r3;
  36995. d8 += h6 * r2;
  36996. d8 += h7 * r1;
  36997. d8 += h8 * r0;
  36998. d8 += h9 * (5 * r9);
  36999. c += (d8 >>> 13); d8 &= 0x1fff;
  37000. d9 = c;
  37001. d9 += h0 * r9;
  37002. d9 += h1 * r8;
  37003. d9 += h2 * r7;
  37004. d9 += h3 * r6;
  37005. d9 += h4 * r5;
  37006. c = (d9 >>> 13); d9 &= 0x1fff;
  37007. d9 += h5 * r4;
  37008. d9 += h6 * r3;
  37009. d9 += h7 * r2;
  37010. d9 += h8 * r1;
  37011. d9 += h9 * r0;
  37012. c += (d9 >>> 13); d9 &= 0x1fff;
  37013. c = (((c << 2) + c)) | 0;
  37014. c = (c + d0) | 0;
  37015. d0 = c & 0x1fff;
  37016. c = (c >>> 13);
  37017. d1 += c;
  37018. h0 = d0;
  37019. h1 = d1;
  37020. h2 = d2;
  37021. h3 = d3;
  37022. h4 = d4;
  37023. h5 = d5;
  37024. h6 = d6;
  37025. h7 = d7;
  37026. h8 = d8;
  37027. h9 = d9;
  37028. mpos += 16;
  37029. bytes -= 16;
  37030. }
  37031. this.h[0] = h0;
  37032. this.h[1] = h1;
  37033. this.h[2] = h2;
  37034. this.h[3] = h3;
  37035. this.h[4] = h4;
  37036. this.h[5] = h5;
  37037. this.h[6] = h6;
  37038. this.h[7] = h7;
  37039. this.h[8] = h8;
  37040. this.h[9] = h9;
  37041. };
  37042. poly1305.prototype.finish = function(mac, macpos) {
  37043. var g = new Uint16Array(10);
  37044. var c, mask, f, i;
  37045. if (this.leftover) {
  37046. i = this.leftover;
  37047. this.buffer[i++] = 1;
  37048. for (; i < 16; i++) this.buffer[i] = 0;
  37049. this.fin = 1;
  37050. this.blocks(this.buffer, 0, 16);
  37051. }
  37052. c = this.h[1] >>> 13;
  37053. this.h[1] &= 0x1fff;
  37054. for (i = 2; i < 10; i++) {
  37055. this.h[i] += c;
  37056. c = this.h[i] >>> 13;
  37057. this.h[i] &= 0x1fff;
  37058. }
  37059. this.h[0] += (c * 5);
  37060. c = this.h[0] >>> 13;
  37061. this.h[0] &= 0x1fff;
  37062. this.h[1] += c;
  37063. c = this.h[1] >>> 13;
  37064. this.h[1] &= 0x1fff;
  37065. this.h[2] += c;
  37066. g[0] = this.h[0] + 5;
  37067. c = g[0] >>> 13;
  37068. g[0] &= 0x1fff;
  37069. for (i = 1; i < 10; i++) {
  37070. g[i] = this.h[i] + c;
  37071. c = g[i] >>> 13;
  37072. g[i] &= 0x1fff;
  37073. }
  37074. g[9] -= (1 << 13);
  37075. mask = (c ^ 1) - 1;
  37076. for (i = 0; i < 10; i++) g[i] &= mask;
  37077. mask = ~mask;
  37078. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  37079. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  37080. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  37081. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  37082. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  37083. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  37084. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  37085. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  37086. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  37087. f = this.h[0] + this.pad[0];
  37088. this.h[0] = f & 0xffff;
  37089. for (i = 1; i < 8; i++) {
  37090. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  37091. this.h[i] = f & 0xffff;
  37092. }
  37093. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  37094. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  37095. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  37096. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  37097. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  37098. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  37099. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  37100. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  37101. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  37102. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  37103. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  37104. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  37105. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  37106. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  37107. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  37108. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  37109. };
  37110. poly1305.prototype.update = function(m, mpos, bytes) {
  37111. var i, want;
  37112. if (this.leftover) {
  37113. want = (16 - this.leftover);
  37114. if (want > bytes)
  37115. want = bytes;
  37116. for (i = 0; i < want; i++)
  37117. this.buffer[this.leftover + i] = m[mpos+i];
  37118. bytes -= want;
  37119. mpos += want;
  37120. this.leftover += want;
  37121. if (this.leftover < 16)
  37122. return;
  37123. this.blocks(this.buffer, 0, 16);
  37124. this.leftover = 0;
  37125. }
  37126. if (bytes >= 16) {
  37127. want = bytes - (bytes % 16);
  37128. this.blocks(m, mpos, want);
  37129. mpos += want;
  37130. bytes -= want;
  37131. }
  37132. if (bytes) {
  37133. for (i = 0; i < bytes; i++)
  37134. this.buffer[this.leftover + i] = m[mpos+i];
  37135. this.leftover += bytes;
  37136. }
  37137. };
  37138. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  37139. var s = new poly1305(k);
  37140. s.update(m, mpos, n);
  37141. s.finish(out, outpos);
  37142. return 0;
  37143. }
  37144. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  37145. var x = new Uint8Array(16);
  37146. crypto_onetimeauth(x,0,m,mpos,n,k);
  37147. return crypto_verify_16(h,hpos,x,0);
  37148. }
  37149. function crypto_secretbox(c,m,d,n,k) {
  37150. var i;
  37151. if (d < 32) return -1;
  37152. crypto_stream_xor(c,0,m,0,d,n,k);
  37153. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  37154. for (i = 0; i < 16; i++) c[i] = 0;
  37155. return 0;
  37156. }
  37157. function crypto_secretbox_open(m,c,d,n,k) {
  37158. var i;
  37159. var x = new Uint8Array(32);
  37160. if (d < 32) return -1;
  37161. crypto_stream(x,0,32,n,k);
  37162. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  37163. crypto_stream_xor(m,0,c,0,d,n,k);
  37164. for (i = 0; i < 32; i++) m[i] = 0;
  37165. return 0;
  37166. }
  37167. function set25519(r, a) {
  37168. var i;
  37169. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  37170. }
  37171. function car25519(o) {
  37172. var i, v, c = 1;
  37173. for (i = 0; i < 16; i++) {
  37174. v = o[i] + c + 65535;
  37175. c = Math.floor(v / 65536);
  37176. o[i] = v - c * 65536;
  37177. }
  37178. o[0] += c-1 + 37 * (c-1);
  37179. }
  37180. function sel25519(p, q, b) {
  37181. var t, c = ~(b-1);
  37182. for (var i = 0; i < 16; i++) {
  37183. t = c & (p[i] ^ q[i]);
  37184. p[i] ^= t;
  37185. q[i] ^= t;
  37186. }
  37187. }
  37188. function pack25519(o, n) {
  37189. var i, j, b;
  37190. var m = gf(), t = gf();
  37191. for (i = 0; i < 16; i++) t[i] = n[i];
  37192. car25519(t);
  37193. car25519(t);
  37194. car25519(t);
  37195. for (j = 0; j < 2; j++) {
  37196. m[0] = t[0] - 0xffed;
  37197. for (i = 1; i < 15; i++) {
  37198. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  37199. m[i-1] &= 0xffff;
  37200. }
  37201. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  37202. b = (m[15]>>16) & 1;
  37203. m[14] &= 0xffff;
  37204. sel25519(t, m, 1-b);
  37205. }
  37206. for (i = 0; i < 16; i++) {
  37207. o[2*i] = t[i] & 0xff;
  37208. o[2*i+1] = t[i]>>8;
  37209. }
  37210. }
  37211. function neq25519(a, b) {
  37212. var c = new Uint8Array(32), d = new Uint8Array(32);
  37213. pack25519(c, a);
  37214. pack25519(d, b);
  37215. return crypto_verify_32(c, 0, d, 0);
  37216. }
  37217. function par25519(a) {
  37218. var d = new Uint8Array(32);
  37219. pack25519(d, a);
  37220. return d[0] & 1;
  37221. }
  37222. function unpack25519(o, n) {
  37223. var i;
  37224. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  37225. o[15] &= 0x7fff;
  37226. }
  37227. function A(o, a, b) {
  37228. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  37229. }
  37230. function Z(o, a, b) {
  37231. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  37232. }
  37233. function M(o, a, b) {
  37234. var v, c,
  37235. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  37236. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  37237. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  37238. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  37239. b0 = b[0],
  37240. b1 = b[1],
  37241. b2 = b[2],
  37242. b3 = b[3],
  37243. b4 = b[4],
  37244. b5 = b[5],
  37245. b6 = b[6],
  37246. b7 = b[7],
  37247. b8 = b[8],
  37248. b9 = b[9],
  37249. b10 = b[10],
  37250. b11 = b[11],
  37251. b12 = b[12],
  37252. b13 = b[13],
  37253. b14 = b[14],
  37254. b15 = b[15];
  37255. v = a[0];
  37256. t0 += v * b0;
  37257. t1 += v * b1;
  37258. t2 += v * b2;
  37259. t3 += v * b3;
  37260. t4 += v * b4;
  37261. t5 += v * b5;
  37262. t6 += v * b6;
  37263. t7 += v * b7;
  37264. t8 += v * b8;
  37265. t9 += v * b9;
  37266. t10 += v * b10;
  37267. t11 += v * b11;
  37268. t12 += v * b12;
  37269. t13 += v * b13;
  37270. t14 += v * b14;
  37271. t15 += v * b15;
  37272. v = a[1];
  37273. t1 += v * b0;
  37274. t2 += v * b1;
  37275. t3 += v * b2;
  37276. t4 += v * b3;
  37277. t5 += v * b4;
  37278. t6 += v * b5;
  37279. t7 += v * b6;
  37280. t8 += v * b7;
  37281. t9 += v * b8;
  37282. t10 += v * b9;
  37283. t11 += v * b10;
  37284. t12 += v * b11;
  37285. t13 += v * b12;
  37286. t14 += v * b13;
  37287. t15 += v * b14;
  37288. t16 += v * b15;
  37289. v = a[2];
  37290. t2 += v * b0;
  37291. t3 += v * b1;
  37292. t4 += v * b2;
  37293. t5 += v * b3;
  37294. t6 += v * b4;
  37295. t7 += v * b5;
  37296. t8 += v * b6;
  37297. t9 += v * b7;
  37298. t10 += v * b8;
  37299. t11 += v * b9;
  37300. t12 += v * b10;
  37301. t13 += v * b11;
  37302. t14 += v * b12;
  37303. t15 += v * b13;
  37304. t16 += v * b14;
  37305. t17 += v * b15;
  37306. v = a[3];
  37307. t3 += v * b0;
  37308. t4 += v * b1;
  37309. t5 += v * b2;
  37310. t6 += v * b3;
  37311. t7 += v * b4;
  37312. t8 += v * b5;
  37313. t9 += v * b6;
  37314. t10 += v * b7;
  37315. t11 += v * b8;
  37316. t12 += v * b9;
  37317. t13 += v * b10;
  37318. t14 += v * b11;
  37319. t15 += v * b12;
  37320. t16 += v * b13;
  37321. t17 += v * b14;
  37322. t18 += v * b15;
  37323. v = a[4];
  37324. t4 += v * b0;
  37325. t5 += v * b1;
  37326. t6 += v * b2;
  37327. t7 += v * b3;
  37328. t8 += v * b4;
  37329. t9 += v * b5;
  37330. t10 += v * b6;
  37331. t11 += v * b7;
  37332. t12 += v * b8;
  37333. t13 += v * b9;
  37334. t14 += v * b10;
  37335. t15 += v * b11;
  37336. t16 += v * b12;
  37337. t17 += v * b13;
  37338. t18 += v * b14;
  37339. t19 += v * b15;
  37340. v = a[5];
  37341. t5 += v * b0;
  37342. t6 += v * b1;
  37343. t7 += v * b2;
  37344. t8 += v * b3;
  37345. t9 += v * b4;
  37346. t10 += v * b5;
  37347. t11 += v * b6;
  37348. t12 += v * b7;
  37349. t13 += v * b8;
  37350. t14 += v * b9;
  37351. t15 += v * b10;
  37352. t16 += v * b11;
  37353. t17 += v * b12;
  37354. t18 += v * b13;
  37355. t19 += v * b14;
  37356. t20 += v * b15;
  37357. v = a[6];
  37358. t6 += v * b0;
  37359. t7 += v * b1;
  37360. t8 += v * b2;
  37361. t9 += v * b3;
  37362. t10 += v * b4;
  37363. t11 += v * b5;
  37364. t12 += v * b6;
  37365. t13 += v * b7;
  37366. t14 += v * b8;
  37367. t15 += v * b9;
  37368. t16 += v * b10;
  37369. t17 += v * b11;
  37370. t18 += v * b12;
  37371. t19 += v * b13;
  37372. t20 += v * b14;
  37373. t21 += v * b15;
  37374. v = a[7];
  37375. t7 += v * b0;
  37376. t8 += v * b1;
  37377. t9 += v * b2;
  37378. t10 += v * b3;
  37379. t11 += v * b4;
  37380. t12 += v * b5;
  37381. t13 += v * b6;
  37382. t14 += v * b7;
  37383. t15 += v * b8;
  37384. t16 += v * b9;
  37385. t17 += v * b10;
  37386. t18 += v * b11;
  37387. t19 += v * b12;
  37388. t20 += v * b13;
  37389. t21 += v * b14;
  37390. t22 += v * b15;
  37391. v = a[8];
  37392. t8 += v * b0;
  37393. t9 += v * b1;
  37394. t10 += v * b2;
  37395. t11 += v * b3;
  37396. t12 += v * b4;
  37397. t13 += v * b5;
  37398. t14 += v * b6;
  37399. t15 += v * b7;
  37400. t16 += v * b8;
  37401. t17 += v * b9;
  37402. t18 += v * b10;
  37403. t19 += v * b11;
  37404. t20 += v * b12;
  37405. t21 += v * b13;
  37406. t22 += v * b14;
  37407. t23 += v * b15;
  37408. v = a[9];
  37409. t9 += v * b0;
  37410. t10 += v * b1;
  37411. t11 += v * b2;
  37412. t12 += v * b3;
  37413. t13 += v * b4;
  37414. t14 += v * b5;
  37415. t15 += v * b6;
  37416. t16 += v * b7;
  37417. t17 += v * b8;
  37418. t18 += v * b9;
  37419. t19 += v * b10;
  37420. t20 += v * b11;
  37421. t21 += v * b12;
  37422. t22 += v * b13;
  37423. t23 += v * b14;
  37424. t24 += v * b15;
  37425. v = a[10];
  37426. t10 += v * b0;
  37427. t11 += v * b1;
  37428. t12 += v * b2;
  37429. t13 += v * b3;
  37430. t14 += v * b4;
  37431. t15 += v * b5;
  37432. t16 += v * b6;
  37433. t17 += v * b7;
  37434. t18 += v * b8;
  37435. t19 += v * b9;
  37436. t20 += v * b10;
  37437. t21 += v * b11;
  37438. t22 += v * b12;
  37439. t23 += v * b13;
  37440. t24 += v * b14;
  37441. t25 += v * b15;
  37442. v = a[11];
  37443. t11 += v * b0;
  37444. t12 += v * b1;
  37445. t13 += v * b2;
  37446. t14 += v * b3;
  37447. t15 += v * b4;
  37448. t16 += v * b5;
  37449. t17 += v * b6;
  37450. t18 += v * b7;
  37451. t19 += v * b8;
  37452. t20 += v * b9;
  37453. t21 += v * b10;
  37454. t22 += v * b11;
  37455. t23 += v * b12;
  37456. t24 += v * b13;
  37457. t25 += v * b14;
  37458. t26 += v * b15;
  37459. v = a[12];
  37460. t12 += v * b0;
  37461. t13 += v * b1;
  37462. t14 += v * b2;
  37463. t15 += v * b3;
  37464. t16 += v * b4;
  37465. t17 += v * b5;
  37466. t18 += v * b6;
  37467. t19 += v * b7;
  37468. t20 += v * b8;
  37469. t21 += v * b9;
  37470. t22 += v * b10;
  37471. t23 += v * b11;
  37472. t24 += v * b12;
  37473. t25 += v * b13;
  37474. t26 += v * b14;
  37475. t27 += v * b15;
  37476. v = a[13];
  37477. t13 += v * b0;
  37478. t14 += v * b1;
  37479. t15 += v * b2;
  37480. t16 += v * b3;
  37481. t17 += v * b4;
  37482. t18 += v * b5;
  37483. t19 += v * b6;
  37484. t20 += v * b7;
  37485. t21 += v * b8;
  37486. t22 += v * b9;
  37487. t23 += v * b10;
  37488. t24 += v * b11;
  37489. t25 += v * b12;
  37490. t26 += v * b13;
  37491. t27 += v * b14;
  37492. t28 += v * b15;
  37493. v = a[14];
  37494. t14 += v * b0;
  37495. t15 += v * b1;
  37496. t16 += v * b2;
  37497. t17 += v * b3;
  37498. t18 += v * b4;
  37499. t19 += v * b5;
  37500. t20 += v * b6;
  37501. t21 += v * b7;
  37502. t22 += v * b8;
  37503. t23 += v * b9;
  37504. t24 += v * b10;
  37505. t25 += v * b11;
  37506. t26 += v * b12;
  37507. t27 += v * b13;
  37508. t28 += v * b14;
  37509. t29 += v * b15;
  37510. v = a[15];
  37511. t15 += v * b0;
  37512. t16 += v * b1;
  37513. t17 += v * b2;
  37514. t18 += v * b3;
  37515. t19 += v * b4;
  37516. t20 += v * b5;
  37517. t21 += v * b6;
  37518. t22 += v * b7;
  37519. t23 += v * b8;
  37520. t24 += v * b9;
  37521. t25 += v * b10;
  37522. t26 += v * b11;
  37523. t27 += v * b12;
  37524. t28 += v * b13;
  37525. t29 += v * b14;
  37526. t30 += v * b15;
  37527. t0 += 38 * t16;
  37528. t1 += 38 * t17;
  37529. t2 += 38 * t18;
  37530. t3 += 38 * t19;
  37531. t4 += 38 * t20;
  37532. t5 += 38 * t21;
  37533. t6 += 38 * t22;
  37534. t7 += 38 * t23;
  37535. t8 += 38 * t24;
  37536. t9 += 38 * t25;
  37537. t10 += 38 * t26;
  37538. t11 += 38 * t27;
  37539. t12 += 38 * t28;
  37540. t13 += 38 * t29;
  37541. t14 += 38 * t30;
  37542. // t15 left as is
  37543. // first car
  37544. c = 1;
  37545. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37546. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37547. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37548. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37549. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37550. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37551. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37552. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37553. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37554. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37555. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37556. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37557. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37558. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37559. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37560. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37561. t0 += c-1 + 37 * (c-1);
  37562. // second car
  37563. c = 1;
  37564. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37565. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37566. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37567. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37568. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37569. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37570. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37571. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37572. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37573. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37574. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37575. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37576. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37577. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37578. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37579. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37580. t0 += c-1 + 37 * (c-1);
  37581. o[ 0] = t0;
  37582. o[ 1] = t1;
  37583. o[ 2] = t2;
  37584. o[ 3] = t3;
  37585. o[ 4] = t4;
  37586. o[ 5] = t5;
  37587. o[ 6] = t6;
  37588. o[ 7] = t7;
  37589. o[ 8] = t8;
  37590. o[ 9] = t9;
  37591. o[10] = t10;
  37592. o[11] = t11;
  37593. o[12] = t12;
  37594. o[13] = t13;
  37595. o[14] = t14;
  37596. o[15] = t15;
  37597. }
  37598. function S(o, a) {
  37599. M(o, a, a);
  37600. }
  37601. function inv25519(o, i) {
  37602. var c = gf();
  37603. var a;
  37604. for (a = 0; a < 16; a++) c[a] = i[a];
  37605. for (a = 253; a >= 0; a--) {
  37606. S(c, c);
  37607. if(a !== 2 && a !== 4) M(c, c, i);
  37608. }
  37609. for (a = 0; a < 16; a++) o[a] = c[a];
  37610. }
  37611. function pow2523(o, i) {
  37612. var c = gf();
  37613. var a;
  37614. for (a = 0; a < 16; a++) c[a] = i[a];
  37615. for (a = 250; a >= 0; a--) {
  37616. S(c, c);
  37617. if(a !== 1) M(c, c, i);
  37618. }
  37619. for (a = 0; a < 16; a++) o[a] = c[a];
  37620. }
  37621. function crypto_scalarmult(q, n, p) {
  37622. var z = new Uint8Array(32);
  37623. var x = new Float64Array(80), r, i;
  37624. var a = gf(), b = gf(), c = gf(),
  37625. d = gf(), e = gf(), f = gf();
  37626. for (i = 0; i < 31; i++) z[i] = n[i];
  37627. z[31]=(n[31]&127)|64;
  37628. z[0]&=248;
  37629. unpack25519(x,p);
  37630. for (i = 0; i < 16; i++) {
  37631. b[i]=x[i];
  37632. d[i]=a[i]=c[i]=0;
  37633. }
  37634. a[0]=d[0]=1;
  37635. for (i=254; i>=0; --i) {
  37636. r=(z[i>>>3]>>>(i&7))&1;
  37637. sel25519(a,b,r);
  37638. sel25519(c,d,r);
  37639. A(e,a,c);
  37640. Z(a,a,c);
  37641. A(c,b,d);
  37642. Z(b,b,d);
  37643. S(d,e);
  37644. S(f,a);
  37645. M(a,c,a);
  37646. M(c,b,e);
  37647. A(e,a,c);
  37648. Z(a,a,c);
  37649. S(b,a);
  37650. Z(c,d,f);
  37651. M(a,c,_121665);
  37652. A(a,a,d);
  37653. M(c,c,a);
  37654. M(a,d,f);
  37655. M(d,b,x);
  37656. S(b,e);
  37657. sel25519(a,b,r);
  37658. sel25519(c,d,r);
  37659. }
  37660. for (i = 0; i < 16; i++) {
  37661. x[i+16]=a[i];
  37662. x[i+32]=c[i];
  37663. x[i+48]=b[i];
  37664. x[i+64]=d[i];
  37665. }
  37666. var x32 = x.subarray(32);
  37667. var x16 = x.subarray(16);
  37668. inv25519(x32,x32);
  37669. M(x16,x16,x32);
  37670. pack25519(q,x16);
  37671. return 0;
  37672. }
  37673. function crypto_scalarmult_base(q, n) {
  37674. return crypto_scalarmult(q, n, _9);
  37675. }
  37676. function crypto_box_keypair(y, x) {
  37677. randombytes(x, 32);
  37678. return crypto_scalarmult_base(y, x);
  37679. }
  37680. function crypto_box_beforenm(k, y, x) {
  37681. var s = new Uint8Array(32);
  37682. crypto_scalarmult(s, x, y);
  37683. return crypto_core_hsalsa20(k, _0, s, sigma);
  37684. }
  37685. var crypto_box_afternm = crypto_secretbox;
  37686. var crypto_box_open_afternm = crypto_secretbox_open;
  37687. function crypto_box(c, m, d, n, y, x) {
  37688. var k = new Uint8Array(32);
  37689. crypto_box_beforenm(k, y, x);
  37690. return crypto_box_afternm(c, m, d, n, k);
  37691. }
  37692. function crypto_box_open(m, c, d, n, y, x) {
  37693. var k = new Uint8Array(32);
  37694. crypto_box_beforenm(k, y, x);
  37695. return crypto_box_open_afternm(m, c, d, n, k);
  37696. }
  37697. var K = [
  37698. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  37699. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  37700. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  37701. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  37702. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  37703. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  37704. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  37705. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  37706. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  37707. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  37708. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  37709. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  37710. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  37711. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  37712. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  37713. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  37714. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  37715. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  37716. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  37717. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  37718. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  37719. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  37720. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  37721. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  37722. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  37723. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  37724. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  37725. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  37726. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  37727. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  37728. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  37729. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  37730. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  37731. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  37732. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  37733. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  37734. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  37735. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  37736. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  37737. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  37738. ];
  37739. function crypto_hashblocks_hl(hh, hl, m, n) {
  37740. var wh = new Int32Array(16), wl = new Int32Array(16),
  37741. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  37742. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  37743. th, tl, i, j, h, l, a, b, c, d;
  37744. var ah0 = hh[0],
  37745. ah1 = hh[1],
  37746. ah2 = hh[2],
  37747. ah3 = hh[3],
  37748. ah4 = hh[4],
  37749. ah5 = hh[5],
  37750. ah6 = hh[6],
  37751. ah7 = hh[7],
  37752. al0 = hl[0],
  37753. al1 = hl[1],
  37754. al2 = hl[2],
  37755. al3 = hl[3],
  37756. al4 = hl[4],
  37757. al5 = hl[5],
  37758. al6 = hl[6],
  37759. al7 = hl[7];
  37760. var pos = 0;
  37761. while (n >= 128) {
  37762. for (i = 0; i < 16; i++) {
  37763. j = 8 * i + pos;
  37764. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  37765. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  37766. }
  37767. for (i = 0; i < 80; i++) {
  37768. bh0 = ah0;
  37769. bh1 = ah1;
  37770. bh2 = ah2;
  37771. bh3 = ah3;
  37772. bh4 = ah4;
  37773. bh5 = ah5;
  37774. bh6 = ah6;
  37775. bh7 = ah7;
  37776. bl0 = al0;
  37777. bl1 = al1;
  37778. bl2 = al2;
  37779. bl3 = al3;
  37780. bl4 = al4;
  37781. bl5 = al5;
  37782. bl6 = al6;
  37783. bl7 = al7;
  37784. // add
  37785. h = ah7;
  37786. l = al7;
  37787. a = l & 0xffff; b = l >>> 16;
  37788. c = h & 0xffff; d = h >>> 16;
  37789. // Sigma1
  37790. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  37791. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  37792. a += l & 0xffff; b += l >>> 16;
  37793. c += h & 0xffff; d += h >>> 16;
  37794. // Ch
  37795. h = (ah4 & ah5) ^ (~ah4 & ah6);
  37796. l = (al4 & al5) ^ (~al4 & al6);
  37797. a += l & 0xffff; b += l >>> 16;
  37798. c += h & 0xffff; d += h >>> 16;
  37799. // K
  37800. h = K[i*2];
  37801. l = K[i*2+1];
  37802. a += l & 0xffff; b += l >>> 16;
  37803. c += h & 0xffff; d += h >>> 16;
  37804. // w
  37805. h = wh[i%16];
  37806. l = wl[i%16];
  37807. a += l & 0xffff; b += l >>> 16;
  37808. c += h & 0xffff; d += h >>> 16;
  37809. b += a >>> 16;
  37810. c += b >>> 16;
  37811. d += c >>> 16;
  37812. th = c & 0xffff | d << 16;
  37813. tl = a & 0xffff | b << 16;
  37814. // add
  37815. h = th;
  37816. l = tl;
  37817. a = l & 0xffff; b = l >>> 16;
  37818. c = h & 0xffff; d = h >>> 16;
  37819. // Sigma0
  37820. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  37821. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  37822. a += l & 0xffff; b += l >>> 16;
  37823. c += h & 0xffff; d += h >>> 16;
  37824. // Maj
  37825. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  37826. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  37827. a += l & 0xffff; b += l >>> 16;
  37828. c += h & 0xffff; d += h >>> 16;
  37829. b += a >>> 16;
  37830. c += b >>> 16;
  37831. d += c >>> 16;
  37832. bh7 = (c & 0xffff) | (d << 16);
  37833. bl7 = (a & 0xffff) | (b << 16);
  37834. // add
  37835. h = bh3;
  37836. l = bl3;
  37837. a = l & 0xffff; b = l >>> 16;
  37838. c = h & 0xffff; d = h >>> 16;
  37839. h = th;
  37840. l = tl;
  37841. a += l & 0xffff; b += l >>> 16;
  37842. c += h & 0xffff; d += h >>> 16;
  37843. b += a >>> 16;
  37844. c += b >>> 16;
  37845. d += c >>> 16;
  37846. bh3 = (c & 0xffff) | (d << 16);
  37847. bl3 = (a & 0xffff) | (b << 16);
  37848. ah1 = bh0;
  37849. ah2 = bh1;
  37850. ah3 = bh2;
  37851. ah4 = bh3;
  37852. ah5 = bh4;
  37853. ah6 = bh5;
  37854. ah7 = bh6;
  37855. ah0 = bh7;
  37856. al1 = bl0;
  37857. al2 = bl1;
  37858. al3 = bl2;
  37859. al4 = bl3;
  37860. al5 = bl4;
  37861. al6 = bl5;
  37862. al7 = bl6;
  37863. al0 = bl7;
  37864. if (i%16 === 15) {
  37865. for (j = 0; j < 16; j++) {
  37866. // add
  37867. h = wh[j];
  37868. l = wl[j];
  37869. a = l & 0xffff; b = l >>> 16;
  37870. c = h & 0xffff; d = h >>> 16;
  37871. h = wh[(j+9)%16];
  37872. l = wl[(j+9)%16];
  37873. a += l & 0xffff; b += l >>> 16;
  37874. c += h & 0xffff; d += h >>> 16;
  37875. // sigma0
  37876. th = wh[(j+1)%16];
  37877. tl = wl[(j+1)%16];
  37878. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  37879. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  37880. a += l & 0xffff; b += l >>> 16;
  37881. c += h & 0xffff; d += h >>> 16;
  37882. // sigma1
  37883. th = wh[(j+14)%16];
  37884. tl = wl[(j+14)%16];
  37885. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  37886. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  37887. a += l & 0xffff; b += l >>> 16;
  37888. c += h & 0xffff; d += h >>> 16;
  37889. b += a >>> 16;
  37890. c += b >>> 16;
  37891. d += c >>> 16;
  37892. wh[j] = (c & 0xffff) | (d << 16);
  37893. wl[j] = (a & 0xffff) | (b << 16);
  37894. }
  37895. }
  37896. }
  37897. // add
  37898. h = ah0;
  37899. l = al0;
  37900. a = l & 0xffff; b = l >>> 16;
  37901. c = h & 0xffff; d = h >>> 16;
  37902. h = hh[0];
  37903. l = hl[0];
  37904. a += l & 0xffff; b += l >>> 16;
  37905. c += h & 0xffff; d += h >>> 16;
  37906. b += a >>> 16;
  37907. c += b >>> 16;
  37908. d += c >>> 16;
  37909. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  37910. hl[0] = al0 = (a & 0xffff) | (b << 16);
  37911. h = ah1;
  37912. l = al1;
  37913. a = l & 0xffff; b = l >>> 16;
  37914. c = h & 0xffff; d = h >>> 16;
  37915. h = hh[1];
  37916. l = hl[1];
  37917. a += l & 0xffff; b += l >>> 16;
  37918. c += h & 0xffff; d += h >>> 16;
  37919. b += a >>> 16;
  37920. c += b >>> 16;
  37921. d += c >>> 16;
  37922. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  37923. hl[1] = al1 = (a & 0xffff) | (b << 16);
  37924. h = ah2;
  37925. l = al2;
  37926. a = l & 0xffff; b = l >>> 16;
  37927. c = h & 0xffff; d = h >>> 16;
  37928. h = hh[2];
  37929. l = hl[2];
  37930. a += l & 0xffff; b += l >>> 16;
  37931. c += h & 0xffff; d += h >>> 16;
  37932. b += a >>> 16;
  37933. c += b >>> 16;
  37934. d += c >>> 16;
  37935. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  37936. hl[2] = al2 = (a & 0xffff) | (b << 16);
  37937. h = ah3;
  37938. l = al3;
  37939. a = l & 0xffff; b = l >>> 16;
  37940. c = h & 0xffff; d = h >>> 16;
  37941. h = hh[3];
  37942. l = hl[3];
  37943. a += l & 0xffff; b += l >>> 16;
  37944. c += h & 0xffff; d += h >>> 16;
  37945. b += a >>> 16;
  37946. c += b >>> 16;
  37947. d += c >>> 16;
  37948. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  37949. hl[3] = al3 = (a & 0xffff) | (b << 16);
  37950. h = ah4;
  37951. l = al4;
  37952. a = l & 0xffff; b = l >>> 16;
  37953. c = h & 0xffff; d = h >>> 16;
  37954. h = hh[4];
  37955. l = hl[4];
  37956. a += l & 0xffff; b += l >>> 16;
  37957. c += h & 0xffff; d += h >>> 16;
  37958. b += a >>> 16;
  37959. c += b >>> 16;
  37960. d += c >>> 16;
  37961. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  37962. hl[4] = al4 = (a & 0xffff) | (b << 16);
  37963. h = ah5;
  37964. l = al5;
  37965. a = l & 0xffff; b = l >>> 16;
  37966. c = h & 0xffff; d = h >>> 16;
  37967. h = hh[5];
  37968. l = hl[5];
  37969. a += l & 0xffff; b += l >>> 16;
  37970. c += h & 0xffff; d += h >>> 16;
  37971. b += a >>> 16;
  37972. c += b >>> 16;
  37973. d += c >>> 16;
  37974. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  37975. hl[5] = al5 = (a & 0xffff) | (b << 16);
  37976. h = ah6;
  37977. l = al6;
  37978. a = l & 0xffff; b = l >>> 16;
  37979. c = h & 0xffff; d = h >>> 16;
  37980. h = hh[6];
  37981. l = hl[6];
  37982. a += l & 0xffff; b += l >>> 16;
  37983. c += h & 0xffff; d += h >>> 16;
  37984. b += a >>> 16;
  37985. c += b >>> 16;
  37986. d += c >>> 16;
  37987. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  37988. hl[6] = al6 = (a & 0xffff) | (b << 16);
  37989. h = ah7;
  37990. l = al7;
  37991. a = l & 0xffff; b = l >>> 16;
  37992. c = h & 0xffff; d = h >>> 16;
  37993. h = hh[7];
  37994. l = hl[7];
  37995. a += l & 0xffff; b += l >>> 16;
  37996. c += h & 0xffff; d += h >>> 16;
  37997. b += a >>> 16;
  37998. c += b >>> 16;
  37999. d += c >>> 16;
  38000. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  38001. hl[7] = al7 = (a & 0xffff) | (b << 16);
  38002. pos += 128;
  38003. n -= 128;
  38004. }
  38005. return n;
  38006. }
  38007. function crypto_hash(out, m, n) {
  38008. var hh = new Int32Array(8),
  38009. hl = new Int32Array(8),
  38010. x = new Uint8Array(256),
  38011. i, b = n;
  38012. hh[0] = 0x6a09e667;
  38013. hh[1] = 0xbb67ae85;
  38014. hh[2] = 0x3c6ef372;
  38015. hh[3] = 0xa54ff53a;
  38016. hh[4] = 0x510e527f;
  38017. hh[5] = 0x9b05688c;
  38018. hh[6] = 0x1f83d9ab;
  38019. hh[7] = 0x5be0cd19;
  38020. hl[0] = 0xf3bcc908;
  38021. hl[1] = 0x84caa73b;
  38022. hl[2] = 0xfe94f82b;
  38023. hl[3] = 0x5f1d36f1;
  38024. hl[4] = 0xade682d1;
  38025. hl[5] = 0x2b3e6c1f;
  38026. hl[6] = 0xfb41bd6b;
  38027. hl[7] = 0x137e2179;
  38028. crypto_hashblocks_hl(hh, hl, m, n);
  38029. n %= 128;
  38030. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  38031. x[n] = 128;
  38032. n = 256-128*(n<112?1:0);
  38033. x[n-9] = 0;
  38034. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  38035. crypto_hashblocks_hl(hh, hl, x, n);
  38036. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  38037. return 0;
  38038. }
  38039. function add(p, q) {
  38040. var a = gf(), b = gf(), c = gf(),
  38041. d = gf(), e = gf(), f = gf(),
  38042. g = gf(), h = gf(), t = gf();
  38043. Z(a, p[1], p[0]);
  38044. Z(t, q[1], q[0]);
  38045. M(a, a, t);
  38046. A(b, p[0], p[1]);
  38047. A(t, q[0], q[1]);
  38048. M(b, b, t);
  38049. M(c, p[3], q[3]);
  38050. M(c, c, D2);
  38051. M(d, p[2], q[2]);
  38052. A(d, d, d);
  38053. Z(e, b, a);
  38054. Z(f, d, c);
  38055. A(g, d, c);
  38056. A(h, b, a);
  38057. M(p[0], e, f);
  38058. M(p[1], h, g);
  38059. M(p[2], g, f);
  38060. M(p[3], e, h);
  38061. }
  38062. function cswap(p, q, b) {
  38063. var i;
  38064. for (i = 0; i < 4; i++) {
  38065. sel25519(p[i], q[i], b);
  38066. }
  38067. }
  38068. function pack(r, p) {
  38069. var tx = gf(), ty = gf(), zi = gf();
  38070. inv25519(zi, p[2]);
  38071. M(tx, p[0], zi);
  38072. M(ty, p[1], zi);
  38073. pack25519(r, ty);
  38074. r[31] ^= par25519(tx) << 7;
  38075. }
  38076. function scalarmult(p, q, s) {
  38077. var b, i;
  38078. set25519(p[0], gf0);
  38079. set25519(p[1], gf1);
  38080. set25519(p[2], gf1);
  38081. set25519(p[3], gf0);
  38082. for (i = 255; i >= 0; --i) {
  38083. b = (s[(i/8)|0] >> (i&7)) & 1;
  38084. cswap(p, q, b);
  38085. add(q, p);
  38086. add(p, p);
  38087. cswap(p, q, b);
  38088. }
  38089. }
  38090. function scalarbase(p, s) {
  38091. var q = [gf(), gf(), gf(), gf()];
  38092. set25519(q[0], X);
  38093. set25519(q[1], Y);
  38094. set25519(q[2], gf1);
  38095. M(q[3], X, Y);
  38096. scalarmult(p, q, s);
  38097. }
  38098. function crypto_sign_keypair(pk, sk, seeded) {
  38099. var d = new Uint8Array(64);
  38100. var p = [gf(), gf(), gf(), gf()];
  38101. var i;
  38102. if (!seeded) randombytes(sk, 32);
  38103. crypto_hash(d, sk, 32);
  38104. d[0] &= 248;
  38105. d[31] &= 127;
  38106. d[31] |= 64;
  38107. scalarbase(p, d);
  38108. pack(pk, p);
  38109. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  38110. return 0;
  38111. }
  38112. 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]);
  38113. function modL(r, x) {
  38114. var carry, i, j, k;
  38115. for (i = 63; i >= 32; --i) {
  38116. carry = 0;
  38117. for (j = i - 32, k = i - 12; j < k; ++j) {
  38118. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  38119. carry = (x[j] + 128) >> 8;
  38120. x[j] -= carry * 256;
  38121. }
  38122. x[j] += carry;
  38123. x[i] = 0;
  38124. }
  38125. carry = 0;
  38126. for (j = 0; j < 32; j++) {
  38127. x[j] += carry - (x[31] >> 4) * L[j];
  38128. carry = x[j] >> 8;
  38129. x[j] &= 255;
  38130. }
  38131. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  38132. for (i = 0; i < 32; i++) {
  38133. x[i+1] += x[i] >> 8;
  38134. r[i] = x[i] & 255;
  38135. }
  38136. }
  38137. function reduce(r) {
  38138. var x = new Float64Array(64), i;
  38139. for (i = 0; i < 64; i++) x[i] = r[i];
  38140. for (i = 0; i < 64; i++) r[i] = 0;
  38141. modL(r, x);
  38142. }
  38143. // Note: difference from C - smlen returned, not passed as argument.
  38144. function crypto_sign(sm, m, n, sk) {
  38145. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  38146. var i, j, x = new Float64Array(64);
  38147. var p = [gf(), gf(), gf(), gf()];
  38148. crypto_hash(d, sk, 32);
  38149. d[0] &= 248;
  38150. d[31] &= 127;
  38151. d[31] |= 64;
  38152. var smlen = n + 64;
  38153. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  38154. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  38155. crypto_hash(r, sm.subarray(32), n+32);
  38156. reduce(r);
  38157. scalarbase(p, r);
  38158. pack(sm, p);
  38159. for (i = 32; i < 64; i++) sm[i] = sk[i];
  38160. crypto_hash(h, sm, n + 64);
  38161. reduce(h);
  38162. for (i = 0; i < 64; i++) x[i] = 0;
  38163. for (i = 0; i < 32; i++) x[i] = r[i];
  38164. for (i = 0; i < 32; i++) {
  38165. for (j = 0; j < 32; j++) {
  38166. x[i+j] += h[i] * d[j];
  38167. }
  38168. }
  38169. modL(sm.subarray(32), x);
  38170. return smlen;
  38171. }
  38172. function unpackneg(r, p) {
  38173. var t = gf(), chk = gf(), num = gf(),
  38174. den = gf(), den2 = gf(), den4 = gf(),
  38175. den6 = gf();
  38176. set25519(r[2], gf1);
  38177. unpack25519(r[1], p);
  38178. S(num, r[1]);
  38179. M(den, num, D);
  38180. Z(num, num, r[2]);
  38181. A(den, r[2], den);
  38182. S(den2, den);
  38183. S(den4, den2);
  38184. M(den6, den4, den2);
  38185. M(t, den6, num);
  38186. M(t, t, den);
  38187. pow2523(t, t);
  38188. M(t, t, num);
  38189. M(t, t, den);
  38190. M(t, t, den);
  38191. M(r[0], t, den);
  38192. S(chk, r[0]);
  38193. M(chk, chk, den);
  38194. if (neq25519(chk, num)) M(r[0], r[0], I);
  38195. S(chk, r[0]);
  38196. M(chk, chk, den);
  38197. if (neq25519(chk, num)) return -1;
  38198. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  38199. M(r[3], r[0], r[1]);
  38200. return 0;
  38201. }
  38202. function crypto_sign_open(m, sm, n, pk) {
  38203. var i, mlen;
  38204. var t = new Uint8Array(32), h = new Uint8Array(64);
  38205. var p = [gf(), gf(), gf(), gf()],
  38206. q = [gf(), gf(), gf(), gf()];
  38207. mlen = -1;
  38208. if (n < 64) return -1;
  38209. if (unpackneg(q, pk)) return -1;
  38210. for (i = 0; i < n; i++) m[i] = sm[i];
  38211. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  38212. crypto_hash(h, m, n);
  38213. reduce(h);
  38214. scalarmult(p, q, h);
  38215. scalarbase(q, sm.subarray(32));
  38216. add(p, q);
  38217. pack(t, p);
  38218. n -= 64;
  38219. if (crypto_verify_32(sm, 0, t, 0)) {
  38220. for (i = 0; i < n; i++) m[i] = 0;
  38221. return -1;
  38222. }
  38223. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  38224. mlen = n;
  38225. return mlen;
  38226. }
  38227. var crypto_secretbox_KEYBYTES = 32,
  38228. crypto_secretbox_NONCEBYTES = 24,
  38229. crypto_secretbox_ZEROBYTES = 32,
  38230. crypto_secretbox_BOXZEROBYTES = 16,
  38231. crypto_scalarmult_BYTES = 32,
  38232. crypto_scalarmult_SCALARBYTES = 32,
  38233. crypto_box_PUBLICKEYBYTES = 32,
  38234. crypto_box_SECRETKEYBYTES = 32,
  38235. crypto_box_BEFORENMBYTES = 32,
  38236. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  38237. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  38238. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  38239. crypto_sign_BYTES = 64,
  38240. crypto_sign_PUBLICKEYBYTES = 32,
  38241. crypto_sign_SECRETKEYBYTES = 64,
  38242. crypto_sign_SEEDBYTES = 32,
  38243. crypto_hash_BYTES = 64;
  38244. nacl.lowlevel = {
  38245. crypto_core_hsalsa20: crypto_core_hsalsa20,
  38246. crypto_stream_xor: crypto_stream_xor,
  38247. crypto_stream: crypto_stream,
  38248. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  38249. crypto_stream_salsa20: crypto_stream_salsa20,
  38250. crypto_onetimeauth: crypto_onetimeauth,
  38251. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  38252. crypto_verify_16: crypto_verify_16,
  38253. crypto_verify_32: crypto_verify_32,
  38254. crypto_secretbox: crypto_secretbox,
  38255. crypto_secretbox_open: crypto_secretbox_open,
  38256. crypto_scalarmult: crypto_scalarmult,
  38257. crypto_scalarmult_base: crypto_scalarmult_base,
  38258. crypto_box_beforenm: crypto_box_beforenm,
  38259. crypto_box_afternm: crypto_box_afternm,
  38260. crypto_box: crypto_box,
  38261. crypto_box_open: crypto_box_open,
  38262. crypto_box_keypair: crypto_box_keypair,
  38263. crypto_hash: crypto_hash,
  38264. crypto_sign: crypto_sign,
  38265. crypto_sign_keypair: crypto_sign_keypair,
  38266. crypto_sign_open: crypto_sign_open,
  38267. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  38268. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  38269. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  38270. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  38271. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  38272. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  38273. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  38274. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  38275. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  38276. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  38277. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  38278. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  38279. crypto_sign_BYTES: crypto_sign_BYTES,
  38280. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  38281. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  38282. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  38283. crypto_hash_BYTES: crypto_hash_BYTES
  38284. };
  38285. /* High-level API */
  38286. function checkLengths(k, n) {
  38287. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  38288. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  38289. }
  38290. function checkBoxLengths(pk, sk) {
  38291. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  38292. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  38293. }
  38294. function checkArrayTypes() {
  38295. for (var i = 0; i < arguments.length; i++) {
  38296. if (!(arguments[i] instanceof Uint8Array))
  38297. throw new TypeError('unexpected type, use Uint8Array');
  38298. }
  38299. }
  38300. function cleanup(arr) {
  38301. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  38302. }
  38303. nacl.randomBytes = function(n) {
  38304. var b = new Uint8Array(n);
  38305. randombytes(b, n);
  38306. return b;
  38307. };
  38308. nacl.secretbox = function(msg, nonce, key) {
  38309. checkArrayTypes(msg, nonce, key);
  38310. checkLengths(key, nonce);
  38311. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  38312. var c = new Uint8Array(m.length);
  38313. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  38314. crypto_secretbox(c, m, m.length, nonce, key);
  38315. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  38316. };
  38317. nacl.secretbox.open = function(box, nonce, key) {
  38318. checkArrayTypes(box, nonce, key);
  38319. checkLengths(key, nonce);
  38320. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  38321. var m = new Uint8Array(c.length);
  38322. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  38323. if (c.length < 32) return null;
  38324. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  38325. return m.subarray(crypto_secretbox_ZEROBYTES);
  38326. };
  38327. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  38328. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  38329. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  38330. nacl.scalarMult = function(n, p) {
  38331. checkArrayTypes(n, p);
  38332. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38333. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  38334. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38335. crypto_scalarmult(q, n, p);
  38336. return q;
  38337. };
  38338. nacl.scalarMult.base = function(n) {
  38339. checkArrayTypes(n);
  38340. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38341. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38342. crypto_scalarmult_base(q, n);
  38343. return q;
  38344. };
  38345. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  38346. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  38347. nacl.box = function(msg, nonce, publicKey, secretKey) {
  38348. var k = nacl.box.before(publicKey, secretKey);
  38349. return nacl.secretbox(msg, nonce, k);
  38350. };
  38351. nacl.box.before = function(publicKey, secretKey) {
  38352. checkArrayTypes(publicKey, secretKey);
  38353. checkBoxLengths(publicKey, secretKey);
  38354. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  38355. crypto_box_beforenm(k, publicKey, secretKey);
  38356. return k;
  38357. };
  38358. nacl.box.after = nacl.secretbox;
  38359. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  38360. var k = nacl.box.before(publicKey, secretKey);
  38361. return nacl.secretbox.open(msg, nonce, k);
  38362. };
  38363. nacl.box.open.after = nacl.secretbox.open;
  38364. nacl.box.keyPair = function() {
  38365. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38366. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  38367. crypto_box_keypair(pk, sk);
  38368. return {publicKey: pk, secretKey: sk};
  38369. };
  38370. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  38371. checkArrayTypes(secretKey);
  38372. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  38373. throw new Error('bad secret key size');
  38374. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38375. crypto_scalarmult_base(pk, secretKey);
  38376. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38377. };
  38378. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  38379. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  38380. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  38381. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  38382. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  38383. nacl.sign = function(msg, secretKey) {
  38384. checkArrayTypes(msg, secretKey);
  38385. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38386. throw new Error('bad secret key size');
  38387. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  38388. crypto_sign(signedMsg, msg, msg.length, secretKey);
  38389. return signedMsg;
  38390. };
  38391. nacl.sign.open = function(signedMsg, publicKey) {
  38392. checkArrayTypes(signedMsg, publicKey);
  38393. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38394. throw new Error('bad public key size');
  38395. var tmp = new Uint8Array(signedMsg.length);
  38396. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  38397. if (mlen < 0) return null;
  38398. var m = new Uint8Array(mlen);
  38399. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  38400. return m;
  38401. };
  38402. nacl.sign.detached = function(msg, secretKey) {
  38403. var signedMsg = nacl.sign(msg, secretKey);
  38404. var sig = new Uint8Array(crypto_sign_BYTES);
  38405. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  38406. return sig;
  38407. };
  38408. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  38409. checkArrayTypes(msg, sig, publicKey);
  38410. if (sig.length !== crypto_sign_BYTES)
  38411. throw new Error('bad signature size');
  38412. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38413. throw new Error('bad public key size');
  38414. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  38415. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  38416. var i;
  38417. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  38418. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  38419. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  38420. };
  38421. nacl.sign.keyPair = function() {
  38422. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38423. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38424. crypto_sign_keypair(pk, sk);
  38425. return {publicKey: pk, secretKey: sk};
  38426. };
  38427. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  38428. checkArrayTypes(secretKey);
  38429. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38430. throw new Error('bad secret key size');
  38431. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38432. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  38433. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38434. };
  38435. nacl.sign.keyPair.fromSeed = function(seed) {
  38436. checkArrayTypes(seed);
  38437. if (seed.length !== crypto_sign_SEEDBYTES)
  38438. throw new Error('bad seed size');
  38439. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38440. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38441. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  38442. crypto_sign_keypair(pk, sk, true);
  38443. return {publicKey: pk, secretKey: sk};
  38444. };
  38445. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  38446. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  38447. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  38448. nacl.sign.signatureLength = crypto_sign_BYTES;
  38449. nacl.hash = function(msg) {
  38450. checkArrayTypes(msg);
  38451. var h = new Uint8Array(crypto_hash_BYTES);
  38452. crypto_hash(h, msg, msg.length);
  38453. return h;
  38454. };
  38455. nacl.hash.hashLength = crypto_hash_BYTES;
  38456. nacl.verify = function(x, y) {
  38457. checkArrayTypes(x, y);
  38458. // Zero length arguments are considered not equal.
  38459. if (x.length === 0 || y.length === 0) return false;
  38460. if (x.length !== y.length) return false;
  38461. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  38462. };
  38463. nacl.setPRNG = function(fn) {
  38464. randombytes = fn;
  38465. };
  38466. (function() {
  38467. // Initialize PRNG if environment provides CSPRNG.
  38468. // If not, methods calling randombytes will throw.
  38469. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  38470. if (crypto && crypto.getRandomValues) {
  38471. // Browsers.
  38472. var QUOTA = 65536;
  38473. nacl.setPRNG(function(x, n) {
  38474. var i, v = new Uint8Array(n);
  38475. for (i = 0; i < n; i += QUOTA) {
  38476. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  38477. }
  38478. for (i = 0; i < n; i++) x[i] = v[i];
  38479. cleanup(v);
  38480. });
  38481. } else if (true) {
  38482. // Node.js.
  38483. crypto = __webpack_require__(3);
  38484. if (crypto && crypto.randomBytes) {
  38485. nacl.setPRNG(function(x, n) {
  38486. var i, v = crypto.randomBytes(n);
  38487. for (i = 0; i < n; i++) x[i] = v[i];
  38488. cleanup(v);
  38489. });
  38490. }
  38491. }
  38492. })();
  38493. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  38494. /***/ }),
  38495. /* 1 */
  38496. /***/ (function(module, exports, __webpack_require__) {
  38497. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  38498. // Public domain.
  38499. (function(root, f) {
  38500. 'use strict';
  38501. if ( true && module.exports) module.exports = f();
  38502. else if (root.nacl) root.nacl.util = f();
  38503. else {
  38504. root.nacl = {};
  38505. root.nacl.util = f();
  38506. }
  38507. }(this, function() {
  38508. 'use strict';
  38509. var util = {};
  38510. function validateBase64(s) {
  38511. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  38512. throw new TypeError('invalid encoding');
  38513. }
  38514. }
  38515. util.decodeUTF8 = function(s) {
  38516. if (typeof s !== 'string') throw new TypeError('expected string');
  38517. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  38518. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38519. return b;
  38520. };
  38521. util.encodeUTF8 = function(arr) {
  38522. var i, s = [];
  38523. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  38524. return decodeURIComponent(escape(s.join('')));
  38525. };
  38526. if (typeof atob === 'undefined') {
  38527. // Node.js
  38528. if (typeof Buffer.from !== 'undefined') {
  38529. // Node v6 and later
  38530. util.encodeBase64 = function (arr) { // v6 and later
  38531. return Buffer.from(arr).toString('base64');
  38532. };
  38533. util.decodeBase64 = function (s) {
  38534. validateBase64(s);
  38535. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  38536. };
  38537. } else {
  38538. // Node earlier than v6
  38539. util.encodeBase64 = function (arr) { // v6 and later
  38540. return (new Buffer(arr)).toString('base64');
  38541. };
  38542. util.decodeBase64 = function(s) {
  38543. validateBase64(s);
  38544. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  38545. };
  38546. }
  38547. } else {
  38548. // Browsers
  38549. util.encodeBase64 = function(arr) {
  38550. var i, s = [], len = arr.length;
  38551. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  38552. return btoa(s.join(''));
  38553. };
  38554. util.decodeBase64 = function(s) {
  38555. validateBase64(s);
  38556. var i, d = atob(s), b = new Uint8Array(d.length);
  38557. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38558. return b;
  38559. };
  38560. }
  38561. return util;
  38562. }));
  38563. /***/ }),
  38564. /* 2 */
  38565. /***/ (function(module, exports, __webpack_require__) {
  38566. // required so we don't have to do require('pusher').default etc.
  38567. module.exports = __webpack_require__(4).default;
  38568. /***/ }),
  38569. /* 3 */
  38570. /***/ (function(module, exports) {
  38571. /* (ignored) */
  38572. /***/ }),
  38573. /* 4 */
  38574. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38575. "use strict";
  38576. __webpack_require__.r(__webpack_exports__);
  38577. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  38578. var ScriptReceiverFactory = (function () {
  38579. function ScriptReceiverFactory(prefix, name) {
  38580. this.lastId = 0;
  38581. this.prefix = prefix;
  38582. this.name = name;
  38583. }
  38584. ScriptReceiverFactory.prototype.create = function (callback) {
  38585. this.lastId++;
  38586. var number = this.lastId;
  38587. var id = this.prefix + number;
  38588. var name = this.name + "[" + number + "]";
  38589. var called = false;
  38590. var callbackWrapper = function () {
  38591. if (!called) {
  38592. callback.apply(null, arguments);
  38593. called = true;
  38594. }
  38595. };
  38596. this[number] = callbackWrapper;
  38597. return { number: number, id: id, name: name, callback: callbackWrapper };
  38598. };
  38599. ScriptReceiverFactory.prototype.remove = function (receiver) {
  38600. delete this[receiver.number];
  38601. };
  38602. return ScriptReceiverFactory;
  38603. }());
  38604. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  38605. // CONCATENATED MODULE: ./src/core/defaults.ts
  38606. var Defaults = {
  38607. VERSION: "5.0.3",
  38608. PROTOCOL: 7,
  38609. host: 'ws.pusherapp.com',
  38610. ws_port: 80,
  38611. wss_port: 443,
  38612. ws_path: '',
  38613. sockjs_host: 'sockjs.pusher.com',
  38614. sockjs_http_port: 80,
  38615. sockjs_https_port: 443,
  38616. sockjs_path: '/pusher',
  38617. stats_host: 'stats.pusher.com',
  38618. channel_auth_endpoint: '/pusher/auth',
  38619. channel_auth_transport: 'ajax',
  38620. activity_timeout: 120000,
  38621. pong_timeout: 30000,
  38622. unavailable_timeout: 10000,
  38623. cdn_http: "http://js.pusher.com",
  38624. cdn_https: "https://js.pusher.com",
  38625. dependency_suffix: ""
  38626. };
  38627. /* harmony default export */ var defaults = (Defaults);
  38628. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  38629. var dependency_loader_DependencyLoader = (function () {
  38630. function DependencyLoader(options) {
  38631. this.options = options;
  38632. this.receivers = options.receivers || ScriptReceivers;
  38633. this.loading = {};
  38634. }
  38635. DependencyLoader.prototype.load = function (name, options, callback) {
  38636. var self = this;
  38637. if (self.loading[name] && self.loading[name].length > 0) {
  38638. self.loading[name].push(callback);
  38639. }
  38640. else {
  38641. self.loading[name] = [callback];
  38642. var request = runtime.createScriptRequest(self.getPath(name, options));
  38643. var receiver = self.receivers.create(function (error) {
  38644. self.receivers.remove(receiver);
  38645. if (self.loading[name]) {
  38646. var callbacks = self.loading[name];
  38647. delete self.loading[name];
  38648. var successCallback = function (wasSuccessful) {
  38649. if (!wasSuccessful) {
  38650. request.cleanup();
  38651. }
  38652. };
  38653. for (var i = 0; i < callbacks.length; i++) {
  38654. callbacks[i](error, successCallback);
  38655. }
  38656. }
  38657. });
  38658. request.send(receiver);
  38659. }
  38660. };
  38661. DependencyLoader.prototype.getRoot = function (options) {
  38662. var cdn;
  38663. var protocol = runtime.getDocument().location.protocol;
  38664. if ((options && options.useTLS) || protocol === "https:") {
  38665. cdn = this.options.cdn_https;
  38666. }
  38667. else {
  38668. cdn = this.options.cdn_http;
  38669. }
  38670. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  38671. };
  38672. DependencyLoader.prototype.getPath = function (name, options) {
  38673. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  38674. };
  38675. ;
  38676. return DependencyLoader;
  38677. }());
  38678. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  38679. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  38680. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  38681. var Dependencies = new dependency_loader({
  38682. cdn_http: defaults.cdn_http,
  38683. cdn_https: defaults.cdn_https,
  38684. version: defaults.VERSION,
  38685. suffix: defaults.dependency_suffix,
  38686. receivers: DependenciesReceivers
  38687. });
  38688. // CONCATENATED MODULE: ./src/core/base64.ts
  38689. function encode(s) {
  38690. return btoa(utob(s));
  38691. }
  38692. var fromCharCode = String.fromCharCode;
  38693. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  38694. var b64tab = {};
  38695. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  38696. b64tab[b64chars.charAt(base64_i)] = base64_i;
  38697. }
  38698. var cb_utob = function (c) {
  38699. var cc = c.charCodeAt(0);
  38700. return cc < 0x80
  38701. ? c
  38702. : cc < 0x800
  38703. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  38704. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  38705. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  38706. fromCharCode(0x80 | (cc & 0x3f));
  38707. };
  38708. var utob = function (u) {
  38709. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  38710. };
  38711. var cb_encode = function (ccc) {
  38712. var padlen = [0, 2, 1][ccc.length % 3];
  38713. var ord = (ccc.charCodeAt(0) << 16) |
  38714. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  38715. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  38716. var chars = [
  38717. b64chars.charAt(ord >>> 18),
  38718. b64chars.charAt((ord >>> 12) & 63),
  38719. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  38720. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  38721. ];
  38722. return chars.join('');
  38723. };
  38724. var btoa = window.btoa ||
  38725. function (b) {
  38726. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  38727. };
  38728. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  38729. var Timer = (function () {
  38730. function Timer(set, clear, delay, callback) {
  38731. var _this = this;
  38732. this.clear = clear;
  38733. this.timer = set(function () {
  38734. if (_this.timer) {
  38735. _this.timer = callback(_this.timer);
  38736. }
  38737. }, delay);
  38738. }
  38739. Timer.prototype.isRunning = function () {
  38740. return this.timer !== null;
  38741. };
  38742. Timer.prototype.ensureAborted = function () {
  38743. if (this.timer) {
  38744. this.clear(this.timer);
  38745. this.timer = null;
  38746. }
  38747. };
  38748. return Timer;
  38749. }());
  38750. /* harmony default export */ var abstract_timer = (Timer);
  38751. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  38752. var __extends = (undefined && undefined.__extends) || (function () {
  38753. var extendStatics = function (d, b) {
  38754. extendStatics = Object.setPrototypeOf ||
  38755. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38756. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38757. return extendStatics(d, b);
  38758. };
  38759. return function (d, b) {
  38760. extendStatics(d, b);
  38761. function __() { this.constructor = d; }
  38762. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38763. };
  38764. })();
  38765. function timers_clearTimeout(timer) {
  38766. window.clearTimeout(timer);
  38767. }
  38768. function timers_clearInterval(timer) {
  38769. window.clearInterval(timer);
  38770. }
  38771. var OneOffTimer = (function (_super) {
  38772. __extends(OneOffTimer, _super);
  38773. function OneOffTimer(delay, callback) {
  38774. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  38775. callback();
  38776. return null;
  38777. }) || this;
  38778. }
  38779. return OneOffTimer;
  38780. }(abstract_timer));
  38781. var PeriodicTimer = (function (_super) {
  38782. __extends(PeriodicTimer, _super);
  38783. function PeriodicTimer(delay, callback) {
  38784. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  38785. callback();
  38786. return timer;
  38787. }) || this;
  38788. }
  38789. return PeriodicTimer;
  38790. }(abstract_timer));
  38791. // CONCATENATED MODULE: ./src/core/util.ts
  38792. var Util = {
  38793. now: function () {
  38794. if (Date.now) {
  38795. return Date.now();
  38796. }
  38797. else {
  38798. return new Date().valueOf();
  38799. }
  38800. },
  38801. defer: function (callback) {
  38802. return new OneOffTimer(0, callback);
  38803. },
  38804. method: function (name) {
  38805. var args = [];
  38806. for (var _i = 1; _i < arguments.length; _i++) {
  38807. args[_i - 1] = arguments[_i];
  38808. }
  38809. var boundArguments = Array.prototype.slice.call(arguments, 1);
  38810. return function (object) {
  38811. return object[name].apply(object, boundArguments.concat(arguments));
  38812. };
  38813. }
  38814. };
  38815. /* harmony default export */ var util = (Util);
  38816. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  38817. function extend(target) {
  38818. var sources = [];
  38819. for (var _i = 1; _i < arguments.length; _i++) {
  38820. sources[_i - 1] = arguments[_i];
  38821. }
  38822. for (var i = 0; i < sources.length; i++) {
  38823. var extensions = sources[i];
  38824. for (var property in extensions) {
  38825. if (extensions[property] && extensions[property].constructor &&
  38826. extensions[property].constructor === Object) {
  38827. target[property] = extend(target[property] || {}, extensions[property]);
  38828. }
  38829. else {
  38830. target[property] = extensions[property];
  38831. }
  38832. }
  38833. }
  38834. return target;
  38835. }
  38836. function stringify() {
  38837. var m = ["Pusher"];
  38838. for (var i = 0; i < arguments.length; i++) {
  38839. if (typeof arguments[i] === "string") {
  38840. m.push(arguments[i]);
  38841. }
  38842. else {
  38843. m.push(safeJSONStringify(arguments[i]));
  38844. }
  38845. }
  38846. return m.join(" : ");
  38847. }
  38848. function arrayIndexOf(array, item) {
  38849. var nativeIndexOf = Array.prototype.indexOf;
  38850. if (array === null) {
  38851. return -1;
  38852. }
  38853. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  38854. return array.indexOf(item);
  38855. }
  38856. for (var i = 0, l = array.length; i < l; i++) {
  38857. if (array[i] === item) {
  38858. return i;
  38859. }
  38860. }
  38861. return -1;
  38862. }
  38863. function objectApply(object, f) {
  38864. for (var key in object) {
  38865. if (Object.prototype.hasOwnProperty.call(object, key)) {
  38866. f(object[key], key, object);
  38867. }
  38868. }
  38869. }
  38870. function keys(object) {
  38871. var keys = [];
  38872. objectApply(object, function (_, key) {
  38873. keys.push(key);
  38874. });
  38875. return keys;
  38876. }
  38877. function values(object) {
  38878. var values = [];
  38879. objectApply(object, function (value) {
  38880. values.push(value);
  38881. });
  38882. return values;
  38883. }
  38884. function apply(array, f, context) {
  38885. for (var i = 0; i < array.length; i++) {
  38886. f.call(context || window, array[i], i, array);
  38887. }
  38888. }
  38889. function map(array, f) {
  38890. var result = [];
  38891. for (var i = 0; i < array.length; i++) {
  38892. result.push(f(array[i], i, array, result));
  38893. }
  38894. return result;
  38895. }
  38896. function mapObject(object, f) {
  38897. var result = {};
  38898. objectApply(object, function (value, key) {
  38899. result[key] = f(value);
  38900. });
  38901. return result;
  38902. }
  38903. function filter(array, test) {
  38904. test = test || function (value) { return !!value; };
  38905. var result = [];
  38906. for (var i = 0; i < array.length; i++) {
  38907. if (test(array[i], i, array, result)) {
  38908. result.push(array[i]);
  38909. }
  38910. }
  38911. return result;
  38912. }
  38913. function filterObject(object, test) {
  38914. var result = {};
  38915. objectApply(object, function (value, key) {
  38916. if ((test && test(value, key, object, result)) || Boolean(value)) {
  38917. result[key] = value;
  38918. }
  38919. });
  38920. return result;
  38921. }
  38922. function flatten(object) {
  38923. var result = [];
  38924. objectApply(object, function (value, key) {
  38925. result.push([key, value]);
  38926. });
  38927. return result;
  38928. }
  38929. function any(array, test) {
  38930. for (var i = 0; i < array.length; i++) {
  38931. if (test(array[i], i, array)) {
  38932. return true;
  38933. }
  38934. }
  38935. return false;
  38936. }
  38937. function collections_all(array, test) {
  38938. for (var i = 0; i < array.length; i++) {
  38939. if (!test(array[i], i, array)) {
  38940. return false;
  38941. }
  38942. }
  38943. return true;
  38944. }
  38945. function encodeParamsObject(data) {
  38946. return mapObject(data, function (value) {
  38947. if (typeof value === "object") {
  38948. value = safeJSONStringify(value);
  38949. }
  38950. return encodeURIComponent(encode(value.toString()));
  38951. });
  38952. }
  38953. function buildQueryString(data) {
  38954. var params = filterObject(data, function (value) {
  38955. return value !== undefined;
  38956. });
  38957. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  38958. return query;
  38959. }
  38960. function decycleObject(object) {
  38961. var objects = [], paths = [];
  38962. return (function derez(value, path) {
  38963. var i, name, nu;
  38964. switch (typeof value) {
  38965. case 'object':
  38966. if (!value) {
  38967. return null;
  38968. }
  38969. for (i = 0; i < objects.length; i += 1) {
  38970. if (objects[i] === value) {
  38971. return { $ref: paths[i] };
  38972. }
  38973. }
  38974. objects.push(value);
  38975. paths.push(path);
  38976. if (Object.prototype.toString.apply(value) === '[object Array]') {
  38977. nu = [];
  38978. for (i = 0; i < value.length; i += 1) {
  38979. nu[i] = derez(value[i], path + '[' + i + ']');
  38980. }
  38981. }
  38982. else {
  38983. nu = {};
  38984. for (name in value) {
  38985. if (Object.prototype.hasOwnProperty.call(value, name)) {
  38986. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  38987. }
  38988. }
  38989. }
  38990. return nu;
  38991. case 'number':
  38992. case 'string':
  38993. case 'boolean':
  38994. return value;
  38995. }
  38996. }(object, '$'));
  38997. }
  38998. function safeJSONStringify(source) {
  38999. try {
  39000. return JSON.stringify(source);
  39001. }
  39002. catch (e) {
  39003. return JSON.stringify(decycleObject(source));
  39004. }
  39005. }
  39006. // CONCATENATED MODULE: ./src/core/logger.ts
  39007. var logger_Logger = (function () {
  39008. function Logger() {
  39009. this.globalLog = function (message) {
  39010. if (window.console && window.console.log) {
  39011. window.console.log(message);
  39012. }
  39013. };
  39014. }
  39015. Logger.prototype.debug = function () {
  39016. var args = [];
  39017. for (var _i = 0; _i < arguments.length; _i++) {
  39018. args[_i] = arguments[_i];
  39019. }
  39020. this.log(this.globalLog, args);
  39021. };
  39022. Logger.prototype.warn = function () {
  39023. var args = [];
  39024. for (var _i = 0; _i < arguments.length; _i++) {
  39025. args[_i] = arguments[_i];
  39026. }
  39027. this.log(this.globalLogWarn, args);
  39028. };
  39029. Logger.prototype.error = function () {
  39030. var args = [];
  39031. for (var _i = 0; _i < arguments.length; _i++) {
  39032. args[_i] = arguments[_i];
  39033. }
  39034. this.log(this.globalLogError, args);
  39035. };
  39036. Logger.prototype.globalLogWarn = function (message) {
  39037. if (window.console && window.console.warn) {
  39038. window.console.warn(message);
  39039. }
  39040. else {
  39041. this.globalLog(message);
  39042. }
  39043. };
  39044. Logger.prototype.globalLogError = function (message) {
  39045. if (window.console && window.console.error) {
  39046. window.console.error(message);
  39047. }
  39048. else {
  39049. this.globalLogWarn(message);
  39050. }
  39051. };
  39052. Logger.prototype.log = function (defaultLoggingFunction) {
  39053. var args = [];
  39054. for (var _i = 1; _i < arguments.length; _i++) {
  39055. args[_i - 1] = arguments[_i];
  39056. }
  39057. var message = stringify.apply(this, arguments);
  39058. if (core_pusher.log) {
  39059. core_pusher.log(message);
  39060. }
  39061. else if (core_pusher.logToConsole) {
  39062. var log = defaultLoggingFunction.bind(this);
  39063. log(message);
  39064. }
  39065. };
  39066. return Logger;
  39067. }());
  39068. /* harmony default export */ var logger = (new logger_Logger());
  39069. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  39070. var urlStore = {
  39071. baseUrl: "https://pusher.com",
  39072. urls: {
  39073. authenticationEndpoint: {
  39074. path: "/docs/authenticating_users",
  39075. },
  39076. javascriptQuickStart: {
  39077. path: "/docs/javascript_quick_start"
  39078. },
  39079. triggeringClientEvents: {
  39080. path: "/docs/client_api_guide/client_events#trigger-events"
  39081. }
  39082. }
  39083. };
  39084. var buildLogSuffix = function (key) {
  39085. var urlPrefix = "See:";
  39086. var urlObj = urlStore.urls[key];
  39087. if (!urlObj)
  39088. return "";
  39089. var url;
  39090. if (urlObj.fullUrl) {
  39091. url = urlObj.fullUrl;
  39092. }
  39093. else if (urlObj.path) {
  39094. url = urlStore.baseUrl + urlObj.path;
  39095. }
  39096. if (!url)
  39097. return "";
  39098. return urlPrefix + " " + url;
  39099. };
  39100. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  39101. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  39102. var ajax = function (context, socketId, callback) {
  39103. var self = this, xhr;
  39104. xhr = runtime.createXHR();
  39105. xhr.open("POST", self.options.authEndpoint, true);
  39106. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  39107. for (var headerName in this.authOptions.headers) {
  39108. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  39109. }
  39110. xhr.onreadystatechange = function () {
  39111. if (xhr.readyState === 4) {
  39112. if (xhr.status === 200) {
  39113. var data, parsed = false;
  39114. try {
  39115. data = JSON.parse(xhr.responseText);
  39116. parsed = true;
  39117. }
  39118. catch (e) {
  39119. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  39120. }
  39121. if (parsed) {
  39122. callback(false, data);
  39123. }
  39124. }
  39125. else {
  39126. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39127. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  39128. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  39129. ("Clients must be authenticated to join private or presence channels. " + suffix));
  39130. callback(true, xhr.status);
  39131. }
  39132. }
  39133. };
  39134. xhr.send(this.composeQuery(socketId));
  39135. return xhr;
  39136. };
  39137. /* harmony default export */ var xhr_auth = (ajax);
  39138. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  39139. var jsonp = function (context, socketId, callback) {
  39140. if (this.authOptions.headers !== undefined) {
  39141. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  39142. }
  39143. var callbackName = context.nextAuthCallbackID.toString();
  39144. context.nextAuthCallbackID++;
  39145. var document = context.getDocument();
  39146. var script = document.createElement("script");
  39147. context.auth_callbacks[callbackName] = function (data) {
  39148. callback(false, data);
  39149. };
  39150. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  39151. script.src = this.options.authEndpoint +
  39152. '?callback=' +
  39153. encodeURIComponent(callback_name) +
  39154. '&' +
  39155. this.composeQuery(socketId);
  39156. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  39157. head.insertBefore(script, head.firstChild);
  39158. };
  39159. /* harmony default export */ var jsonp_auth = (jsonp);
  39160. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  39161. var ScriptRequest = (function () {
  39162. function ScriptRequest(src) {
  39163. this.src = src;
  39164. }
  39165. ScriptRequest.prototype.send = function (receiver) {
  39166. var self = this;
  39167. var errorString = "Error loading " + self.src;
  39168. self.script = document.createElement("script");
  39169. self.script.id = receiver.id;
  39170. self.script.src = self.src;
  39171. self.script.type = "text/javascript";
  39172. self.script.charset = "UTF-8";
  39173. if (self.script.addEventListener) {
  39174. self.script.onerror = function () {
  39175. receiver.callback(errorString);
  39176. };
  39177. self.script.onload = function () {
  39178. receiver.callback(null);
  39179. };
  39180. }
  39181. else {
  39182. self.script.onreadystatechange = function () {
  39183. if (self.script.readyState === 'loaded' ||
  39184. self.script.readyState === 'complete') {
  39185. receiver.callback(null);
  39186. }
  39187. };
  39188. }
  39189. if (self.script.async === undefined && document.attachEvent &&
  39190. /opera/i.test(navigator.userAgent)) {
  39191. self.errorScript = document.createElement("script");
  39192. self.errorScript.id = receiver.id + "_error";
  39193. self.errorScript.text = receiver.name + "('" + errorString + "');";
  39194. self.script.async = self.errorScript.async = false;
  39195. }
  39196. else {
  39197. self.script.async = true;
  39198. }
  39199. var head = document.getElementsByTagName('head')[0];
  39200. head.insertBefore(self.script, head.firstChild);
  39201. if (self.errorScript) {
  39202. head.insertBefore(self.errorScript, self.script.nextSibling);
  39203. }
  39204. };
  39205. ScriptRequest.prototype.cleanup = function () {
  39206. if (this.script) {
  39207. this.script.onload = this.script.onerror = null;
  39208. this.script.onreadystatechange = null;
  39209. }
  39210. if (this.script && this.script.parentNode) {
  39211. this.script.parentNode.removeChild(this.script);
  39212. }
  39213. if (this.errorScript && this.errorScript.parentNode) {
  39214. this.errorScript.parentNode.removeChild(this.errorScript);
  39215. }
  39216. this.script = null;
  39217. this.errorScript = null;
  39218. };
  39219. return ScriptRequest;
  39220. }());
  39221. /* harmony default export */ var script_request = (ScriptRequest);
  39222. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  39223. var jsonp_request_JSONPRequest = (function () {
  39224. function JSONPRequest(url, data) {
  39225. this.url = url;
  39226. this.data = data;
  39227. }
  39228. JSONPRequest.prototype.send = function (receiver) {
  39229. if (this.request) {
  39230. return;
  39231. }
  39232. var query = buildQueryString(this.data);
  39233. var url = this.url + "/" + receiver.number + "?" + query;
  39234. this.request = runtime.createScriptRequest(url);
  39235. this.request.send(receiver);
  39236. };
  39237. JSONPRequest.prototype.cleanup = function () {
  39238. if (this.request) {
  39239. this.request.cleanup();
  39240. }
  39241. };
  39242. return JSONPRequest;
  39243. }());
  39244. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  39245. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  39246. var getAgent = function (sender, useTLS) {
  39247. return function (data, callback) {
  39248. var scheme = "http" + (useTLS ? "s" : "") + "://";
  39249. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  39250. var request = runtime.createJSONPRequest(url, data);
  39251. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  39252. ScriptReceivers.remove(receiver);
  39253. request.cleanup();
  39254. if (result && result.host) {
  39255. sender.host = result.host;
  39256. }
  39257. if (callback) {
  39258. callback(error, result);
  39259. }
  39260. });
  39261. request.send(receiver);
  39262. };
  39263. };
  39264. var jsonp_timeline_jsonp = {
  39265. name: 'jsonp',
  39266. getAgent: getAgent
  39267. };
  39268. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  39269. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  39270. function getGenericURL(baseScheme, params, path) {
  39271. var scheme = baseScheme + (params.useTLS ? "s" : "");
  39272. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  39273. return scheme + "://" + host + path;
  39274. }
  39275. function getGenericPath(key, queryString) {
  39276. var path = "/app/" + key;
  39277. var query = "?protocol=" + defaults.PROTOCOL +
  39278. "&client=js" +
  39279. "&version=" + defaults.VERSION +
  39280. (queryString ? ("&" + queryString) : "");
  39281. return path + query;
  39282. }
  39283. var ws = {
  39284. getInitial: function (key, params) {
  39285. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  39286. return getGenericURL("ws", params, path);
  39287. }
  39288. };
  39289. var http = {
  39290. getInitial: function (key, params) {
  39291. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  39292. return getGenericURL("http", params, path);
  39293. }
  39294. };
  39295. var sockjs = {
  39296. getInitial: function (key, params) {
  39297. return getGenericURL("http", params, params.httpPath || "/pusher");
  39298. },
  39299. getPath: function (key, params) {
  39300. return getGenericPath(key);
  39301. }
  39302. };
  39303. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  39304. var callback_registry_CallbackRegistry = (function () {
  39305. function CallbackRegistry() {
  39306. this._callbacks = {};
  39307. }
  39308. CallbackRegistry.prototype.get = function (name) {
  39309. return this._callbacks[prefix(name)];
  39310. };
  39311. CallbackRegistry.prototype.add = function (name, callback, context) {
  39312. var prefixedEventName = prefix(name);
  39313. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  39314. this._callbacks[prefixedEventName].push({
  39315. fn: callback,
  39316. context: context
  39317. });
  39318. };
  39319. CallbackRegistry.prototype.remove = function (name, callback, context) {
  39320. if (!name && !callback && !context) {
  39321. this._callbacks = {};
  39322. return;
  39323. }
  39324. var names = name ? [prefix(name)] : keys(this._callbacks);
  39325. if (callback || context) {
  39326. this.removeCallback(names, callback, context);
  39327. }
  39328. else {
  39329. this.removeAllCallbacks(names);
  39330. }
  39331. };
  39332. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  39333. apply(names, function (name) {
  39334. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  39335. return (callback && callback !== binding.fn) ||
  39336. (context && context !== binding.context);
  39337. });
  39338. if (this._callbacks[name].length === 0) {
  39339. delete this._callbacks[name];
  39340. }
  39341. }, this);
  39342. };
  39343. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  39344. apply(names, function (name) {
  39345. delete this._callbacks[name];
  39346. }, this);
  39347. };
  39348. return CallbackRegistry;
  39349. }());
  39350. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  39351. function prefix(name) {
  39352. return "_" + name;
  39353. }
  39354. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  39355. var dispatcher_Dispatcher = (function () {
  39356. function Dispatcher(failThrough) {
  39357. this.callbacks = new callback_registry();
  39358. this.global_callbacks = [];
  39359. this.failThrough = failThrough;
  39360. }
  39361. Dispatcher.prototype.bind = function (eventName, callback, context) {
  39362. this.callbacks.add(eventName, callback, context);
  39363. return this;
  39364. };
  39365. Dispatcher.prototype.bind_global = function (callback) {
  39366. this.global_callbacks.push(callback);
  39367. return this;
  39368. };
  39369. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  39370. this.callbacks.remove(eventName, callback, context);
  39371. return this;
  39372. };
  39373. Dispatcher.prototype.unbind_global = function (callback) {
  39374. if (!callback) {
  39375. this.global_callbacks = [];
  39376. return this;
  39377. }
  39378. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  39379. return this;
  39380. };
  39381. Dispatcher.prototype.unbind_all = function () {
  39382. this.unbind();
  39383. this.unbind_global();
  39384. return this;
  39385. };
  39386. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  39387. for (var i = 0; i < this.global_callbacks.length; i++) {
  39388. this.global_callbacks[i](eventName, data);
  39389. }
  39390. var callbacks = this.callbacks.get(eventName);
  39391. var args = [];
  39392. if (metadata) {
  39393. args.push(data, metadata);
  39394. }
  39395. else if (data) {
  39396. args.push(data);
  39397. }
  39398. if (callbacks && callbacks.length > 0) {
  39399. for (var i = 0; i < callbacks.length; i++) {
  39400. callbacks[i].fn.apply(callbacks[i].context || window, args);
  39401. }
  39402. }
  39403. else if (this.failThrough) {
  39404. this.failThrough(eventName, data);
  39405. }
  39406. return this;
  39407. };
  39408. return Dispatcher;
  39409. }());
  39410. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  39411. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  39412. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  39413. var extendStatics = function (d, b) {
  39414. extendStatics = Object.setPrototypeOf ||
  39415. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39416. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39417. return extendStatics(d, b);
  39418. };
  39419. return function (d, b) {
  39420. extendStatics(d, b);
  39421. function __() { this.constructor = d; }
  39422. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39423. };
  39424. })();
  39425. var transport_connection_TransportConnection = (function (_super) {
  39426. transport_connection_extends(TransportConnection, _super);
  39427. function TransportConnection(hooks, name, priority, key, options) {
  39428. var _this = _super.call(this) || this;
  39429. _this.initialize = runtime.transportConnectionInitializer;
  39430. _this.hooks = hooks;
  39431. _this.name = name;
  39432. _this.priority = priority;
  39433. _this.key = key;
  39434. _this.options = options;
  39435. _this.state = "new";
  39436. _this.timeline = options.timeline;
  39437. _this.activityTimeout = options.activityTimeout;
  39438. _this.id = _this.timeline.generateUniqueID();
  39439. return _this;
  39440. }
  39441. TransportConnection.prototype.handlesActivityChecks = function () {
  39442. return Boolean(this.hooks.handlesActivityChecks);
  39443. };
  39444. TransportConnection.prototype.supportsPing = function () {
  39445. return Boolean(this.hooks.supportsPing);
  39446. };
  39447. TransportConnection.prototype.connect = function () {
  39448. var _this = this;
  39449. if (this.socket || this.state !== "initialized") {
  39450. return false;
  39451. }
  39452. var url = this.hooks.urls.getInitial(this.key, this.options);
  39453. try {
  39454. this.socket = this.hooks.getSocket(url, this.options);
  39455. }
  39456. catch (e) {
  39457. util.defer(function () {
  39458. _this.onError(e);
  39459. _this.changeState("closed");
  39460. });
  39461. return false;
  39462. }
  39463. this.bindListeners();
  39464. logger.debug("Connecting", { transport: this.name, url: url });
  39465. this.changeState("connecting");
  39466. return true;
  39467. };
  39468. TransportConnection.prototype.close = function () {
  39469. if (this.socket) {
  39470. this.socket.close();
  39471. return true;
  39472. }
  39473. else {
  39474. return false;
  39475. }
  39476. };
  39477. TransportConnection.prototype.send = function (data) {
  39478. var _this = this;
  39479. if (this.state === "open") {
  39480. util.defer(function () {
  39481. if (_this.socket) {
  39482. _this.socket.send(data);
  39483. }
  39484. });
  39485. return true;
  39486. }
  39487. else {
  39488. return false;
  39489. }
  39490. };
  39491. TransportConnection.prototype.ping = function () {
  39492. if (this.state === "open" && this.supportsPing()) {
  39493. this.socket.ping();
  39494. }
  39495. };
  39496. TransportConnection.prototype.onOpen = function () {
  39497. if (this.hooks.beforeOpen) {
  39498. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  39499. }
  39500. this.changeState("open");
  39501. this.socket.onopen = undefined;
  39502. };
  39503. TransportConnection.prototype.onError = function (error) {
  39504. this.emit("error", { type: 'WebSocketError', error: error });
  39505. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  39506. };
  39507. TransportConnection.prototype.onClose = function (closeEvent) {
  39508. if (closeEvent) {
  39509. this.changeState("closed", {
  39510. code: closeEvent.code,
  39511. reason: closeEvent.reason,
  39512. wasClean: closeEvent.wasClean
  39513. });
  39514. }
  39515. else {
  39516. this.changeState("closed");
  39517. }
  39518. this.unbindListeners();
  39519. this.socket = undefined;
  39520. };
  39521. TransportConnection.prototype.onMessage = function (message) {
  39522. this.emit("message", message);
  39523. };
  39524. TransportConnection.prototype.onActivity = function () {
  39525. this.emit("activity");
  39526. };
  39527. TransportConnection.prototype.bindListeners = function () {
  39528. var _this = this;
  39529. this.socket.onopen = function () {
  39530. _this.onOpen();
  39531. };
  39532. this.socket.onerror = function (error) {
  39533. _this.onError(error);
  39534. };
  39535. this.socket.onclose = function (closeEvent) {
  39536. _this.onClose(closeEvent);
  39537. };
  39538. this.socket.onmessage = function (message) {
  39539. _this.onMessage(message);
  39540. };
  39541. if (this.supportsPing()) {
  39542. this.socket.onactivity = function () { _this.onActivity(); };
  39543. }
  39544. };
  39545. TransportConnection.prototype.unbindListeners = function () {
  39546. if (this.socket) {
  39547. this.socket.onopen = undefined;
  39548. this.socket.onerror = undefined;
  39549. this.socket.onclose = undefined;
  39550. this.socket.onmessage = undefined;
  39551. if (this.supportsPing()) {
  39552. this.socket.onactivity = undefined;
  39553. }
  39554. }
  39555. };
  39556. TransportConnection.prototype.changeState = function (state, params) {
  39557. this.state = state;
  39558. this.timeline.info(this.buildTimelineMessage({
  39559. state: state,
  39560. params: params
  39561. }));
  39562. this.emit(state, params);
  39563. };
  39564. TransportConnection.prototype.buildTimelineMessage = function (message) {
  39565. return extend({ cid: this.id }, message);
  39566. };
  39567. return TransportConnection;
  39568. }(dispatcher));
  39569. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  39570. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  39571. var transport_Transport = (function () {
  39572. function Transport(hooks) {
  39573. this.hooks = hooks;
  39574. }
  39575. Transport.prototype.isSupported = function (environment) {
  39576. return this.hooks.isSupported(environment);
  39577. };
  39578. Transport.prototype.createConnection = function (name, priority, key, options) {
  39579. return new transport_connection(this.hooks, name, priority, key, options);
  39580. };
  39581. return Transport;
  39582. }());
  39583. /* harmony default export */ var transports_transport = (transport_Transport);
  39584. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  39585. var WSTransport = new transports_transport({
  39586. urls: ws,
  39587. handlesActivityChecks: false,
  39588. supportsPing: false,
  39589. isInitialized: function () {
  39590. return Boolean(runtime.getWebSocketAPI());
  39591. },
  39592. isSupported: function () {
  39593. return Boolean(runtime.getWebSocketAPI());
  39594. },
  39595. getSocket: function (url) {
  39596. return runtime.createWebSocket(url);
  39597. }
  39598. });
  39599. var httpConfiguration = {
  39600. urls: http,
  39601. handlesActivityChecks: false,
  39602. supportsPing: true,
  39603. isInitialized: function () {
  39604. return true;
  39605. }
  39606. };
  39607. var streamingConfiguration = extend({ getSocket: function (url) {
  39608. return runtime.HTTPFactory.createStreamingSocket(url);
  39609. }
  39610. }, httpConfiguration);
  39611. var pollingConfiguration = extend({ getSocket: function (url) {
  39612. return runtime.HTTPFactory.createPollingSocket(url);
  39613. }
  39614. }, httpConfiguration);
  39615. var xhrConfiguration = {
  39616. isSupported: function () {
  39617. return runtime.isXHRSupported();
  39618. }
  39619. };
  39620. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  39621. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  39622. var Transports = {
  39623. ws: WSTransport,
  39624. xhr_streaming: XHRStreamingTransport,
  39625. xhr_polling: XHRPollingTransport
  39626. };
  39627. /* harmony default export */ var transports = (Transports);
  39628. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  39629. var SockJSTransport = new transports_transport({
  39630. file: "sockjs",
  39631. urls: sockjs,
  39632. handlesActivityChecks: true,
  39633. supportsPing: false,
  39634. isSupported: function () {
  39635. return true;
  39636. },
  39637. isInitialized: function () {
  39638. return window.SockJS !== undefined;
  39639. },
  39640. getSocket: function (url, options) {
  39641. return new window.SockJS(url, null, {
  39642. js_path: Dependencies.getPath("sockjs", {
  39643. useTLS: options.useTLS
  39644. }),
  39645. ignore_null_origin: options.ignoreNullOrigin
  39646. });
  39647. },
  39648. beforeOpen: function (socket, path) {
  39649. socket.send(JSON.stringify({
  39650. path: path
  39651. }));
  39652. }
  39653. });
  39654. var xdrConfiguration = {
  39655. isSupported: function (environment) {
  39656. var yes = runtime.isXDRSupported(environment.useTLS);
  39657. return yes;
  39658. }
  39659. };
  39660. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  39661. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  39662. transports.xdr_streaming = XDRStreamingTransport;
  39663. transports.xdr_polling = XDRPollingTransport;
  39664. transports.sockjs = SockJSTransport;
  39665. /* harmony default export */ var transports_transports = (transports);
  39666. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  39667. var net_info_extends = (undefined && undefined.__extends) || (function () {
  39668. var extendStatics = function (d, b) {
  39669. extendStatics = Object.setPrototypeOf ||
  39670. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39671. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39672. return extendStatics(d, b);
  39673. };
  39674. return function (d, b) {
  39675. extendStatics(d, b);
  39676. function __() { this.constructor = d; }
  39677. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39678. };
  39679. })();
  39680. var NetInfo = (function (_super) {
  39681. net_info_extends(NetInfo, _super);
  39682. function NetInfo() {
  39683. var _this = _super.call(this) || this;
  39684. var self = _this;
  39685. if (window.addEventListener !== undefined) {
  39686. window.addEventListener("online", function () {
  39687. self.emit('online');
  39688. }, false);
  39689. window.addEventListener("offline", function () {
  39690. self.emit('offline');
  39691. }, false);
  39692. }
  39693. return _this;
  39694. }
  39695. NetInfo.prototype.isOnline = function () {
  39696. if (window.navigator.onLine === undefined) {
  39697. return true;
  39698. }
  39699. else {
  39700. return window.navigator.onLine;
  39701. }
  39702. };
  39703. return NetInfo;
  39704. }(dispatcher));
  39705. var net_info_Network = new NetInfo();
  39706. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  39707. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  39708. function AssistantToTheTransportManager(manager, transport, options) {
  39709. this.manager = manager;
  39710. this.transport = transport;
  39711. this.minPingDelay = options.minPingDelay;
  39712. this.maxPingDelay = options.maxPingDelay;
  39713. this.pingDelay = undefined;
  39714. }
  39715. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  39716. var _this = this;
  39717. options = extend({}, options, {
  39718. activityTimeout: this.pingDelay
  39719. });
  39720. var connection = this.transport.createConnection(name, priority, key, options);
  39721. var openTimestamp = null;
  39722. var onOpen = function () {
  39723. connection.unbind("open", onOpen);
  39724. connection.bind("closed", onClosed);
  39725. openTimestamp = util.now();
  39726. };
  39727. var onClosed = function (closeEvent) {
  39728. connection.unbind("closed", onClosed);
  39729. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  39730. _this.manager.reportDeath();
  39731. }
  39732. else if (!closeEvent.wasClean && openTimestamp) {
  39733. var lifespan = util.now() - openTimestamp;
  39734. if (lifespan < 2 * _this.maxPingDelay) {
  39735. _this.manager.reportDeath();
  39736. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  39737. }
  39738. }
  39739. };
  39740. connection.bind("open", onOpen);
  39741. return connection;
  39742. };
  39743. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  39744. return this.manager.isAlive() && this.transport.isSupported(environment);
  39745. };
  39746. return AssistantToTheTransportManager;
  39747. }());
  39748. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  39749. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  39750. var Protocol = {
  39751. decodeMessage: function (messageEvent) {
  39752. try {
  39753. var messageData = JSON.parse(messageEvent.data);
  39754. var pusherEventData = messageData.data;
  39755. if (typeof pusherEventData === 'string') {
  39756. try {
  39757. pusherEventData = JSON.parse(messageData.data);
  39758. }
  39759. catch (e) { }
  39760. }
  39761. var pusherEvent = {
  39762. event: messageData.event,
  39763. channel: messageData.channel,
  39764. data: pusherEventData,
  39765. };
  39766. if (messageData.user_id) {
  39767. pusherEvent.user_id = messageData.user_id;
  39768. }
  39769. return pusherEvent;
  39770. }
  39771. catch (e) {
  39772. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  39773. }
  39774. },
  39775. encodeMessage: function (event) {
  39776. return JSON.stringify(event);
  39777. },
  39778. processHandshake: function (messageEvent) {
  39779. var message = Protocol.decodeMessage(messageEvent);
  39780. if (message.event === "pusher:connection_established") {
  39781. if (!message.data.activity_timeout) {
  39782. throw "No activity timeout specified in handshake";
  39783. }
  39784. return {
  39785. action: "connected",
  39786. id: message.data.socket_id,
  39787. activityTimeout: message.data.activity_timeout * 1000
  39788. };
  39789. }
  39790. else if (message.event === "pusher:error") {
  39791. return {
  39792. action: this.getCloseAction(message.data),
  39793. error: this.getCloseError(message.data)
  39794. };
  39795. }
  39796. else {
  39797. throw "Invalid handshake";
  39798. }
  39799. },
  39800. getCloseAction: function (closeEvent) {
  39801. if (closeEvent.code < 4000) {
  39802. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  39803. return "backoff";
  39804. }
  39805. else {
  39806. return null;
  39807. }
  39808. }
  39809. else if (closeEvent.code === 4000) {
  39810. return "tls_only";
  39811. }
  39812. else if (closeEvent.code < 4100) {
  39813. return "refused";
  39814. }
  39815. else if (closeEvent.code < 4200) {
  39816. return "backoff";
  39817. }
  39818. else if (closeEvent.code < 4300) {
  39819. return "retry";
  39820. }
  39821. else {
  39822. return "refused";
  39823. }
  39824. },
  39825. getCloseError: function (closeEvent) {
  39826. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  39827. return {
  39828. type: 'PusherError',
  39829. data: {
  39830. code: closeEvent.code,
  39831. message: closeEvent.reason || closeEvent.message
  39832. }
  39833. };
  39834. }
  39835. else {
  39836. return null;
  39837. }
  39838. }
  39839. };
  39840. /* harmony default export */ var protocol_protocol = (Protocol);
  39841. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  39842. var connection_extends = (undefined && undefined.__extends) || (function () {
  39843. var extendStatics = function (d, b) {
  39844. extendStatics = Object.setPrototypeOf ||
  39845. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39846. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39847. return extendStatics(d, b);
  39848. };
  39849. return function (d, b) {
  39850. extendStatics(d, b);
  39851. function __() { this.constructor = d; }
  39852. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39853. };
  39854. })();
  39855. var connection_Connection = (function (_super) {
  39856. connection_extends(Connection, _super);
  39857. function Connection(id, transport) {
  39858. var _this = _super.call(this) || this;
  39859. _this.id = id;
  39860. _this.transport = transport;
  39861. _this.activityTimeout = transport.activityTimeout;
  39862. _this.bindListeners();
  39863. return _this;
  39864. }
  39865. Connection.prototype.handlesActivityChecks = function () {
  39866. return this.transport.handlesActivityChecks();
  39867. };
  39868. Connection.prototype.send = function (data) {
  39869. return this.transport.send(data);
  39870. };
  39871. Connection.prototype.send_event = function (name, data, channel) {
  39872. var event = { event: name, data: data };
  39873. if (channel) {
  39874. event.channel = channel;
  39875. }
  39876. logger.debug('Event sent', event);
  39877. return this.send(protocol_protocol.encodeMessage(event));
  39878. };
  39879. Connection.prototype.ping = function () {
  39880. if (this.transport.supportsPing()) {
  39881. this.transport.ping();
  39882. }
  39883. else {
  39884. this.send_event('pusher:ping', {});
  39885. }
  39886. };
  39887. Connection.prototype.close = function () {
  39888. this.transport.close();
  39889. };
  39890. Connection.prototype.bindListeners = function () {
  39891. var _this = this;
  39892. var listeners = {
  39893. message: function (messageEvent) {
  39894. var pusherEvent;
  39895. try {
  39896. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  39897. }
  39898. catch (e) {
  39899. _this.emit('error', {
  39900. type: 'MessageParseError',
  39901. error: e,
  39902. data: messageEvent.data
  39903. });
  39904. }
  39905. if (pusherEvent !== undefined) {
  39906. logger.debug('Event recd', pusherEvent);
  39907. switch (pusherEvent.event) {
  39908. case 'pusher:error':
  39909. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  39910. break;
  39911. case 'pusher:ping':
  39912. _this.emit("ping");
  39913. break;
  39914. case 'pusher:pong':
  39915. _this.emit("pong");
  39916. break;
  39917. }
  39918. _this.emit('message', pusherEvent);
  39919. }
  39920. },
  39921. activity: function () {
  39922. _this.emit("activity");
  39923. },
  39924. error: function (error) {
  39925. _this.emit("error", { type: "WebSocketError", error: error });
  39926. },
  39927. closed: function (closeEvent) {
  39928. unbindListeners();
  39929. if (closeEvent && closeEvent.code) {
  39930. _this.handleCloseEvent(closeEvent);
  39931. }
  39932. _this.transport = null;
  39933. _this.emit("closed");
  39934. }
  39935. };
  39936. var unbindListeners = function () {
  39937. objectApply(listeners, function (listener, event) {
  39938. _this.transport.unbind(event, listener);
  39939. });
  39940. };
  39941. objectApply(listeners, function (listener, event) {
  39942. _this.transport.bind(event, listener);
  39943. });
  39944. };
  39945. Connection.prototype.handleCloseEvent = function (closeEvent) {
  39946. var action = protocol_protocol.getCloseAction(closeEvent);
  39947. var error = protocol_protocol.getCloseError(closeEvent);
  39948. if (error) {
  39949. this.emit('error', error);
  39950. }
  39951. if (action) {
  39952. this.emit(action, { action: action, error: error });
  39953. }
  39954. };
  39955. return Connection;
  39956. }(dispatcher));
  39957. /* harmony default export */ var connection_connection = (connection_Connection);
  39958. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  39959. var handshake_Handshake = (function () {
  39960. function Handshake(transport, callback) {
  39961. this.transport = transport;
  39962. this.callback = callback;
  39963. this.bindListeners();
  39964. }
  39965. Handshake.prototype.close = function () {
  39966. this.unbindListeners();
  39967. this.transport.close();
  39968. };
  39969. Handshake.prototype.bindListeners = function () {
  39970. var _this = this;
  39971. this.onMessage = function (m) {
  39972. _this.unbindListeners();
  39973. var result;
  39974. try {
  39975. result = protocol_protocol.processHandshake(m);
  39976. }
  39977. catch (e) {
  39978. _this.finish("error", { error: e });
  39979. _this.transport.close();
  39980. return;
  39981. }
  39982. if (result.action === "connected") {
  39983. _this.finish("connected", {
  39984. connection: new connection_connection(result.id, _this.transport),
  39985. activityTimeout: result.activityTimeout
  39986. });
  39987. }
  39988. else {
  39989. _this.finish(result.action, { error: result.error });
  39990. _this.transport.close();
  39991. }
  39992. };
  39993. this.onClosed = function (closeEvent) {
  39994. _this.unbindListeners();
  39995. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  39996. var error = protocol_protocol.getCloseError(closeEvent);
  39997. _this.finish(action, { error: error });
  39998. };
  39999. this.transport.bind("message", this.onMessage);
  40000. this.transport.bind("closed", this.onClosed);
  40001. };
  40002. Handshake.prototype.unbindListeners = function () {
  40003. this.transport.unbind("message", this.onMessage);
  40004. this.transport.unbind("closed", this.onClosed);
  40005. };
  40006. Handshake.prototype.finish = function (action, params) {
  40007. this.callback(extend({ transport: this.transport, action: action }, params));
  40008. };
  40009. return Handshake;
  40010. }());
  40011. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  40012. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  40013. var pusher_authorizer_PusherAuthorizer = (function () {
  40014. function PusherAuthorizer(channel, options) {
  40015. this.channel = channel;
  40016. var authTransport = options.authTransport;
  40017. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  40018. throw "'" + authTransport + "' is not a recognized auth transport";
  40019. }
  40020. this.type = authTransport;
  40021. this.options = options;
  40022. this.authOptions = (options || {}).auth || {};
  40023. }
  40024. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  40025. var query = 'socket_id=' + encodeURIComponent(socketId) +
  40026. '&channel_name=' + encodeURIComponent(this.channel.name);
  40027. for (var i in this.authOptions.params) {
  40028. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  40029. }
  40030. return query;
  40031. };
  40032. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  40033. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  40034. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  40035. };
  40036. return PusherAuthorizer;
  40037. }());
  40038. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  40039. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  40040. var timeline_sender_TimelineSender = (function () {
  40041. function TimelineSender(timeline, options) {
  40042. this.timeline = timeline;
  40043. this.options = options || {};
  40044. }
  40045. TimelineSender.prototype.send = function (useTLS, callback) {
  40046. if (this.timeline.isEmpty()) {
  40047. return;
  40048. }
  40049. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  40050. };
  40051. return TimelineSender;
  40052. }());
  40053. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  40054. // CONCATENATED MODULE: ./src/core/errors.ts
  40055. var errors_extends = (undefined && undefined.__extends) || (function () {
  40056. var extendStatics = function (d, b) {
  40057. extendStatics = Object.setPrototypeOf ||
  40058. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40059. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40060. return extendStatics(d, b);
  40061. };
  40062. return function (d, b) {
  40063. extendStatics(d, b);
  40064. function __() { this.constructor = d; }
  40065. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40066. };
  40067. })();
  40068. var BadEventName = (function (_super) {
  40069. errors_extends(BadEventName, _super);
  40070. function BadEventName(msg) {
  40071. var _newTarget = this.constructor;
  40072. var _this = _super.call(this, msg) || this;
  40073. Object.setPrototypeOf(_this, _newTarget.prototype);
  40074. return _this;
  40075. }
  40076. return BadEventName;
  40077. }(Error));
  40078. var RequestTimedOut = (function (_super) {
  40079. errors_extends(RequestTimedOut, _super);
  40080. function RequestTimedOut(msg) {
  40081. var _newTarget = this.constructor;
  40082. var _this = _super.call(this, msg) || this;
  40083. Object.setPrototypeOf(_this, _newTarget.prototype);
  40084. return _this;
  40085. }
  40086. return RequestTimedOut;
  40087. }(Error));
  40088. var TransportPriorityTooLow = (function (_super) {
  40089. errors_extends(TransportPriorityTooLow, _super);
  40090. function TransportPriorityTooLow(msg) {
  40091. var _newTarget = this.constructor;
  40092. var _this = _super.call(this, msg) || this;
  40093. Object.setPrototypeOf(_this, _newTarget.prototype);
  40094. return _this;
  40095. }
  40096. return TransportPriorityTooLow;
  40097. }(Error));
  40098. var TransportClosed = (function (_super) {
  40099. errors_extends(TransportClosed, _super);
  40100. function TransportClosed(msg) {
  40101. var _newTarget = this.constructor;
  40102. var _this = _super.call(this, msg) || this;
  40103. Object.setPrototypeOf(_this, _newTarget.prototype);
  40104. return _this;
  40105. }
  40106. return TransportClosed;
  40107. }(Error));
  40108. var UnsupportedFeature = (function (_super) {
  40109. errors_extends(UnsupportedFeature, _super);
  40110. function UnsupportedFeature(msg) {
  40111. var _newTarget = this.constructor;
  40112. var _this = _super.call(this, msg) || this;
  40113. Object.setPrototypeOf(_this, _newTarget.prototype);
  40114. return _this;
  40115. }
  40116. return UnsupportedFeature;
  40117. }(Error));
  40118. var UnsupportedTransport = (function (_super) {
  40119. errors_extends(UnsupportedTransport, _super);
  40120. function UnsupportedTransport(msg) {
  40121. var _newTarget = this.constructor;
  40122. var _this = _super.call(this, msg) || this;
  40123. Object.setPrototypeOf(_this, _newTarget.prototype);
  40124. return _this;
  40125. }
  40126. return UnsupportedTransport;
  40127. }(Error));
  40128. var UnsupportedStrategy = (function (_super) {
  40129. errors_extends(UnsupportedStrategy, _super);
  40130. function UnsupportedStrategy(msg) {
  40131. var _newTarget = this.constructor;
  40132. var _this = _super.call(this, msg) || this;
  40133. Object.setPrototypeOf(_this, _newTarget.prototype);
  40134. return _this;
  40135. }
  40136. return UnsupportedStrategy;
  40137. }(Error));
  40138. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  40139. var channel_extends = (undefined && undefined.__extends) || (function () {
  40140. var extendStatics = function (d, b) {
  40141. extendStatics = Object.setPrototypeOf ||
  40142. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40143. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40144. return extendStatics(d, b);
  40145. };
  40146. return function (d, b) {
  40147. extendStatics(d, b);
  40148. function __() { this.constructor = d; }
  40149. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40150. };
  40151. })();
  40152. var channel_Channel = (function (_super) {
  40153. channel_extends(Channel, _super);
  40154. function Channel(name, pusher) {
  40155. var _this = _super.call(this, function (event, data) {
  40156. logger.debug('No callbacks on ' + name + ' for ' + event);
  40157. }) || this;
  40158. _this.name = name;
  40159. _this.pusher = pusher;
  40160. _this.subscribed = false;
  40161. _this.subscriptionPending = false;
  40162. _this.subscriptionCancelled = false;
  40163. return _this;
  40164. }
  40165. Channel.prototype.authorize = function (socketId, callback) {
  40166. return callback(false, {});
  40167. };
  40168. Channel.prototype.trigger = function (event, data) {
  40169. if (event.indexOf("client-") !== 0) {
  40170. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  40171. }
  40172. if (!this.subscribed) {
  40173. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  40174. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  40175. }
  40176. return this.pusher.send_event(event, data, this.name);
  40177. };
  40178. Channel.prototype.disconnect = function () {
  40179. this.subscribed = false;
  40180. this.subscriptionPending = false;
  40181. };
  40182. Channel.prototype.handleEvent = function (event) {
  40183. var eventName = event.event;
  40184. var data = event.data;
  40185. if (eventName === "pusher_internal:subscription_succeeded") {
  40186. this.handleSubscriptionSucceededEvent(event);
  40187. }
  40188. else if (eventName.indexOf("pusher_internal:") !== 0) {
  40189. var metadata = {};
  40190. this.emit(eventName, data, metadata);
  40191. }
  40192. };
  40193. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40194. this.subscriptionPending = false;
  40195. this.subscribed = true;
  40196. if (this.subscriptionCancelled) {
  40197. this.pusher.unsubscribe(this.name);
  40198. }
  40199. else {
  40200. this.emit("pusher:subscription_succeeded", event.data);
  40201. }
  40202. };
  40203. Channel.prototype.subscribe = function () {
  40204. var _this = this;
  40205. if (this.subscribed) {
  40206. return;
  40207. }
  40208. this.subscriptionPending = true;
  40209. this.subscriptionCancelled = false;
  40210. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  40211. if (error) {
  40212. logger.error(data);
  40213. _this.emit('pusher:subscription_error', data);
  40214. }
  40215. else {
  40216. _this.pusher.send_event('pusher:subscribe', {
  40217. auth: data.auth,
  40218. channel_data: data.channel_data,
  40219. channel: _this.name
  40220. });
  40221. }
  40222. });
  40223. };
  40224. Channel.prototype.unsubscribe = function () {
  40225. this.subscribed = false;
  40226. this.pusher.send_event('pusher:unsubscribe', {
  40227. channel: this.name
  40228. });
  40229. };
  40230. Channel.prototype.cancelSubscription = function () {
  40231. this.subscriptionCancelled = true;
  40232. };
  40233. Channel.prototype.reinstateSubscription = function () {
  40234. this.subscriptionCancelled = false;
  40235. };
  40236. return Channel;
  40237. }(dispatcher));
  40238. /* harmony default export */ var channels_channel = (channel_Channel);
  40239. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  40240. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  40241. var extendStatics = function (d, b) {
  40242. extendStatics = Object.setPrototypeOf ||
  40243. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40244. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40245. return extendStatics(d, b);
  40246. };
  40247. return function (d, b) {
  40248. extendStatics(d, b);
  40249. function __() { this.constructor = d; }
  40250. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40251. };
  40252. })();
  40253. var private_channel_PrivateChannel = (function (_super) {
  40254. private_channel_extends(PrivateChannel, _super);
  40255. function PrivateChannel() {
  40256. return _super !== null && _super.apply(this, arguments) || this;
  40257. }
  40258. PrivateChannel.prototype.authorize = function (socketId, callback) {
  40259. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  40260. return authorizer.authorize(socketId, callback);
  40261. };
  40262. return PrivateChannel;
  40263. }(channels_channel));
  40264. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  40265. // CONCATENATED MODULE: ./src/core/channels/members.ts
  40266. var members_Members = (function () {
  40267. function Members() {
  40268. this.reset();
  40269. }
  40270. Members.prototype.get = function (id) {
  40271. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  40272. return {
  40273. id: id,
  40274. info: this.members[id]
  40275. };
  40276. }
  40277. else {
  40278. return null;
  40279. }
  40280. };
  40281. Members.prototype.each = function (callback) {
  40282. var _this = this;
  40283. objectApply(this.members, function (member, id) {
  40284. callback(_this.get(id));
  40285. });
  40286. };
  40287. Members.prototype.setMyID = function (id) {
  40288. this.myID = id;
  40289. };
  40290. Members.prototype.onSubscription = function (subscriptionData) {
  40291. this.members = subscriptionData.presence.hash;
  40292. this.count = subscriptionData.presence.count;
  40293. this.me = this.get(this.myID);
  40294. };
  40295. Members.prototype.addMember = function (memberData) {
  40296. if (this.get(memberData.user_id) === null) {
  40297. this.count++;
  40298. }
  40299. this.members[memberData.user_id] = memberData.user_info;
  40300. return this.get(memberData.user_id);
  40301. };
  40302. Members.prototype.removeMember = function (memberData) {
  40303. var member = this.get(memberData.user_id);
  40304. if (member) {
  40305. delete this.members[memberData.user_id];
  40306. this.count--;
  40307. }
  40308. return member;
  40309. };
  40310. Members.prototype.reset = function () {
  40311. this.members = {};
  40312. this.count = 0;
  40313. this.myID = null;
  40314. this.me = null;
  40315. };
  40316. return Members;
  40317. }());
  40318. /* harmony default export */ var members = (members_Members);
  40319. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  40320. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  40321. var extendStatics = function (d, b) {
  40322. extendStatics = Object.setPrototypeOf ||
  40323. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40324. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40325. return extendStatics(d, b);
  40326. };
  40327. return function (d, b) {
  40328. extendStatics(d, b);
  40329. function __() { this.constructor = d; }
  40330. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40331. };
  40332. })();
  40333. var presence_channel_PresenceChannel = (function (_super) {
  40334. presence_channel_extends(PresenceChannel, _super);
  40335. function PresenceChannel(name, pusher) {
  40336. var _this = _super.call(this, name, pusher) || this;
  40337. _this.members = new members();
  40338. return _this;
  40339. }
  40340. PresenceChannel.prototype.authorize = function (socketId, callback) {
  40341. var _this = this;
  40342. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40343. if (!error) {
  40344. if (authData.channel_data === undefined) {
  40345. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  40346. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  40347. ("expected 'channel_data' field. " + suffix));
  40348. callback("Invalid auth response");
  40349. return;
  40350. }
  40351. var channelData = JSON.parse(authData.channel_data);
  40352. _this.members.setMyID(channelData.user_id);
  40353. }
  40354. callback(error, authData);
  40355. });
  40356. };
  40357. PresenceChannel.prototype.handleEvent = function (event) {
  40358. var eventName = event.event;
  40359. if (eventName.indexOf("pusher_internal:") === 0) {
  40360. this.handleInternalEvent(event);
  40361. }
  40362. else {
  40363. var data = event.data;
  40364. var metadata = {};
  40365. if (event.user_id) {
  40366. metadata.user_id = event.user_id;
  40367. }
  40368. this.emit(eventName, data, metadata);
  40369. }
  40370. };
  40371. PresenceChannel.prototype.handleInternalEvent = function (event) {
  40372. var eventName = event.event;
  40373. var data = event.data;
  40374. switch (eventName) {
  40375. case "pusher_internal:subscription_succeeded":
  40376. this.handleSubscriptionSucceededEvent(event);
  40377. break;
  40378. case "pusher_internal:member_added":
  40379. var addedMember = this.members.addMember(data);
  40380. this.emit('pusher:member_added', addedMember);
  40381. break;
  40382. case "pusher_internal:member_removed":
  40383. var removedMember = this.members.removeMember(data);
  40384. if (removedMember) {
  40385. this.emit('pusher:member_removed', removedMember);
  40386. }
  40387. break;
  40388. }
  40389. };
  40390. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40391. this.subscriptionPending = false;
  40392. this.subscribed = true;
  40393. if (this.subscriptionCancelled) {
  40394. this.pusher.unsubscribe(this.name);
  40395. }
  40396. else {
  40397. this.members.onSubscription(event.data);
  40398. this.emit("pusher:subscription_succeeded", this.members);
  40399. }
  40400. };
  40401. PresenceChannel.prototype.disconnect = function () {
  40402. this.members.reset();
  40403. _super.prototype.disconnect.call(this);
  40404. };
  40405. return PresenceChannel;
  40406. }(private_channel));
  40407. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  40408. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  40409. var nacl_fast = __webpack_require__(0);
  40410. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  40411. var nacl_util = __webpack_require__(1);
  40412. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  40413. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  40414. var extendStatics = function (d, b) {
  40415. extendStatics = Object.setPrototypeOf ||
  40416. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40417. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40418. return extendStatics(d, b);
  40419. };
  40420. return function (d, b) {
  40421. extendStatics(d, b);
  40422. function __() { this.constructor = d; }
  40423. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40424. };
  40425. })();
  40426. var encrypted_channel_EncryptedChannel = (function (_super) {
  40427. encrypted_channel_extends(EncryptedChannel, _super);
  40428. function EncryptedChannel() {
  40429. var _this = _super !== null && _super.apply(this, arguments) || this;
  40430. _this.key = null;
  40431. return _this;
  40432. }
  40433. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  40434. var _this = this;
  40435. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40436. if (error) {
  40437. callback(true, authData);
  40438. return;
  40439. }
  40440. var sharedSecret = authData["shared_secret"];
  40441. if (!sharedSecret) {
  40442. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  40443. callback(true, errorMsg);
  40444. return;
  40445. }
  40446. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  40447. delete authData["shared_secret"];
  40448. callback(false, authData);
  40449. });
  40450. };
  40451. EncryptedChannel.prototype.trigger = function (event, data) {
  40452. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  40453. };
  40454. EncryptedChannel.prototype.handleEvent = function (event) {
  40455. var eventName = event.event;
  40456. var data = event.data;
  40457. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  40458. _super.prototype.handleEvent.call(this, event);
  40459. return;
  40460. }
  40461. this.handleEncryptedEvent(eventName, data);
  40462. };
  40463. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  40464. var _this = this;
  40465. if (!this.key) {
  40466. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  40467. return;
  40468. }
  40469. if (!data.ciphertext || !data.nonce) {
  40470. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  40471. return;
  40472. }
  40473. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  40474. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  40475. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  40476. return;
  40477. }
  40478. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  40479. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  40480. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  40481. return;
  40482. }
  40483. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  40484. if (bytes === null) {
  40485. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  40486. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  40487. if (error) {
  40488. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  40489. return;
  40490. }
  40491. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  40492. if (bytes === null) {
  40493. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  40494. return;
  40495. }
  40496. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40497. return;
  40498. });
  40499. return;
  40500. }
  40501. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40502. };
  40503. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  40504. try {
  40505. this.emit(eventName, JSON.parse(data));
  40506. }
  40507. catch (e) {
  40508. this.emit(eventName, data);
  40509. }
  40510. return this;
  40511. };
  40512. return EncryptedChannel;
  40513. }(private_channel));
  40514. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  40515. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  40516. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  40517. var extendStatics = function (d, b) {
  40518. extendStatics = Object.setPrototypeOf ||
  40519. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40520. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40521. return extendStatics(d, b);
  40522. };
  40523. return function (d, b) {
  40524. extendStatics(d, b);
  40525. function __() { this.constructor = d; }
  40526. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40527. };
  40528. })();
  40529. var connection_manager_ConnectionManager = (function (_super) {
  40530. connection_manager_extends(ConnectionManager, _super);
  40531. function ConnectionManager(key, options) {
  40532. var _this = _super.call(this) || this;
  40533. _this.key = key;
  40534. _this.options = options || {};
  40535. _this.state = "initialized";
  40536. _this.connection = null;
  40537. _this.usingTLS = !!options.useTLS;
  40538. _this.timeline = _this.options.timeline;
  40539. _this.errorCallbacks = _this.buildErrorCallbacks();
  40540. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  40541. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  40542. var Network = runtime.getNetwork();
  40543. Network.bind("online", function () {
  40544. _this.timeline.info({ netinfo: "online" });
  40545. if (_this.state === "connecting" || _this.state === "unavailable") {
  40546. _this.retryIn(0);
  40547. }
  40548. });
  40549. Network.bind("offline", function () {
  40550. _this.timeline.info({ netinfo: "offline" });
  40551. if (_this.connection) {
  40552. _this.sendActivityCheck();
  40553. }
  40554. });
  40555. _this.updateStrategy();
  40556. return _this;
  40557. }
  40558. ConnectionManager.prototype.connect = function () {
  40559. if (this.connection || this.runner) {
  40560. return;
  40561. }
  40562. if (!this.strategy.isSupported()) {
  40563. this.updateState("failed");
  40564. return;
  40565. }
  40566. this.updateState("connecting");
  40567. this.startConnecting();
  40568. this.setUnavailableTimer();
  40569. };
  40570. ;
  40571. ConnectionManager.prototype.send = function (data) {
  40572. if (this.connection) {
  40573. return this.connection.send(data);
  40574. }
  40575. else {
  40576. return false;
  40577. }
  40578. };
  40579. ;
  40580. ConnectionManager.prototype.send_event = function (name, data, channel) {
  40581. if (this.connection) {
  40582. return this.connection.send_event(name, data, channel);
  40583. }
  40584. else {
  40585. return false;
  40586. }
  40587. };
  40588. ;
  40589. ConnectionManager.prototype.disconnect = function () {
  40590. this.disconnectInternally();
  40591. this.updateState("disconnected");
  40592. };
  40593. ;
  40594. ConnectionManager.prototype.isUsingTLS = function () {
  40595. return this.usingTLS;
  40596. };
  40597. ;
  40598. ConnectionManager.prototype.startConnecting = function () {
  40599. var _this = this;
  40600. var callback = function (error, handshake) {
  40601. if (error) {
  40602. _this.runner = _this.strategy.connect(0, callback);
  40603. }
  40604. else {
  40605. if (handshake.action === "error") {
  40606. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  40607. _this.timeline.error({ handshakeError: handshake.error });
  40608. }
  40609. else {
  40610. _this.abortConnecting();
  40611. _this.handshakeCallbacks[handshake.action](handshake);
  40612. }
  40613. }
  40614. };
  40615. this.runner = this.strategy.connect(0, callback);
  40616. };
  40617. ;
  40618. ConnectionManager.prototype.abortConnecting = function () {
  40619. if (this.runner) {
  40620. this.runner.abort();
  40621. this.runner = null;
  40622. }
  40623. };
  40624. ;
  40625. ConnectionManager.prototype.disconnectInternally = function () {
  40626. this.abortConnecting();
  40627. this.clearRetryTimer();
  40628. this.clearUnavailableTimer();
  40629. if (this.connection) {
  40630. var connection = this.abandonConnection();
  40631. connection.close();
  40632. }
  40633. };
  40634. ;
  40635. ConnectionManager.prototype.updateStrategy = function () {
  40636. this.strategy = this.options.getStrategy({
  40637. key: this.key,
  40638. timeline: this.timeline,
  40639. useTLS: this.usingTLS
  40640. });
  40641. };
  40642. ;
  40643. ConnectionManager.prototype.retryIn = function (delay) {
  40644. var _this = this;
  40645. this.timeline.info({ action: "retry", delay: delay });
  40646. if (delay > 0) {
  40647. this.emit("connecting_in", Math.round(delay / 1000));
  40648. }
  40649. this.retryTimer = new OneOffTimer(delay || 0, function () {
  40650. _this.disconnectInternally();
  40651. _this.connect();
  40652. });
  40653. };
  40654. ;
  40655. ConnectionManager.prototype.clearRetryTimer = function () {
  40656. if (this.retryTimer) {
  40657. this.retryTimer.ensureAborted();
  40658. this.retryTimer = null;
  40659. }
  40660. };
  40661. ;
  40662. ConnectionManager.prototype.setUnavailableTimer = function () {
  40663. var _this = this;
  40664. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  40665. _this.updateState("unavailable");
  40666. });
  40667. };
  40668. ;
  40669. ConnectionManager.prototype.clearUnavailableTimer = function () {
  40670. if (this.unavailableTimer) {
  40671. this.unavailableTimer.ensureAborted();
  40672. }
  40673. };
  40674. ;
  40675. ConnectionManager.prototype.sendActivityCheck = function () {
  40676. var _this = this;
  40677. this.stopActivityCheck();
  40678. this.connection.ping();
  40679. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  40680. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  40681. _this.retryIn(0);
  40682. });
  40683. };
  40684. ;
  40685. ConnectionManager.prototype.resetActivityCheck = function () {
  40686. var _this = this;
  40687. this.stopActivityCheck();
  40688. if (this.connection && !this.connection.handlesActivityChecks()) {
  40689. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  40690. _this.sendActivityCheck();
  40691. });
  40692. }
  40693. };
  40694. ;
  40695. ConnectionManager.prototype.stopActivityCheck = function () {
  40696. if (this.activityTimer) {
  40697. this.activityTimer.ensureAborted();
  40698. }
  40699. };
  40700. ;
  40701. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  40702. var _this = this;
  40703. return extend({}, errorCallbacks, {
  40704. message: function (message) {
  40705. _this.resetActivityCheck();
  40706. _this.emit('message', message);
  40707. },
  40708. ping: function () {
  40709. _this.send_event('pusher:pong', {});
  40710. },
  40711. activity: function () {
  40712. _this.resetActivityCheck();
  40713. },
  40714. error: function (error) {
  40715. _this.emit("error", { type: "WebSocketError", error: error });
  40716. },
  40717. closed: function () {
  40718. _this.abandonConnection();
  40719. if (_this.shouldRetry()) {
  40720. _this.retryIn(1000);
  40721. }
  40722. }
  40723. });
  40724. };
  40725. ;
  40726. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  40727. var _this = this;
  40728. return extend({}, errorCallbacks, {
  40729. connected: function (handshake) {
  40730. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  40731. _this.clearUnavailableTimer();
  40732. _this.setConnection(handshake.connection);
  40733. _this.socket_id = _this.connection.id;
  40734. _this.updateState("connected", { socket_id: _this.socket_id });
  40735. }
  40736. });
  40737. };
  40738. ;
  40739. ConnectionManager.prototype.buildErrorCallbacks = function () {
  40740. var _this = this;
  40741. var withErrorEmitted = function (callback) {
  40742. return function (result) {
  40743. if (result.error) {
  40744. _this.emit("error", { type: "WebSocketError", error: result.error });
  40745. }
  40746. callback(result);
  40747. };
  40748. };
  40749. return {
  40750. tls_only: withErrorEmitted(function () {
  40751. _this.usingTLS = true;
  40752. _this.updateStrategy();
  40753. _this.retryIn(0);
  40754. }),
  40755. refused: withErrorEmitted(function () {
  40756. _this.disconnect();
  40757. }),
  40758. backoff: withErrorEmitted(function () {
  40759. _this.retryIn(1000);
  40760. }),
  40761. retry: withErrorEmitted(function () {
  40762. _this.retryIn(0);
  40763. })
  40764. };
  40765. };
  40766. ;
  40767. ConnectionManager.prototype.setConnection = function (connection) {
  40768. this.connection = connection;
  40769. for (var event in this.connectionCallbacks) {
  40770. this.connection.bind(event, this.connectionCallbacks[event]);
  40771. }
  40772. this.resetActivityCheck();
  40773. };
  40774. ;
  40775. ConnectionManager.prototype.abandonConnection = function () {
  40776. if (!this.connection) {
  40777. return;
  40778. }
  40779. this.stopActivityCheck();
  40780. for (var event in this.connectionCallbacks) {
  40781. this.connection.unbind(event, this.connectionCallbacks[event]);
  40782. }
  40783. var connection = this.connection;
  40784. this.connection = null;
  40785. return connection;
  40786. };
  40787. ConnectionManager.prototype.updateState = function (newState, data) {
  40788. var previousState = this.state;
  40789. this.state = newState;
  40790. if (previousState !== newState) {
  40791. var newStateDescription = newState;
  40792. if (newStateDescription === "connected") {
  40793. newStateDescription += " with new socket ID " + data.socket_id;
  40794. }
  40795. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  40796. this.timeline.info({ state: newState, params: data });
  40797. this.emit('state_change', { previous: previousState, current: newState });
  40798. this.emit(newState, data);
  40799. }
  40800. };
  40801. ConnectionManager.prototype.shouldRetry = function () {
  40802. return this.state === "connecting" || this.state === "connected";
  40803. };
  40804. return ConnectionManager;
  40805. }(dispatcher));
  40806. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  40807. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  40808. var channels_Channels = (function () {
  40809. function Channels() {
  40810. this.channels = {};
  40811. }
  40812. Channels.prototype.add = function (name, pusher) {
  40813. if (!this.channels[name]) {
  40814. this.channels[name] = createChannel(name, pusher);
  40815. }
  40816. return this.channels[name];
  40817. };
  40818. Channels.prototype.all = function () {
  40819. return values(this.channels);
  40820. };
  40821. Channels.prototype.find = function (name) {
  40822. return this.channels[name];
  40823. };
  40824. Channels.prototype.remove = function (name) {
  40825. var channel = this.channels[name];
  40826. delete this.channels[name];
  40827. return channel;
  40828. };
  40829. Channels.prototype.disconnect = function () {
  40830. objectApply(this.channels, function (channel) {
  40831. channel.disconnect();
  40832. });
  40833. };
  40834. return Channels;
  40835. }());
  40836. /* harmony default export */ var channels = (channels_Channels);
  40837. function createChannel(name, pusher) {
  40838. if (name.indexOf('private-encrypted-') === 0) {
  40839. if (false) { var errorMsg; }
  40840. return factory.createEncryptedChannel(name, pusher);
  40841. }
  40842. else if (name.indexOf('private-') === 0) {
  40843. return factory.createPrivateChannel(name, pusher);
  40844. }
  40845. else if (name.indexOf('presence-') === 0) {
  40846. return factory.createPresenceChannel(name, pusher);
  40847. }
  40848. else {
  40849. return factory.createChannel(name, pusher);
  40850. }
  40851. }
  40852. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  40853. var Factory = {
  40854. createChannels: function () {
  40855. return new channels();
  40856. },
  40857. createConnectionManager: function (key, options) {
  40858. return new connection_manager(key, options);
  40859. },
  40860. createChannel: function (name, pusher) {
  40861. return new channels_channel(name, pusher);
  40862. },
  40863. createPrivateChannel: function (name, pusher) {
  40864. return new private_channel(name, pusher);
  40865. },
  40866. createPresenceChannel: function (name, pusher) {
  40867. return new presence_channel(name, pusher);
  40868. },
  40869. createEncryptedChannel: function (name, pusher) {
  40870. return new encrypted_channel(name, pusher);
  40871. },
  40872. createTimelineSender: function (timeline, options) {
  40873. return new timeline_sender(timeline, options);
  40874. },
  40875. createAuthorizer: function (channel, options) {
  40876. if (options.authorizer) {
  40877. return options.authorizer(channel, options);
  40878. }
  40879. return new pusher_authorizer(channel, options);
  40880. },
  40881. createHandshake: function (transport, callback) {
  40882. return new connection_handshake(transport, callback);
  40883. },
  40884. createAssistantToTheTransportManager: function (manager, transport, options) {
  40885. return new assistant_to_the_transport_manager(manager, transport, options);
  40886. }
  40887. };
  40888. /* harmony default export */ var factory = (Factory);
  40889. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  40890. var transport_manager_TransportManager = (function () {
  40891. function TransportManager(options) {
  40892. this.options = options || {};
  40893. this.livesLeft = this.options.lives || Infinity;
  40894. }
  40895. TransportManager.prototype.getAssistant = function (transport) {
  40896. return factory.createAssistantToTheTransportManager(this, transport, {
  40897. minPingDelay: this.options.minPingDelay,
  40898. maxPingDelay: this.options.maxPingDelay
  40899. });
  40900. };
  40901. TransportManager.prototype.isAlive = function () {
  40902. return this.livesLeft > 0;
  40903. };
  40904. TransportManager.prototype.reportDeath = function () {
  40905. this.livesLeft -= 1;
  40906. };
  40907. return TransportManager;
  40908. }());
  40909. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  40910. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  40911. var sequential_strategy_SequentialStrategy = (function () {
  40912. function SequentialStrategy(strategies, options) {
  40913. this.strategies = strategies;
  40914. this.loop = Boolean(options.loop);
  40915. this.failFast = Boolean(options.failFast);
  40916. this.timeout = options.timeout;
  40917. this.timeoutLimit = options.timeoutLimit;
  40918. }
  40919. SequentialStrategy.prototype.isSupported = function () {
  40920. return any(this.strategies, util.method("isSupported"));
  40921. };
  40922. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  40923. var _this = this;
  40924. var strategies = this.strategies;
  40925. var current = 0;
  40926. var timeout = this.timeout;
  40927. var runner = null;
  40928. var tryNextStrategy = function (error, handshake) {
  40929. if (handshake) {
  40930. callback(null, handshake);
  40931. }
  40932. else {
  40933. current = current + 1;
  40934. if (_this.loop) {
  40935. current = current % strategies.length;
  40936. }
  40937. if (current < strategies.length) {
  40938. if (timeout) {
  40939. timeout = timeout * 2;
  40940. if (_this.timeoutLimit) {
  40941. timeout = Math.min(timeout, _this.timeoutLimit);
  40942. }
  40943. }
  40944. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  40945. }
  40946. else {
  40947. callback(true);
  40948. }
  40949. }
  40950. };
  40951. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  40952. return {
  40953. abort: function () {
  40954. runner.abort();
  40955. },
  40956. forceMinPriority: function (p) {
  40957. minPriority = p;
  40958. if (runner) {
  40959. runner.forceMinPriority(p);
  40960. }
  40961. }
  40962. };
  40963. };
  40964. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  40965. var timer = null;
  40966. var runner = null;
  40967. if (options.timeout > 0) {
  40968. timer = new OneOffTimer(options.timeout, function () {
  40969. runner.abort();
  40970. callback(true);
  40971. });
  40972. }
  40973. runner = strategy.connect(minPriority, function (error, handshake) {
  40974. if (error && timer && timer.isRunning() && !options.failFast) {
  40975. return;
  40976. }
  40977. if (timer) {
  40978. timer.ensureAborted();
  40979. }
  40980. callback(error, handshake);
  40981. });
  40982. return {
  40983. abort: function () {
  40984. if (timer) {
  40985. timer.ensureAborted();
  40986. }
  40987. runner.abort();
  40988. },
  40989. forceMinPriority: function (p) {
  40990. runner.forceMinPriority(p);
  40991. }
  40992. };
  40993. };
  40994. return SequentialStrategy;
  40995. }());
  40996. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  40997. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  40998. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  40999. function BestConnectedEverStrategy(strategies) {
  41000. this.strategies = strategies;
  41001. }
  41002. BestConnectedEverStrategy.prototype.isSupported = function () {
  41003. return any(this.strategies, util.method("isSupported"));
  41004. };
  41005. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  41006. return connect(this.strategies, minPriority, function (i, runners) {
  41007. return function (error, handshake) {
  41008. runners[i].error = error;
  41009. if (error) {
  41010. if (allRunnersFailed(runners)) {
  41011. callback(true);
  41012. }
  41013. return;
  41014. }
  41015. apply(runners, function (runner) {
  41016. runner.forceMinPriority(handshake.transport.priority);
  41017. });
  41018. callback(null, handshake);
  41019. };
  41020. });
  41021. };
  41022. return BestConnectedEverStrategy;
  41023. }());
  41024. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  41025. function connect(strategies, minPriority, callbackBuilder) {
  41026. var runners = map(strategies, function (strategy, i, _, rs) {
  41027. return strategy.connect(minPriority, callbackBuilder(i, rs));
  41028. });
  41029. return {
  41030. abort: function () {
  41031. apply(runners, abortRunner);
  41032. },
  41033. forceMinPriority: function (p) {
  41034. apply(runners, function (runner) {
  41035. runner.forceMinPriority(p);
  41036. });
  41037. }
  41038. };
  41039. }
  41040. function allRunnersFailed(runners) {
  41041. return collections_all(runners, function (runner) {
  41042. return Boolean(runner.error);
  41043. });
  41044. }
  41045. function abortRunner(runner) {
  41046. if (!runner.error && !runner.aborted) {
  41047. runner.abort();
  41048. runner.aborted = true;
  41049. }
  41050. }
  41051. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  41052. var cached_strategy_CachedStrategy = (function () {
  41053. function CachedStrategy(strategy, transports, options) {
  41054. this.strategy = strategy;
  41055. this.transports = transports;
  41056. this.ttl = options.ttl || 1800 * 1000;
  41057. this.usingTLS = options.useTLS;
  41058. this.timeline = options.timeline;
  41059. }
  41060. CachedStrategy.prototype.isSupported = function () {
  41061. return this.strategy.isSupported();
  41062. };
  41063. CachedStrategy.prototype.connect = function (minPriority, callback) {
  41064. var usingTLS = this.usingTLS;
  41065. var info = fetchTransportCache(usingTLS);
  41066. var strategies = [this.strategy];
  41067. if (info && info.timestamp + this.ttl >= util.now()) {
  41068. var transport = this.transports[info.transport];
  41069. if (transport) {
  41070. this.timeline.info({
  41071. cached: true,
  41072. transport: info.transport,
  41073. latency: info.latency
  41074. });
  41075. strategies.push(new sequential_strategy([transport], {
  41076. timeout: info.latency * 2 + 1000,
  41077. failFast: true
  41078. }));
  41079. }
  41080. }
  41081. var startTimestamp = util.now();
  41082. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  41083. if (error) {
  41084. flushTransportCache(usingTLS);
  41085. if (strategies.length > 0) {
  41086. startTimestamp = util.now();
  41087. runner = strategies.pop().connect(minPriority, cb);
  41088. }
  41089. else {
  41090. callback(error);
  41091. }
  41092. }
  41093. else {
  41094. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  41095. callback(null, handshake);
  41096. }
  41097. });
  41098. return {
  41099. abort: function () {
  41100. runner.abort();
  41101. },
  41102. forceMinPriority: function (p) {
  41103. minPriority = p;
  41104. if (runner) {
  41105. runner.forceMinPriority(p);
  41106. }
  41107. }
  41108. };
  41109. };
  41110. return CachedStrategy;
  41111. }());
  41112. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  41113. function getTransportCacheKey(usingTLS) {
  41114. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  41115. }
  41116. function fetchTransportCache(usingTLS) {
  41117. var storage = runtime.getLocalStorage();
  41118. if (storage) {
  41119. try {
  41120. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  41121. if (serializedCache) {
  41122. return JSON.parse(serializedCache);
  41123. }
  41124. }
  41125. catch (e) {
  41126. flushTransportCache(usingTLS);
  41127. }
  41128. }
  41129. return null;
  41130. }
  41131. function storeTransportCache(usingTLS, transport, latency) {
  41132. var storage = runtime.getLocalStorage();
  41133. if (storage) {
  41134. try {
  41135. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  41136. timestamp: util.now(),
  41137. transport: transport,
  41138. latency: latency
  41139. });
  41140. }
  41141. catch (e) {
  41142. }
  41143. }
  41144. }
  41145. function flushTransportCache(usingTLS) {
  41146. var storage = runtime.getLocalStorage();
  41147. if (storage) {
  41148. try {
  41149. delete storage[getTransportCacheKey(usingTLS)];
  41150. }
  41151. catch (e) {
  41152. }
  41153. }
  41154. }
  41155. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  41156. var delayed_strategy_DelayedStrategy = (function () {
  41157. function DelayedStrategy(strategy, _a) {
  41158. var number = _a.delay;
  41159. this.strategy = strategy;
  41160. this.options = { delay: number };
  41161. }
  41162. DelayedStrategy.prototype.isSupported = function () {
  41163. return this.strategy.isSupported();
  41164. };
  41165. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  41166. var strategy = this.strategy;
  41167. var runner;
  41168. var timer = new OneOffTimer(this.options.delay, function () {
  41169. runner = strategy.connect(minPriority, callback);
  41170. });
  41171. return {
  41172. abort: function () {
  41173. timer.ensureAborted();
  41174. if (runner) {
  41175. runner.abort();
  41176. }
  41177. },
  41178. forceMinPriority: function (p) {
  41179. minPriority = p;
  41180. if (runner) {
  41181. runner.forceMinPriority(p);
  41182. }
  41183. }
  41184. };
  41185. };
  41186. return DelayedStrategy;
  41187. }());
  41188. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  41189. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  41190. var IfStrategy = (function () {
  41191. function IfStrategy(test, trueBranch, falseBranch) {
  41192. this.test = test;
  41193. this.trueBranch = trueBranch;
  41194. this.falseBranch = falseBranch;
  41195. }
  41196. IfStrategy.prototype.isSupported = function () {
  41197. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41198. return branch.isSupported();
  41199. };
  41200. IfStrategy.prototype.connect = function (minPriority, callback) {
  41201. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41202. return branch.connect(minPriority, callback);
  41203. };
  41204. return IfStrategy;
  41205. }());
  41206. /* harmony default export */ var if_strategy = (IfStrategy);
  41207. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  41208. var FirstConnectedStrategy = (function () {
  41209. function FirstConnectedStrategy(strategy) {
  41210. this.strategy = strategy;
  41211. }
  41212. FirstConnectedStrategy.prototype.isSupported = function () {
  41213. return this.strategy.isSupported();
  41214. };
  41215. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  41216. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  41217. if (handshake) {
  41218. runner.abort();
  41219. }
  41220. callback(error, handshake);
  41221. });
  41222. return runner;
  41223. };
  41224. return FirstConnectedStrategy;
  41225. }());
  41226. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  41227. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  41228. function testSupportsStrategy(strategy) {
  41229. return function () {
  41230. return strategy.isSupported();
  41231. };
  41232. }
  41233. var getDefaultStrategy = function (config, defineTransport) {
  41234. var definedTransports = {};
  41235. function defineTransportStrategy(name, type, priority, options, manager) {
  41236. var transport = defineTransport(config, name, type, priority, options, manager);
  41237. definedTransports[name] = transport;
  41238. return transport;
  41239. }
  41240. var ws_options = {
  41241. hostNonTLS: config.wsHost + ":" + config.wsPort,
  41242. hostTLS: config.wsHost + ":" + config.wssPort,
  41243. httpPath: config.wsPath
  41244. };
  41245. var wss_options = extend({}, ws_options, {
  41246. useTLS: true
  41247. });
  41248. var sockjs_options = {
  41249. hostNonTLS: config.httpHost + ":" + config.httpPort,
  41250. hostTLS: config.httpHost + ":" + config.httpsPort,
  41251. httpPath: config.httpPath
  41252. };
  41253. var timeouts = {
  41254. loop: true,
  41255. timeout: 15000,
  41256. timeoutLimit: 60000
  41257. };
  41258. var ws_manager = new transport_manager({
  41259. lives: 2,
  41260. minPingDelay: 10000,
  41261. maxPingDelay: config.activity_timeout
  41262. });
  41263. var streaming_manager = new transport_manager({
  41264. lives: 2,
  41265. minPingDelay: 10000,
  41266. maxPingDelay: config.activity_timeout
  41267. });
  41268. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  41269. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  41270. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  41271. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  41272. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  41273. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  41274. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  41275. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  41276. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  41277. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  41278. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  41279. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  41280. 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);
  41281. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  41282. var wsStrategy;
  41283. if (config.useTLS) {
  41284. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  41285. }
  41286. else {
  41287. wsStrategy = new best_connected_ever_strategy([
  41288. ws_loop,
  41289. new delayed_strategy(wss_loop, { delay: 2000 }),
  41290. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  41291. ]);
  41292. }
  41293. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  41294. ttl: 1800000,
  41295. timeline: config.timeline,
  41296. useTLS: config.useTLS
  41297. });
  41298. };
  41299. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  41300. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  41301. /* harmony default export */ var transport_connection_initializer = (function () {
  41302. var self = this;
  41303. self.timeline.info(self.buildTimelineMessage({
  41304. transport: self.name + (self.options.useTLS ? "s" : "")
  41305. }));
  41306. if (self.hooks.isInitialized()) {
  41307. self.changeState("initialized");
  41308. }
  41309. else if (self.hooks.file) {
  41310. self.changeState("initializing");
  41311. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  41312. if (self.hooks.isInitialized()) {
  41313. self.changeState("initialized");
  41314. callback(true);
  41315. }
  41316. else {
  41317. if (error) {
  41318. self.onError(error);
  41319. }
  41320. self.onClose();
  41321. callback(false);
  41322. }
  41323. });
  41324. }
  41325. else {
  41326. self.onClose();
  41327. }
  41328. });
  41329. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  41330. var http_xdomain_request_hooks = {
  41331. getRequest: function (socket) {
  41332. var xdr = new window.XDomainRequest();
  41333. xdr.ontimeout = function () {
  41334. socket.emit("error", new RequestTimedOut());
  41335. socket.close();
  41336. };
  41337. xdr.onerror = function (e) {
  41338. socket.emit("error", e);
  41339. socket.close();
  41340. };
  41341. xdr.onprogress = function () {
  41342. if (xdr.responseText && xdr.responseText.length > 0) {
  41343. socket.onChunk(200, xdr.responseText);
  41344. }
  41345. };
  41346. xdr.onload = function () {
  41347. if (xdr.responseText && xdr.responseText.length > 0) {
  41348. socket.onChunk(200, xdr.responseText);
  41349. }
  41350. socket.emit("finished", 200);
  41351. socket.close();
  41352. };
  41353. return xdr;
  41354. },
  41355. abortRequest: function (xdr) {
  41356. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  41357. xdr.abort();
  41358. }
  41359. };
  41360. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  41361. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  41362. var http_request_extends = (undefined && undefined.__extends) || (function () {
  41363. var extendStatics = function (d, b) {
  41364. extendStatics = Object.setPrototypeOf ||
  41365. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41366. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41367. return extendStatics(d, b);
  41368. };
  41369. return function (d, b) {
  41370. extendStatics(d, b);
  41371. function __() { this.constructor = d; }
  41372. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41373. };
  41374. })();
  41375. var MAX_BUFFER_LENGTH = 256 * 1024;
  41376. var http_request_HTTPRequest = (function (_super) {
  41377. http_request_extends(HTTPRequest, _super);
  41378. function HTTPRequest(hooks, method, url) {
  41379. var _this = _super.call(this) || this;
  41380. _this.hooks = hooks;
  41381. _this.method = method;
  41382. _this.url = url;
  41383. return _this;
  41384. }
  41385. HTTPRequest.prototype.start = function (payload) {
  41386. var _this = this;
  41387. this.position = 0;
  41388. this.xhr = this.hooks.getRequest(this);
  41389. this.unloader = function () {
  41390. _this.close();
  41391. };
  41392. runtime.addUnloadListener(this.unloader);
  41393. this.xhr.open(this.method, this.url, true);
  41394. if (this.xhr.setRequestHeader) {
  41395. this.xhr.setRequestHeader("Content-Type", "application/json");
  41396. }
  41397. this.xhr.send(payload);
  41398. };
  41399. HTTPRequest.prototype.close = function () {
  41400. if (this.unloader) {
  41401. runtime.removeUnloadListener(this.unloader);
  41402. this.unloader = null;
  41403. }
  41404. if (this.xhr) {
  41405. this.hooks.abortRequest(this.xhr);
  41406. this.xhr = null;
  41407. }
  41408. };
  41409. HTTPRequest.prototype.onChunk = function (status, data) {
  41410. while (true) {
  41411. var chunk = this.advanceBuffer(data);
  41412. if (chunk) {
  41413. this.emit("chunk", { status: status, data: chunk });
  41414. }
  41415. else {
  41416. break;
  41417. }
  41418. }
  41419. if (this.isBufferTooLong(data)) {
  41420. this.emit("buffer_too_long");
  41421. }
  41422. };
  41423. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  41424. var unreadData = buffer.slice(this.position);
  41425. var endOfLinePosition = unreadData.indexOf("\n");
  41426. if (endOfLinePosition !== -1) {
  41427. this.position += endOfLinePosition + 1;
  41428. return unreadData.slice(0, endOfLinePosition);
  41429. }
  41430. else {
  41431. return null;
  41432. }
  41433. };
  41434. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  41435. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  41436. };
  41437. return HTTPRequest;
  41438. }(dispatcher));
  41439. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  41440. // CONCATENATED MODULE: ./src/core/http/state.ts
  41441. var State;
  41442. (function (State) {
  41443. State[State["CONNECTING"] = 0] = "CONNECTING";
  41444. State[State["OPEN"] = 1] = "OPEN";
  41445. State[State["CLOSED"] = 3] = "CLOSED";
  41446. })(State || (State = {}));
  41447. /* harmony default export */ var state = (State);
  41448. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  41449. var autoIncrement = 1;
  41450. var http_socket_HTTPSocket = (function () {
  41451. function HTTPSocket(hooks, url) {
  41452. this.hooks = hooks;
  41453. this.session = randomNumber(1000) + "/" + randomString(8);
  41454. this.location = getLocation(url);
  41455. this.readyState = state.CONNECTING;
  41456. this.openStream();
  41457. }
  41458. HTTPSocket.prototype.send = function (payload) {
  41459. return this.sendRaw(JSON.stringify([payload]));
  41460. };
  41461. HTTPSocket.prototype.ping = function () {
  41462. this.hooks.sendHeartbeat(this);
  41463. };
  41464. HTTPSocket.prototype.close = function (code, reason) {
  41465. this.onClose(code, reason, true);
  41466. };
  41467. HTTPSocket.prototype.sendRaw = function (payload) {
  41468. if (this.readyState === state.OPEN) {
  41469. try {
  41470. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  41471. return true;
  41472. }
  41473. catch (e) {
  41474. return false;
  41475. }
  41476. }
  41477. else {
  41478. return false;
  41479. }
  41480. };
  41481. HTTPSocket.prototype.reconnect = function () {
  41482. this.closeStream();
  41483. this.openStream();
  41484. };
  41485. ;
  41486. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  41487. this.closeStream();
  41488. this.readyState = state.CLOSED;
  41489. if (this.onclose) {
  41490. this.onclose({
  41491. code: code,
  41492. reason: reason,
  41493. wasClean: wasClean
  41494. });
  41495. }
  41496. };
  41497. HTTPSocket.prototype.onChunk = function (chunk) {
  41498. if (chunk.status !== 200) {
  41499. return;
  41500. }
  41501. if (this.readyState === state.OPEN) {
  41502. this.onActivity();
  41503. }
  41504. var payload;
  41505. var type = chunk.data.slice(0, 1);
  41506. switch (type) {
  41507. case 'o':
  41508. payload = JSON.parse(chunk.data.slice(1) || '{}');
  41509. this.onOpen(payload);
  41510. break;
  41511. case 'a':
  41512. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41513. for (var i = 0; i < payload.length; i++) {
  41514. this.onEvent(payload[i]);
  41515. }
  41516. break;
  41517. case 'm':
  41518. payload = JSON.parse(chunk.data.slice(1) || 'null');
  41519. this.onEvent(payload);
  41520. break;
  41521. case 'h':
  41522. this.hooks.onHeartbeat(this);
  41523. break;
  41524. case 'c':
  41525. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41526. this.onClose(payload[0], payload[1], true);
  41527. break;
  41528. }
  41529. };
  41530. HTTPSocket.prototype.onOpen = function (options) {
  41531. if (this.readyState === state.CONNECTING) {
  41532. if (options && options.hostname) {
  41533. this.location.base = replaceHost(this.location.base, options.hostname);
  41534. }
  41535. this.readyState = state.OPEN;
  41536. if (this.onopen) {
  41537. this.onopen();
  41538. }
  41539. }
  41540. else {
  41541. this.onClose(1006, "Server lost session", true);
  41542. }
  41543. };
  41544. HTTPSocket.prototype.onEvent = function (event) {
  41545. if (this.readyState === state.OPEN && this.onmessage) {
  41546. this.onmessage({ data: event });
  41547. }
  41548. };
  41549. HTTPSocket.prototype.onActivity = function () {
  41550. if (this.onactivity) {
  41551. this.onactivity();
  41552. }
  41553. };
  41554. HTTPSocket.prototype.onError = function (error) {
  41555. if (this.onerror) {
  41556. this.onerror(error);
  41557. }
  41558. };
  41559. HTTPSocket.prototype.openStream = function () {
  41560. var _this = this;
  41561. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  41562. this.stream.bind("chunk", function (chunk) {
  41563. _this.onChunk(chunk);
  41564. });
  41565. this.stream.bind("finished", function (status) {
  41566. _this.hooks.onFinished(_this, status);
  41567. });
  41568. this.stream.bind("buffer_too_long", function () {
  41569. _this.reconnect();
  41570. });
  41571. try {
  41572. this.stream.start();
  41573. }
  41574. catch (error) {
  41575. util.defer(function () {
  41576. _this.onError(error);
  41577. _this.onClose(1006, "Could not start streaming", false);
  41578. });
  41579. }
  41580. };
  41581. HTTPSocket.prototype.closeStream = function () {
  41582. if (this.stream) {
  41583. this.stream.unbind_all();
  41584. this.stream.close();
  41585. this.stream = null;
  41586. }
  41587. };
  41588. return HTTPSocket;
  41589. }());
  41590. function getLocation(url) {
  41591. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  41592. return {
  41593. base: parts[1],
  41594. queryString: parts[2]
  41595. };
  41596. }
  41597. function getSendURL(url, session) {
  41598. return url.base + "/" + session + "/xhr_send";
  41599. }
  41600. function getUniqueURL(url) {
  41601. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  41602. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  41603. }
  41604. function replaceHost(url, hostname) {
  41605. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  41606. return urlParts[1] + hostname + urlParts[3];
  41607. }
  41608. function randomNumber(max) {
  41609. return Math.floor(Math.random() * max);
  41610. }
  41611. function randomString(length) {
  41612. var result = [];
  41613. for (var i = 0; i < length; i++) {
  41614. result.push(randomNumber(32).toString(32));
  41615. }
  41616. return result.join('');
  41617. }
  41618. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  41619. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  41620. var http_streaming_socket_hooks = {
  41621. getReceiveURL: function (url, session) {
  41622. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  41623. },
  41624. onHeartbeat: function (socket) {
  41625. socket.sendRaw("[]");
  41626. },
  41627. sendHeartbeat: function (socket) {
  41628. socket.sendRaw("[]");
  41629. },
  41630. onFinished: function (socket, status) {
  41631. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41632. }
  41633. };
  41634. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  41635. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  41636. var http_polling_socket_hooks = {
  41637. getReceiveURL: function (url, session) {
  41638. return url.base + "/" + session + "/xhr" + url.queryString;
  41639. },
  41640. onHeartbeat: function () {
  41641. },
  41642. sendHeartbeat: function (socket) {
  41643. socket.sendRaw("[]");
  41644. },
  41645. onFinished: function (socket, status) {
  41646. if (status === 200) {
  41647. socket.reconnect();
  41648. }
  41649. else {
  41650. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41651. }
  41652. }
  41653. };
  41654. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  41655. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  41656. var http_xhr_request_hooks = {
  41657. getRequest: function (socket) {
  41658. var Constructor = runtime.getXHRAPI();
  41659. var xhr = new Constructor();
  41660. xhr.onreadystatechange = xhr.onprogress = function () {
  41661. switch (xhr.readyState) {
  41662. case 3:
  41663. if (xhr.responseText && xhr.responseText.length > 0) {
  41664. socket.onChunk(xhr.status, xhr.responseText);
  41665. }
  41666. break;
  41667. case 4:
  41668. if (xhr.responseText && xhr.responseText.length > 0) {
  41669. socket.onChunk(xhr.status, xhr.responseText);
  41670. }
  41671. socket.emit("finished", xhr.status);
  41672. socket.close();
  41673. break;
  41674. }
  41675. };
  41676. return xhr;
  41677. },
  41678. abortRequest: function (xhr) {
  41679. xhr.onreadystatechange = null;
  41680. xhr.abort();
  41681. }
  41682. };
  41683. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  41684. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  41685. var HTTP = {
  41686. createStreamingSocket: function (url) {
  41687. return this.createSocket(http_streaming_socket, url);
  41688. },
  41689. createPollingSocket: function (url) {
  41690. return this.createSocket(http_polling_socket, url);
  41691. },
  41692. createSocket: function (hooks, url) {
  41693. return new http_socket(hooks, url);
  41694. },
  41695. createXHR: function (method, url) {
  41696. return this.createRequest(http_xhr_request, method, url);
  41697. },
  41698. createRequest: function (hooks, method, url) {
  41699. return new http_request(hooks, method, url);
  41700. }
  41701. };
  41702. /* harmony default export */ var http_http = (HTTP);
  41703. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  41704. http_http.createXDR = function (method, url) {
  41705. return this.createRequest(http_xdomain_request, method, url);
  41706. };
  41707. /* harmony default export */ var web_http_http = (http_http);
  41708. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  41709. var Runtime = {
  41710. nextAuthCallbackID: 1,
  41711. auth_callbacks: {},
  41712. ScriptReceivers: ScriptReceivers,
  41713. DependenciesReceivers: DependenciesReceivers,
  41714. getDefaultStrategy: default_strategy,
  41715. Transports: transports_transports,
  41716. transportConnectionInitializer: transport_connection_initializer,
  41717. HTTPFactory: web_http_http,
  41718. TimelineTransport: jsonp_timeline,
  41719. getXHRAPI: function () {
  41720. return window.XMLHttpRequest;
  41721. },
  41722. getWebSocketAPI: function () {
  41723. return window.WebSocket || window.MozWebSocket;
  41724. },
  41725. setup: function (PusherClass) {
  41726. var _this = this;
  41727. window.Pusher = PusherClass;
  41728. var initializeOnDocumentBody = function () {
  41729. _this.onDocumentBody(PusherClass.ready);
  41730. };
  41731. if (!window.JSON) {
  41732. Dependencies.load("json2", {}, initializeOnDocumentBody);
  41733. }
  41734. else {
  41735. initializeOnDocumentBody();
  41736. }
  41737. },
  41738. getDocument: function () {
  41739. return document;
  41740. },
  41741. getProtocol: function () {
  41742. return this.getDocument().location.protocol;
  41743. },
  41744. getAuthorizers: function () {
  41745. return { ajax: xhr_auth, jsonp: jsonp_auth };
  41746. },
  41747. onDocumentBody: function (callback) {
  41748. var _this = this;
  41749. if (document.body) {
  41750. callback();
  41751. }
  41752. else {
  41753. setTimeout(function () {
  41754. _this.onDocumentBody(callback);
  41755. }, 0);
  41756. }
  41757. },
  41758. createJSONPRequest: function (url, data) {
  41759. return new jsonp_request(url, data);
  41760. },
  41761. createScriptRequest: function (src) {
  41762. return new script_request(src);
  41763. },
  41764. getLocalStorage: function () {
  41765. try {
  41766. return window.localStorage;
  41767. }
  41768. catch (e) {
  41769. return undefined;
  41770. }
  41771. },
  41772. createXHR: function () {
  41773. if (this.getXHRAPI()) {
  41774. return this.createXMLHttpRequest();
  41775. }
  41776. else {
  41777. return this.createMicrosoftXHR();
  41778. }
  41779. },
  41780. createXMLHttpRequest: function () {
  41781. var Constructor = this.getXHRAPI();
  41782. return new Constructor();
  41783. },
  41784. createMicrosoftXHR: function () {
  41785. return new ActiveXObject("Microsoft.XMLHTTP");
  41786. },
  41787. getNetwork: function () {
  41788. return net_info_Network;
  41789. },
  41790. createWebSocket: function (url) {
  41791. var Constructor = this.getWebSocketAPI();
  41792. return new Constructor(url);
  41793. },
  41794. createSocketRequest: function (method, url) {
  41795. if (this.isXHRSupported()) {
  41796. return this.HTTPFactory.createXHR(method, url);
  41797. }
  41798. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  41799. return this.HTTPFactory.createXDR(method, url);
  41800. }
  41801. else {
  41802. throw "Cross-origin HTTP requests are not supported";
  41803. }
  41804. },
  41805. isXHRSupported: function () {
  41806. var Constructor = this.getXHRAPI();
  41807. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  41808. },
  41809. isXDRSupported: function (useTLS) {
  41810. var protocol = useTLS ? "https:" : "http:";
  41811. var documentProtocol = this.getProtocol();
  41812. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  41813. },
  41814. addUnloadListener: function (listener) {
  41815. if (window.addEventListener !== undefined) {
  41816. window.addEventListener("unload", listener, false);
  41817. }
  41818. else if (window.attachEvent !== undefined) {
  41819. window.attachEvent("onunload", listener);
  41820. }
  41821. },
  41822. removeUnloadListener: function (listener) {
  41823. if (window.addEventListener !== undefined) {
  41824. window.removeEventListener("unload", listener, false);
  41825. }
  41826. else if (window.detachEvent !== undefined) {
  41827. window.detachEvent("onunload", listener);
  41828. }
  41829. }
  41830. };
  41831. /* harmony default export */ var runtime = (Runtime);
  41832. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  41833. var TimelineLevel;
  41834. (function (TimelineLevel) {
  41835. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  41836. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  41837. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  41838. })(TimelineLevel || (TimelineLevel = {}));
  41839. /* harmony default export */ var timeline_level = (TimelineLevel);
  41840. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  41841. var timeline_Timeline = (function () {
  41842. function Timeline(key, session, options) {
  41843. this.key = key;
  41844. this.session = session;
  41845. this.events = [];
  41846. this.options = options || {};
  41847. this.sent = 0;
  41848. this.uniqueID = 0;
  41849. }
  41850. Timeline.prototype.log = function (level, event) {
  41851. if (level <= this.options.level) {
  41852. this.events.push(extend({}, event, { timestamp: util.now() }));
  41853. if (this.options.limit && this.events.length > this.options.limit) {
  41854. this.events.shift();
  41855. }
  41856. }
  41857. };
  41858. Timeline.prototype.error = function (event) {
  41859. this.log(timeline_level.ERROR, event);
  41860. };
  41861. Timeline.prototype.info = function (event) {
  41862. this.log(timeline_level.INFO, event);
  41863. };
  41864. Timeline.prototype.debug = function (event) {
  41865. this.log(timeline_level.DEBUG, event);
  41866. };
  41867. Timeline.prototype.isEmpty = function () {
  41868. return this.events.length === 0;
  41869. };
  41870. Timeline.prototype.send = function (sendfn, callback) {
  41871. var _this = this;
  41872. var data = extend({
  41873. session: this.session,
  41874. bundle: this.sent + 1,
  41875. key: this.key,
  41876. lib: "js",
  41877. version: this.options.version,
  41878. cluster: this.options.cluster,
  41879. features: this.options.features,
  41880. timeline: this.events
  41881. }, this.options.params);
  41882. this.events = [];
  41883. sendfn(data, function (error, result) {
  41884. if (!error) {
  41885. _this.sent++;
  41886. }
  41887. if (callback) {
  41888. callback(error, result);
  41889. }
  41890. });
  41891. return true;
  41892. };
  41893. Timeline.prototype.generateUniqueID = function () {
  41894. this.uniqueID++;
  41895. return this.uniqueID;
  41896. };
  41897. return Timeline;
  41898. }());
  41899. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  41900. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  41901. var transport_strategy_TransportStrategy = (function () {
  41902. function TransportStrategy(name, priority, transport, options) {
  41903. this.name = name;
  41904. this.priority = priority;
  41905. this.transport = transport;
  41906. this.options = options || {};
  41907. }
  41908. TransportStrategy.prototype.isSupported = function () {
  41909. return this.transport.isSupported({
  41910. useTLS: this.options.useTLS
  41911. });
  41912. };
  41913. TransportStrategy.prototype.connect = function (minPriority, callback) {
  41914. var _this = this;
  41915. if (!this.isSupported()) {
  41916. return failAttempt(new UnsupportedStrategy(), callback);
  41917. }
  41918. else if (this.priority < minPriority) {
  41919. return failAttempt(new TransportPriorityTooLow(), callback);
  41920. }
  41921. var connected = false;
  41922. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  41923. var handshake = null;
  41924. var onInitialized = function () {
  41925. transport.unbind("initialized", onInitialized);
  41926. transport.connect();
  41927. };
  41928. var onOpen = function () {
  41929. handshake = factory.createHandshake(transport, function (result) {
  41930. connected = true;
  41931. unbindListeners();
  41932. callback(null, result);
  41933. });
  41934. };
  41935. var onError = function (error) {
  41936. unbindListeners();
  41937. callback(error);
  41938. };
  41939. var onClosed = function () {
  41940. unbindListeners();
  41941. var serializedTransport;
  41942. serializedTransport = safeJSONStringify(transport);
  41943. callback(new TransportClosed(serializedTransport));
  41944. };
  41945. var unbindListeners = function () {
  41946. transport.unbind("initialized", onInitialized);
  41947. transport.unbind("open", onOpen);
  41948. transport.unbind("error", onError);
  41949. transport.unbind("closed", onClosed);
  41950. };
  41951. transport.bind("initialized", onInitialized);
  41952. transport.bind("open", onOpen);
  41953. transport.bind("error", onError);
  41954. transport.bind("closed", onClosed);
  41955. transport.initialize();
  41956. return {
  41957. abort: function () {
  41958. if (connected) {
  41959. return;
  41960. }
  41961. unbindListeners();
  41962. if (handshake) {
  41963. handshake.close();
  41964. }
  41965. else {
  41966. transport.close();
  41967. }
  41968. },
  41969. forceMinPriority: function (p) {
  41970. if (connected) {
  41971. return;
  41972. }
  41973. if (_this.priority < p) {
  41974. if (handshake) {
  41975. handshake.close();
  41976. }
  41977. else {
  41978. transport.close();
  41979. }
  41980. }
  41981. }
  41982. };
  41983. };
  41984. return TransportStrategy;
  41985. }());
  41986. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  41987. function failAttempt(error, callback) {
  41988. util.defer(function () {
  41989. callback(error);
  41990. });
  41991. return {
  41992. abort: function () { },
  41993. forceMinPriority: function () { }
  41994. };
  41995. }
  41996. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  41997. var strategy_builder_Transports = runtime.Transports;
  41998. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  41999. var transportClass = strategy_builder_Transports[type];
  42000. if (!transportClass) {
  42001. throw new UnsupportedTransport(type);
  42002. }
  42003. var enabled = (!config.enabledTransports ||
  42004. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  42005. (!config.disabledTransports ||
  42006. arrayIndexOf(config.disabledTransports, name) === -1);
  42007. var transport;
  42008. if (enabled) {
  42009. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  42010. key: config.key,
  42011. useTLS: config.useTLS,
  42012. timeline: config.timeline,
  42013. ignoreNullOrigin: config.ignoreNullOrigin
  42014. }, options));
  42015. }
  42016. else {
  42017. transport = strategy_builder_UnsupportedStrategy;
  42018. }
  42019. return transport;
  42020. };
  42021. var strategy_builder_UnsupportedStrategy = {
  42022. isSupported: function () {
  42023. return false;
  42024. },
  42025. connect: function (_, callback) {
  42026. var deferred = util.defer(function () {
  42027. callback(new UnsupportedStrategy());
  42028. });
  42029. return {
  42030. abort: function () {
  42031. deferred.ensureAborted();
  42032. },
  42033. forceMinPriority: function () { }
  42034. };
  42035. }
  42036. };
  42037. // CONCATENATED MODULE: ./src/core/config.ts
  42038. var getGlobalConfig = function () {
  42039. return {
  42040. wsHost: defaults.host,
  42041. wsPort: defaults.ws_port,
  42042. wssPort: defaults.wss_port,
  42043. wsPath: defaults.ws_path,
  42044. httpHost: defaults.sockjs_host,
  42045. httpPort: defaults.sockjs_http_port,
  42046. httpsPort: defaults.sockjs_https_port,
  42047. httpPath: defaults.sockjs_path,
  42048. statsHost: defaults.stats_host,
  42049. authEndpoint: defaults.channel_auth_endpoint,
  42050. authTransport: defaults.channel_auth_transport,
  42051. activity_timeout: defaults.activity_timeout,
  42052. pong_timeout: defaults.pong_timeout,
  42053. unavailable_timeout: defaults.unavailable_timeout
  42054. };
  42055. };
  42056. var getClusterConfig = function (clusterName) {
  42057. return {
  42058. wsHost: 'ws-' + clusterName + '.pusher.com',
  42059. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  42060. };
  42061. };
  42062. // CONCATENATED MODULE: ./src/core/pusher.ts
  42063. var pusher_Pusher = (function () {
  42064. function Pusher(app_key, options) {
  42065. var _this = this;
  42066. checkAppKey(app_key);
  42067. options = options || {};
  42068. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  42069. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  42070. logger.warn("You should always specify a cluster when connecting. " + suffix);
  42071. }
  42072. this.key = app_key;
  42073. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  42074. this.channels = factory.createChannels();
  42075. this.global_emitter = new dispatcher();
  42076. this.sessionID = Math.floor(Math.random() * 1000000000);
  42077. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  42078. cluster: this.config.cluster,
  42079. features: Pusher.getClientFeatures(),
  42080. params: this.config.timelineParams || {},
  42081. limit: 50,
  42082. level: timeline_level.INFO,
  42083. version: defaults.VERSION
  42084. });
  42085. if (!this.config.disableStats) {
  42086. this.timelineSender = factory.createTimelineSender(this.timeline, {
  42087. host: this.config.statsHost,
  42088. path: '/timeline/v2/' + runtime.TimelineTransport.name
  42089. });
  42090. }
  42091. var getStrategy = function (options) {
  42092. var config = extend({}, _this.config, options);
  42093. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  42094. };
  42095. this.connection = factory.createConnectionManager(this.key, extend({
  42096. getStrategy: getStrategy,
  42097. timeline: this.timeline,
  42098. activityTimeout: this.config.activity_timeout,
  42099. pongTimeout: this.config.pong_timeout,
  42100. unavailableTimeout: this.config.unavailable_timeout
  42101. }, this.config, { useTLS: this.shouldUseTLS() }));
  42102. this.connection.bind('connected', function () {
  42103. _this.subscribeAll();
  42104. if (_this.timelineSender) {
  42105. _this.timelineSender.send(_this.connection.isUsingTLS());
  42106. }
  42107. });
  42108. this.connection.bind('message', function (event) {
  42109. var eventName = event.event;
  42110. var internal = eventName.indexOf('pusher_internal:') === 0;
  42111. if (event.channel) {
  42112. var channel = _this.channel(event.channel);
  42113. if (channel) {
  42114. channel.handleEvent(event);
  42115. }
  42116. }
  42117. if (!internal) {
  42118. _this.global_emitter.emit(event.event, event.data);
  42119. }
  42120. });
  42121. this.connection.bind('connecting', function () {
  42122. _this.channels.disconnect();
  42123. });
  42124. this.connection.bind('disconnected', function () {
  42125. _this.channels.disconnect();
  42126. });
  42127. this.connection.bind('error', function (err) {
  42128. logger.warn(err);
  42129. });
  42130. Pusher.instances.push(this);
  42131. this.timeline.info({ instances: Pusher.instances.length });
  42132. if (Pusher.isReady) {
  42133. this.connect();
  42134. }
  42135. }
  42136. Pusher.ready = function () {
  42137. Pusher.isReady = true;
  42138. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  42139. Pusher.instances[i].connect();
  42140. }
  42141. };
  42142. Pusher.getClientFeatures = function () {
  42143. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  42144. return t.isSupported({});
  42145. }));
  42146. };
  42147. Pusher.prototype.channel = function (name) {
  42148. return this.channels.find(name);
  42149. };
  42150. Pusher.prototype.allChannels = function () {
  42151. return this.channels.all();
  42152. };
  42153. Pusher.prototype.connect = function () {
  42154. this.connection.connect();
  42155. if (this.timelineSender) {
  42156. if (!this.timelineSenderTimer) {
  42157. var usingTLS = this.connection.isUsingTLS();
  42158. var timelineSender = this.timelineSender;
  42159. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  42160. timelineSender.send(usingTLS);
  42161. });
  42162. }
  42163. }
  42164. };
  42165. Pusher.prototype.disconnect = function () {
  42166. this.connection.disconnect();
  42167. if (this.timelineSenderTimer) {
  42168. this.timelineSenderTimer.ensureAborted();
  42169. this.timelineSenderTimer = null;
  42170. }
  42171. };
  42172. Pusher.prototype.bind = function (event_name, callback, context) {
  42173. this.global_emitter.bind(event_name, callback, context);
  42174. return this;
  42175. };
  42176. Pusher.prototype.unbind = function (event_name, callback, context) {
  42177. this.global_emitter.unbind(event_name, callback, context);
  42178. return this;
  42179. };
  42180. Pusher.prototype.bind_global = function (callback) {
  42181. this.global_emitter.bind_global(callback);
  42182. return this;
  42183. };
  42184. Pusher.prototype.unbind_global = function (callback) {
  42185. this.global_emitter.unbind_global(callback);
  42186. return this;
  42187. };
  42188. Pusher.prototype.unbind_all = function (callback) {
  42189. this.global_emitter.unbind_all();
  42190. return this;
  42191. };
  42192. Pusher.prototype.subscribeAll = function () {
  42193. var channelName;
  42194. for (channelName in this.channels.channels) {
  42195. if (this.channels.channels.hasOwnProperty(channelName)) {
  42196. this.subscribe(channelName);
  42197. }
  42198. }
  42199. };
  42200. Pusher.prototype.subscribe = function (channel_name) {
  42201. var channel = this.channels.add(channel_name, this);
  42202. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  42203. channel.reinstateSubscription();
  42204. }
  42205. else if (!channel.subscriptionPending &&
  42206. this.connection.state === 'connected') {
  42207. channel.subscribe();
  42208. }
  42209. return channel;
  42210. };
  42211. Pusher.prototype.unsubscribe = function (channel_name) {
  42212. var channel = this.channels.find(channel_name);
  42213. if (channel && channel.subscriptionPending) {
  42214. channel.cancelSubscription();
  42215. }
  42216. else {
  42217. channel = this.channels.remove(channel_name);
  42218. if (channel && this.connection.state === 'connected') {
  42219. channel.unsubscribe();
  42220. }
  42221. }
  42222. };
  42223. Pusher.prototype.send_event = function (event_name, data, channel) {
  42224. return this.connection.send_event(event_name, data, channel);
  42225. };
  42226. Pusher.prototype.shouldUseTLS = function () {
  42227. if (runtime.getProtocol() === 'https:') {
  42228. return true;
  42229. }
  42230. else if (this.config.forceTLS === true) {
  42231. return true;
  42232. }
  42233. else {
  42234. return Boolean(this.config.encrypted);
  42235. }
  42236. };
  42237. Pusher.instances = [];
  42238. Pusher.isReady = false;
  42239. Pusher.logToConsole = false;
  42240. Pusher.Runtime = runtime;
  42241. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  42242. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  42243. Pusher.auth_callbacks = runtime.auth_callbacks;
  42244. return Pusher;
  42245. }());
  42246. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  42247. function checkAppKey(key) {
  42248. if (key === null || key === undefined) {
  42249. throw 'You must pass your app key when you instantiate Pusher.';
  42250. }
  42251. }
  42252. runtime.setup(pusher_Pusher);
  42253. /***/ })
  42254. /******/ ]);
  42255. });
  42256. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  42257. /***/ }),
  42258. /***/ "./node_modules/setimmediate/setImmediate.js":
  42259. /*!***************************************************!*\
  42260. !*** ./node_modules/setimmediate/setImmediate.js ***!
  42261. \***************************************************/
  42262. /*! no static exports found */
  42263. /***/ (function(module, exports, __webpack_require__) {
  42264. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  42265. "use strict";
  42266. if (global.setImmediate) {
  42267. return;
  42268. }
  42269. var nextHandle = 1; // Spec says greater than zero
  42270. var tasksByHandle = {};
  42271. var currentlyRunningATask = false;
  42272. var doc = global.document;
  42273. var registerImmediate;
  42274. function setImmediate(callback) {
  42275. // Callback can either be a function or a string
  42276. if (typeof callback !== "function") {
  42277. callback = new Function("" + callback);
  42278. }
  42279. // Copy function arguments
  42280. var args = new Array(arguments.length - 1);
  42281. for (var i = 0; i < args.length; i++) {
  42282. args[i] = arguments[i + 1];
  42283. }
  42284. // Store and register the task
  42285. var task = { callback: callback, args: args };
  42286. tasksByHandle[nextHandle] = task;
  42287. registerImmediate(nextHandle);
  42288. return nextHandle++;
  42289. }
  42290. function clearImmediate(handle) {
  42291. delete tasksByHandle[handle];
  42292. }
  42293. function run(task) {
  42294. var callback = task.callback;
  42295. var args = task.args;
  42296. switch (args.length) {
  42297. case 0:
  42298. callback();
  42299. break;
  42300. case 1:
  42301. callback(args[0]);
  42302. break;
  42303. case 2:
  42304. callback(args[0], args[1]);
  42305. break;
  42306. case 3:
  42307. callback(args[0], args[1], args[2]);
  42308. break;
  42309. default:
  42310. callback.apply(undefined, args);
  42311. break;
  42312. }
  42313. }
  42314. function runIfPresent(handle) {
  42315. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  42316. // So if we're currently running a task, we'll need to delay this invocation.
  42317. if (currentlyRunningATask) {
  42318. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  42319. // "too much recursion" error.
  42320. setTimeout(runIfPresent, 0, handle);
  42321. } else {
  42322. var task = tasksByHandle[handle];
  42323. if (task) {
  42324. currentlyRunningATask = true;
  42325. try {
  42326. run(task);
  42327. } finally {
  42328. clearImmediate(handle);
  42329. currentlyRunningATask = false;
  42330. }
  42331. }
  42332. }
  42333. }
  42334. function installNextTickImplementation() {
  42335. registerImmediate = function(handle) {
  42336. process.nextTick(function () { runIfPresent(handle); });
  42337. };
  42338. }
  42339. function canUsePostMessage() {
  42340. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  42341. // where `global.postMessage` means something completely different and can't be used for this purpose.
  42342. if (global.postMessage && !global.importScripts) {
  42343. var postMessageIsAsynchronous = true;
  42344. var oldOnMessage = global.onmessage;
  42345. global.onmessage = function() {
  42346. postMessageIsAsynchronous = false;
  42347. };
  42348. global.postMessage("", "*");
  42349. global.onmessage = oldOnMessage;
  42350. return postMessageIsAsynchronous;
  42351. }
  42352. }
  42353. function installPostMessageImplementation() {
  42354. // Installs an event handler on `global` for the `message` event: see
  42355. // * https://developer.mozilla.org/en/DOM/window.postMessage
  42356. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  42357. var messagePrefix = "setImmediate$" + Math.random() + "$";
  42358. var onGlobalMessage = function(event) {
  42359. if (event.source === global &&
  42360. typeof event.data === "string" &&
  42361. event.data.indexOf(messagePrefix) === 0) {
  42362. runIfPresent(+event.data.slice(messagePrefix.length));
  42363. }
  42364. };
  42365. if (global.addEventListener) {
  42366. global.addEventListener("message", onGlobalMessage, false);
  42367. } else {
  42368. global.attachEvent("onmessage", onGlobalMessage);
  42369. }
  42370. registerImmediate = function(handle) {
  42371. global.postMessage(messagePrefix + handle, "*");
  42372. };
  42373. }
  42374. function installMessageChannelImplementation() {
  42375. var channel = new MessageChannel();
  42376. channel.port1.onmessage = function(event) {
  42377. var handle = event.data;
  42378. runIfPresent(handle);
  42379. };
  42380. registerImmediate = function(handle) {
  42381. channel.port2.postMessage(handle);
  42382. };
  42383. }
  42384. function installReadyStateChangeImplementation() {
  42385. var html = doc.documentElement;
  42386. registerImmediate = function(handle) {
  42387. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  42388. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  42389. var script = doc.createElement("script");
  42390. script.onreadystatechange = function () {
  42391. runIfPresent(handle);
  42392. script.onreadystatechange = null;
  42393. html.removeChild(script);
  42394. script = null;
  42395. };
  42396. html.appendChild(script);
  42397. };
  42398. }
  42399. function installSetTimeoutImplementation() {
  42400. registerImmediate = function(handle) {
  42401. setTimeout(runIfPresent, 0, handle);
  42402. };
  42403. }
  42404. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  42405. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  42406. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  42407. // Don't get fooled by e.g. browserify environments.
  42408. if ({}.toString.call(global.process) === "[object process]") {
  42409. // For Node.js before 0.9
  42410. installNextTickImplementation();
  42411. } else if (canUsePostMessage()) {
  42412. // For non-IE10 modern browsers
  42413. installPostMessageImplementation();
  42414. } else if (global.MessageChannel) {
  42415. // For web workers, where supported
  42416. installMessageChannelImplementation();
  42417. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  42418. // For IE 6–8
  42419. installReadyStateChangeImplementation();
  42420. } else {
  42421. // For older browsers
  42422. installSetTimeoutImplementation();
  42423. }
  42424. attachTo.setImmediate = setImmediate;
  42425. attachTo.clearImmediate = clearImmediate;
  42426. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  42427. /* 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")))
  42428. /***/ }),
  42429. /***/ "./node_modules/style-loader/index.js!./node_modules/css-loader/index.js?!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&":
  42430. /*!************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
  42431. !*** ./node_modules/style-loader!./node_modules/css-loader??ref--6-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--6-2!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& ***!
  42432. \************************************************************************************************************************************************************************************************************************************************************************************************************************/
  42433. /*! no static exports found */
  42434. /***/ (function(module, exports, __webpack_require__) {
  42435. var content = __webpack_require__(/*! !../../../node_modules/css-loader??ref--6-1!../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../node_modules/postcss-loader/src??ref--6-2!../../../node_modules/vue-loader/lib??vue-loader-options!./Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& */ "./node_modules/css-loader/index.js?!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&");
  42436. if(typeof content === 'string') content = [[module.i, content, '']];
  42437. var transform;
  42438. var insertInto;
  42439. var options = {"hmr":true}
  42440. options.transform = transform
  42441. options.insertInto = undefined;
  42442. var update = __webpack_require__(/*! ../../../node_modules/style-loader/lib/addStyles.js */ "./node_modules/style-loader/lib/addStyles.js")(content, options);
  42443. if(content.locals) module.exports = content.locals;
  42444. if(false) {}
  42445. /***/ }),
  42446. /***/ "./node_modules/style-loader/lib/addStyles.js":
  42447. /*!****************************************************!*\
  42448. !*** ./node_modules/style-loader/lib/addStyles.js ***!
  42449. \****************************************************/
  42450. /*! no static exports found */
  42451. /***/ (function(module, exports, __webpack_require__) {
  42452. /*
  42453. MIT License http://www.opensource.org/licenses/mit-license.php
  42454. Author Tobias Koppers @sokra
  42455. */
  42456. var stylesInDom = {};
  42457. var memoize = function (fn) {
  42458. var memo;
  42459. return function () {
  42460. if (typeof memo === "undefined") memo = fn.apply(this, arguments);
  42461. return memo;
  42462. };
  42463. };
  42464. var isOldIE = memoize(function () {
  42465. // Test for IE <= 9 as proposed by Browserhacks
  42466. // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
  42467. // Tests for existence of standard globals is to allow style-loader
  42468. // to operate correctly into non-standard environments
  42469. // @see https://github.com/webpack-contrib/style-loader/issues/177
  42470. return window && document && document.all && !window.atob;
  42471. });
  42472. var getTarget = function (target, parent) {
  42473. if (parent){
  42474. return parent.querySelector(target);
  42475. }
  42476. return document.querySelector(target);
  42477. };
  42478. var getElement = (function (fn) {
  42479. var memo = {};
  42480. return function(target, parent) {
  42481. // If passing function in options, then use it for resolve "head" element.
  42482. // Useful for Shadow Root style i.e
  42483. // {
  42484. // insertInto: function () { return document.querySelector("#foo").shadowRoot }
  42485. // }
  42486. if (typeof target === 'function') {
  42487. return target();
  42488. }
  42489. if (typeof memo[target] === "undefined") {
  42490. var styleTarget = getTarget.call(this, target, parent);
  42491. // Special case to return head of iframe instead of iframe itself
  42492. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  42493. try {
  42494. // This will throw an exception if access to iframe is blocked
  42495. // due to cross-origin restrictions
  42496. styleTarget = styleTarget.contentDocument.head;
  42497. } catch(e) {
  42498. styleTarget = null;
  42499. }
  42500. }
  42501. memo[target] = styleTarget;
  42502. }
  42503. return memo[target]
  42504. };
  42505. })();
  42506. var singleton = null;
  42507. var singletonCounter = 0;
  42508. var stylesInsertedAtTop = [];
  42509. var fixUrls = __webpack_require__(/*! ./urls */ "./node_modules/style-loader/lib/urls.js");
  42510. module.exports = function(list, options) {
  42511. if (typeof DEBUG !== "undefined" && DEBUG) {
  42512. if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
  42513. }
  42514. options = options || {};
  42515. options.attrs = typeof options.attrs === "object" ? options.attrs : {};
  42516. // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  42517. // tags it will allow on a page
  42518. if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();
  42519. // By default, add <style> tags to the <head> element
  42520. if (!options.insertInto) options.insertInto = "head";
  42521. // By default, add <style> tags to the bottom of the target
  42522. if (!options.insertAt) options.insertAt = "bottom";
  42523. var styles = listToStyles(list, options);
  42524. addStylesToDom(styles, options);
  42525. return function update (newList) {
  42526. var mayRemove = [];
  42527. for (var i = 0; i < styles.length; i++) {
  42528. var item = styles[i];
  42529. var domStyle = stylesInDom[item.id];
  42530. domStyle.refs--;
  42531. mayRemove.push(domStyle);
  42532. }
  42533. if(newList) {
  42534. var newStyles = listToStyles(newList, options);
  42535. addStylesToDom(newStyles, options);
  42536. }
  42537. for (var i = 0; i < mayRemove.length; i++) {
  42538. var domStyle = mayRemove[i];
  42539. if(domStyle.refs === 0) {
  42540. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
  42541. delete stylesInDom[domStyle.id];
  42542. }
  42543. }
  42544. };
  42545. };
  42546. function addStylesToDom (styles, options) {
  42547. for (var i = 0; i < styles.length; i++) {
  42548. var item = styles[i];
  42549. var domStyle = stylesInDom[item.id];
  42550. if(domStyle) {
  42551. domStyle.refs++;
  42552. for(var j = 0; j < domStyle.parts.length; j++) {
  42553. domStyle.parts[j](item.parts[j]);
  42554. }
  42555. for(; j < item.parts.length; j++) {
  42556. domStyle.parts.push(addStyle(item.parts[j], options));
  42557. }
  42558. } else {
  42559. var parts = [];
  42560. for(var j = 0; j < item.parts.length; j++) {
  42561. parts.push(addStyle(item.parts[j], options));
  42562. }
  42563. stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
  42564. }
  42565. }
  42566. }
  42567. function listToStyles (list, options) {
  42568. var styles = [];
  42569. var newStyles = {};
  42570. for (var i = 0; i < list.length; i++) {
  42571. var item = list[i];
  42572. var id = options.base ? item[0] + options.base : item[0];
  42573. var css = item[1];
  42574. var media = item[2];
  42575. var sourceMap = item[3];
  42576. var part = {css: css, media: media, sourceMap: sourceMap};
  42577. if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
  42578. else newStyles[id].parts.push(part);
  42579. }
  42580. return styles;
  42581. }
  42582. function insertStyleElement (options, style) {
  42583. var target = getElement(options.insertInto)
  42584. if (!target) {
  42585. throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
  42586. }
  42587. var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
  42588. if (options.insertAt === "top") {
  42589. if (!lastStyleElementInsertedAtTop) {
  42590. target.insertBefore(style, target.firstChild);
  42591. } else if (lastStyleElementInsertedAtTop.nextSibling) {
  42592. target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
  42593. } else {
  42594. target.appendChild(style);
  42595. }
  42596. stylesInsertedAtTop.push(style);
  42597. } else if (options.insertAt === "bottom") {
  42598. target.appendChild(style);
  42599. } else if (typeof options.insertAt === "object" && options.insertAt.before) {
  42600. var nextSibling = getElement(options.insertAt.before, target);
  42601. target.insertBefore(style, nextSibling);
  42602. } else {
  42603. throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
  42604. }
  42605. }
  42606. function removeStyleElement (style) {
  42607. if (style.parentNode === null) return false;
  42608. style.parentNode.removeChild(style);
  42609. var idx = stylesInsertedAtTop.indexOf(style);
  42610. if(idx >= 0) {
  42611. stylesInsertedAtTop.splice(idx, 1);
  42612. }
  42613. }
  42614. function createStyleElement (options) {
  42615. var style = document.createElement("style");
  42616. if(options.attrs.type === undefined) {
  42617. options.attrs.type = "text/css";
  42618. }
  42619. if(options.attrs.nonce === undefined) {
  42620. var nonce = getNonce();
  42621. if (nonce) {
  42622. options.attrs.nonce = nonce;
  42623. }
  42624. }
  42625. addAttrs(style, options.attrs);
  42626. insertStyleElement(options, style);
  42627. return style;
  42628. }
  42629. function createLinkElement (options) {
  42630. var link = document.createElement("link");
  42631. if(options.attrs.type === undefined) {
  42632. options.attrs.type = "text/css";
  42633. }
  42634. options.attrs.rel = "stylesheet";
  42635. addAttrs(link, options.attrs);
  42636. insertStyleElement(options, link);
  42637. return link;
  42638. }
  42639. function addAttrs (el, attrs) {
  42640. Object.keys(attrs).forEach(function (key) {
  42641. el.setAttribute(key, attrs[key]);
  42642. });
  42643. }
  42644. function getNonce() {
  42645. if (false) {}
  42646. return __webpack_require__.nc;
  42647. }
  42648. function addStyle (obj, options) {
  42649. var style, update, remove, result;
  42650. // If a transform function was defined, run it on the css
  42651. if (options.transform && obj.css) {
  42652. result = typeof options.transform === 'function'
  42653. ? options.transform(obj.css)
  42654. : options.transform.default(obj.css);
  42655. if (result) {
  42656. // If transform returns a value, use that instead of the original css.
  42657. // This allows running runtime transformations on the css.
  42658. obj.css = result;
  42659. } else {
  42660. // If the transform function returns a falsy value, don't add this css.
  42661. // This allows conditional loading of css
  42662. return function() {
  42663. // noop
  42664. };
  42665. }
  42666. }
  42667. if (options.singleton) {
  42668. var styleIndex = singletonCounter++;
  42669. style = singleton || (singleton = createStyleElement(options));
  42670. update = applyToSingletonTag.bind(null, style, styleIndex, false);
  42671. remove = applyToSingletonTag.bind(null, style, styleIndex, true);
  42672. } else if (
  42673. obj.sourceMap &&
  42674. typeof URL === "function" &&
  42675. typeof URL.createObjectURL === "function" &&
  42676. typeof URL.revokeObjectURL === "function" &&
  42677. typeof Blob === "function" &&
  42678. typeof btoa === "function"
  42679. ) {
  42680. style = createLinkElement(options);
  42681. update = updateLink.bind(null, style, options);
  42682. remove = function () {
  42683. removeStyleElement(style);
  42684. if(style.href) URL.revokeObjectURL(style.href);
  42685. };
  42686. } else {
  42687. style = createStyleElement(options);
  42688. update = applyToTag.bind(null, style);
  42689. remove = function () {
  42690. removeStyleElement(style);
  42691. };
  42692. }
  42693. update(obj);
  42694. return function updateStyle (newObj) {
  42695. if (newObj) {
  42696. if (
  42697. newObj.css === obj.css &&
  42698. newObj.media === obj.media &&
  42699. newObj.sourceMap === obj.sourceMap
  42700. ) {
  42701. return;
  42702. }
  42703. update(obj = newObj);
  42704. } else {
  42705. remove();
  42706. }
  42707. };
  42708. }
  42709. var replaceText = (function () {
  42710. var textStore = [];
  42711. return function (index, replacement) {
  42712. textStore[index] = replacement;
  42713. return textStore.filter(Boolean).join('\n');
  42714. };
  42715. })();
  42716. function applyToSingletonTag (style, index, remove, obj) {
  42717. var css = remove ? "" : obj.css;
  42718. if (style.styleSheet) {
  42719. style.styleSheet.cssText = replaceText(index, css);
  42720. } else {
  42721. var cssNode = document.createTextNode(css);
  42722. var childNodes = style.childNodes;
  42723. if (childNodes[index]) style.removeChild(childNodes[index]);
  42724. if (childNodes.length) {
  42725. style.insertBefore(cssNode, childNodes[index]);
  42726. } else {
  42727. style.appendChild(cssNode);
  42728. }
  42729. }
  42730. }
  42731. function applyToTag (style, obj) {
  42732. var css = obj.css;
  42733. var media = obj.media;
  42734. if(media) {
  42735. style.setAttribute("media", media)
  42736. }
  42737. if(style.styleSheet) {
  42738. style.styleSheet.cssText = css;
  42739. } else {
  42740. while(style.firstChild) {
  42741. style.removeChild(style.firstChild);
  42742. }
  42743. style.appendChild(document.createTextNode(css));
  42744. }
  42745. }
  42746. function updateLink (link, options, obj) {
  42747. var css = obj.css;
  42748. var sourceMap = obj.sourceMap;
  42749. /*
  42750. If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
  42751. and there is no publicPath defined then lets turn convertToAbsoluteUrls
  42752. on by default. Otherwise default to the convertToAbsoluteUrls option
  42753. directly
  42754. */
  42755. var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
  42756. if (options.convertToAbsoluteUrls || autoFixUrls) {
  42757. css = fixUrls(css);
  42758. }
  42759. if (sourceMap) {
  42760. // http://stackoverflow.com/a/26603875
  42761. css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
  42762. }
  42763. var blob = new Blob([css], { type: "text/css" });
  42764. var oldSrc = link.href;
  42765. link.href = URL.createObjectURL(blob);
  42766. if(oldSrc) URL.revokeObjectURL(oldSrc);
  42767. }
  42768. /***/ }),
  42769. /***/ "./node_modules/style-loader/lib/urls.js":
  42770. /*!***********************************************!*\
  42771. !*** ./node_modules/style-loader/lib/urls.js ***!
  42772. \***********************************************/
  42773. /*! no static exports found */
  42774. /***/ (function(module, exports) {
  42775. /**
  42776. * When source maps are enabled, `style-loader` uses a link element with a data-uri to
  42777. * embed the css on the page. This breaks all relative urls because now they are relative to a
  42778. * bundle instead of the current page.
  42779. *
  42780. * One solution is to only use full urls, but that may be impossible.
  42781. *
  42782. * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
  42783. *
  42784. * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
  42785. *
  42786. */
  42787. module.exports = function (css) {
  42788. // get current location
  42789. var location = typeof window !== "undefined" && window.location;
  42790. if (!location) {
  42791. throw new Error("fixUrls requires window.location");
  42792. }
  42793. // blank or null?
  42794. if (!css || typeof css !== "string") {
  42795. return css;
  42796. }
  42797. var baseUrl = location.protocol + "//" + location.host;
  42798. var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
  42799. // convert each url(...)
  42800. /*
  42801. This regular expression is just a way to recursively match brackets within
  42802. a string.
  42803. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
  42804. ( = Start a capturing group
  42805. (?: = Start a non-capturing group
  42806. [^)(] = Match anything that isn't a parentheses
  42807. | = OR
  42808. \( = Match a start parentheses
  42809. (?: = Start another non-capturing groups
  42810. [^)(]+ = Match anything that isn't a parentheses
  42811. | = OR
  42812. \( = Match a start parentheses
  42813. [^)(]* = Match anything that isn't a parentheses
  42814. \) = Match a end parentheses
  42815. ) = End Group
  42816. *\) = Match anything and then a close parens
  42817. ) = Close non-capturing group
  42818. * = Match anything
  42819. ) = Close capturing group
  42820. \) = Match a close parens
  42821. /gi = Get all matches, not the first. Be case insensitive.
  42822. */
  42823. var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
  42824. // strip quotes (if they exist)
  42825. var unquotedOrigUrl = origUrl
  42826. .trim()
  42827. .replace(/^"(.*)"$/, function(o, $1){ return $1; })
  42828. .replace(/^'(.*)'$/, function(o, $1){ return $1; });
  42829. // already a full url? no change
  42830. if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
  42831. return fullMatch;
  42832. }
  42833. // convert the url to a full url
  42834. var newUrl;
  42835. if (unquotedOrigUrl.indexOf("//") === 0) {
  42836. //TODO: should we add protocol?
  42837. newUrl = unquotedOrigUrl;
  42838. } else if (unquotedOrigUrl.indexOf("/") === 0) {
  42839. // path should be relative to the base url
  42840. newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
  42841. } else {
  42842. // path should be relative to current directory
  42843. newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
  42844. }
  42845. // send back the fixed url(...)
  42846. return "url(" + JSON.stringify(newUrl) + ")";
  42847. });
  42848. // send back the fixed css
  42849. return fixedCss;
  42850. };
  42851. /***/ }),
  42852. /***/ "./node_modules/timers-browserify/main.js":
  42853. /*!************************************************!*\
  42854. !*** ./node_modules/timers-browserify/main.js ***!
  42855. \************************************************/
  42856. /*! no static exports found */
  42857. /***/ (function(module, exports, __webpack_require__) {
  42858. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  42859. (typeof self !== "undefined" && self) ||
  42860. window;
  42861. var apply = Function.prototype.apply;
  42862. // DOM APIs, for completeness
  42863. exports.setTimeout = function() {
  42864. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  42865. };
  42866. exports.setInterval = function() {
  42867. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  42868. };
  42869. exports.clearTimeout =
  42870. exports.clearInterval = function(timeout) {
  42871. if (timeout) {
  42872. timeout.close();
  42873. }
  42874. };
  42875. function Timeout(id, clearFn) {
  42876. this._id = id;
  42877. this._clearFn = clearFn;
  42878. }
  42879. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  42880. Timeout.prototype.close = function() {
  42881. this._clearFn.call(scope, this._id);
  42882. };
  42883. // Does not start the time, just sets up the members needed.
  42884. exports.enroll = function(item, msecs) {
  42885. clearTimeout(item._idleTimeoutId);
  42886. item._idleTimeout = msecs;
  42887. };
  42888. exports.unenroll = function(item) {
  42889. clearTimeout(item._idleTimeoutId);
  42890. item._idleTimeout = -1;
  42891. };
  42892. exports._unrefActive = exports.active = function(item) {
  42893. clearTimeout(item._idleTimeoutId);
  42894. var msecs = item._idleTimeout;
  42895. if (msecs >= 0) {
  42896. item._idleTimeoutId = setTimeout(function onTimeout() {
  42897. if (item._onTimeout)
  42898. item._onTimeout();
  42899. }, msecs);
  42900. }
  42901. };
  42902. // setimmediate attaches itself to the global object
  42903. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  42904. // On some exotic environments, it's not clear which object `setimmediate` was
  42905. // able to install onto. Search each possibility in the same order as the
  42906. // `setimmediate` library.
  42907. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  42908. (typeof global !== "undefined" && global.setImmediate) ||
  42909. (this && this.setImmediate);
  42910. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  42911. (typeof global !== "undefined" && global.clearImmediate) ||
  42912. (this && this.clearImmediate);
  42913. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  42914. /***/ }),
  42915. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/App.vue?vue&type=template&id=91ac6b5c&":
  42916. /*!*************************************************************************************************************************************************************************************************!*\
  42917. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/App.vue?vue&type=template&id=91ac6b5c& ***!
  42918. \*************************************************************************************************************************************************************************************************/
  42919. /*! exports provided: render, staticRenderFns */
  42920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42921. "use strict";
  42922. __webpack_require__.r(__webpack_exports__);
  42923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42925. var render = function() {
  42926. var _vm = this
  42927. var _h = _vm.$createElement
  42928. var _c = _vm._self._c || _h
  42929. return _c("div", [
  42930. _c(
  42931. "nav",
  42932. {
  42933. staticClass:
  42934. "navbar navbar-expand navbar-dark bg-primary text-light shadow-sm"
  42935. },
  42936. [
  42937. _c(
  42938. "div",
  42939. { staticClass: "container-fluid" },
  42940. [
  42941. _c(
  42942. "router-link",
  42943. { staticClass: "navbar-brand", attrs: { to: { name: "home" } } },
  42944. [_vm._v("\n UPCCRT\n ")]
  42945. ),
  42946. _vm._v(" "),
  42947. _vm._m(0),
  42948. _vm._v(" "),
  42949. _vm._m(1)
  42950. ],
  42951. 1
  42952. )
  42953. ]
  42954. ),
  42955. _vm._v(" "),
  42956. _c("main", { staticClass: "py-4" }, [_c("router-view")], 1)
  42957. ])
  42958. }
  42959. var staticRenderFns = [
  42960. function() {
  42961. var _vm = this
  42962. var _h = _vm.$createElement
  42963. var _c = _vm._self._c || _h
  42964. return _c(
  42965. "button",
  42966. {
  42967. staticClass: "navbar-toggler",
  42968. attrs: {
  42969. type: "button",
  42970. "data-toggle": "collapse",
  42971. "data-target": "#navbarSupportedContent",
  42972. "aria-controls": "navbarSupportedContent",
  42973. "aria-expanded": "false"
  42974. }
  42975. },
  42976. [_c("span", { staticClass: "navbar-toggler-icon" })]
  42977. )
  42978. },
  42979. function() {
  42980. var _vm = this
  42981. var _h = _vm.$createElement
  42982. var _c = _vm._self._c || _h
  42983. return _c(
  42984. "div",
  42985. {
  42986. staticClass: "collapse navbar-collapse",
  42987. attrs: { id: "navbarSupportedContent" }
  42988. },
  42989. [
  42990. _c("ul", { staticClass: "navbar-nav mr-auto text-center" }, [
  42991. _c("li", { staticClass: "nav-item" }, [
  42992. _c("a", { staticClass: "nav-link", attrs: { href: "#" } }, [
  42993. _c("i", { staticClass: "fas fa-sign-in-alt" }),
  42994. _vm._v(" "),
  42995. _c("span", { staticClass: "d-none d-sm-block d-md-inline" }, [
  42996. _vm._v("Check-In")
  42997. ])
  42998. ])
  42999. ]),
  43000. _vm._v(" "),
  43001. _c("li", { staticClass: "nav-item" }, [
  43002. _c("a", { staticClass: "nav-link", attrs: { href: "#" } }, [
  43003. _c("i", { staticClass: "fas fa-sign-out-alt" }),
  43004. _vm._v(" "),
  43005. _c("span", { staticClass: "d-none d-sm-block d-md-inline" }, [
  43006. _vm._v("Check-Out")
  43007. ])
  43008. ])
  43009. ]),
  43010. _vm._v(" "),
  43011. _c("li", { staticClass: "nav-item" }, [
  43012. _c("a", { staticClass: "nav-link", attrs: { href: "#" } }, [
  43013. _c("i", { staticClass: "fas fa-tachometer-alt" }),
  43014. _vm._v(" "),
  43015. _c("span", { staticClass: "d-none d-sm-block d-md-inline" }, [
  43016. _vm._v("Dashboard")
  43017. ])
  43018. ])
  43019. ]),
  43020. _vm._v(" "),
  43021. _c("li", { staticClass: "nav-item" }, [
  43022. _c("a", { staticClass: "nav-link", attrs: { href: "#" } }, [
  43023. _c("i", { staticClass: "fas fa-chart-bar" }),
  43024. _vm._v(" "),
  43025. _c("span", { staticClass: "d-none d-sm-block d-md-inline" }, [
  43026. _vm._v("Reports")
  43027. ])
  43028. ])
  43029. ])
  43030. ]),
  43031. _vm._v(" "),
  43032. _c("ul", { staticClass: "navbar-nav ml-auto" })
  43033. ]
  43034. )
  43035. }
  43036. ]
  43037. render._withStripped = true
  43038. /***/ }),
  43039. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true&":
  43040. /*!*****************************************************************************************************************************************************************************************************************!*\
  43041. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true& ***!
  43042. \*****************************************************************************************************************************************************************************************************************/
  43043. /*! exports provided: render, staticRenderFns */
  43044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43045. "use strict";
  43046. __webpack_require__.r(__webpack_exports__);
  43047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  43048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  43049. var render = function() {
  43050. var _vm = this
  43051. var _h = _vm.$createElement
  43052. var _c = _vm._self._c || _h
  43053. return _vm._m(0)
  43054. }
  43055. var staticRenderFns = [
  43056. function() {
  43057. var _vm = this
  43058. var _h = _vm.$createElement
  43059. var _c = _vm._self._c || _h
  43060. return _c("div", { staticClass: "flex-center position-ref full-height" }, [
  43061. _c("div", { staticClass: "content" }, [
  43062. _c("div", { staticClass: "m-b-md" }, [
  43063. _c("h2", { staticClass: "title m-b-md" }, [
  43064. _vm._v("\n UPCCRT\n ")
  43065. ]),
  43066. _vm._v(" "),
  43067. _c("h3", [
  43068. _vm._v(
  43069. "\n University PC Care Repair Tracker\n "
  43070. )
  43071. ])
  43072. ])
  43073. ])
  43074. ])
  43075. }
  43076. ]
  43077. render._withStripped = true
  43078. /***/ }),
  43079. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  43080. /*!********************************************************************!*\
  43081. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  43082. \********************************************************************/
  43083. /*! exports provided: default */
  43084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43085. "use strict";
  43086. __webpack_require__.r(__webpack_exports__);
  43087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  43088. /* globals __VUE_SSR_CONTEXT__ */
  43089. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  43090. // This module is a runtime utility for cleaner component module output and will
  43091. // be included in the final webpack user bundle.
  43092. function normalizeComponent (
  43093. scriptExports,
  43094. render,
  43095. staticRenderFns,
  43096. functionalTemplate,
  43097. injectStyles,
  43098. scopeId,
  43099. moduleIdentifier, /* server only */
  43100. shadowMode /* vue-cli only */
  43101. ) {
  43102. // Vue.extend constructor export interop
  43103. var options = typeof scriptExports === 'function'
  43104. ? scriptExports.options
  43105. : scriptExports
  43106. // render functions
  43107. if (render) {
  43108. options.render = render
  43109. options.staticRenderFns = staticRenderFns
  43110. options._compiled = true
  43111. }
  43112. // functional template
  43113. if (functionalTemplate) {
  43114. options.functional = true
  43115. }
  43116. // scopedId
  43117. if (scopeId) {
  43118. options._scopeId = 'data-v-' + scopeId
  43119. }
  43120. var hook
  43121. if (moduleIdentifier) { // server build
  43122. hook = function (context) {
  43123. // 2.3 injection
  43124. context =
  43125. context || // cached call
  43126. (this.$vnode && this.$vnode.ssrContext) || // stateful
  43127. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  43128. // 2.2 with runInNewContext: true
  43129. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  43130. context = __VUE_SSR_CONTEXT__
  43131. }
  43132. // inject component styles
  43133. if (injectStyles) {
  43134. injectStyles.call(this, context)
  43135. }
  43136. // register component module identifier for async chunk inferrence
  43137. if (context && context._registeredComponents) {
  43138. context._registeredComponents.add(moduleIdentifier)
  43139. }
  43140. }
  43141. // used by ssr in case component is cached and beforeCreate
  43142. // never gets called
  43143. options._ssrRegister = hook
  43144. } else if (injectStyles) {
  43145. hook = shadowMode
  43146. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  43147. : injectStyles
  43148. }
  43149. if (hook) {
  43150. if (options.functional) {
  43151. // for template-only hot-reload because in that case the render fn doesn't
  43152. // go through the normalizer
  43153. options._injectStyles = hook
  43154. // register for functioal component in vue file
  43155. var originalRender = options.render
  43156. options.render = function renderWithStyleInjection (h, context) {
  43157. hook.call(context)
  43158. return originalRender(h, context)
  43159. }
  43160. } else {
  43161. // inject component registration as beforeCreate hook
  43162. var existing = options.beforeCreate
  43163. options.beforeCreate = existing
  43164. ? [].concat(existing, hook)
  43165. : [hook]
  43166. }
  43167. }
  43168. return {
  43169. exports: scriptExports,
  43170. options: options
  43171. }
  43172. }
  43173. /***/ }),
  43174. /***/ "./node_modules/vue-router/dist/vue-router.esm.js":
  43175. /*!********************************************************!*\
  43176. !*** ./node_modules/vue-router/dist/vue-router.esm.js ***!
  43177. \********************************************************/
  43178. /*! exports provided: default */
  43179. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43180. "use strict";
  43181. __webpack_require__.r(__webpack_exports__);
  43182. /*!
  43183. * vue-router v3.1.6
  43184. * (c) 2020 Evan You
  43185. * @license MIT
  43186. */
  43187. /* */
  43188. function assert (condition, message) {
  43189. if (!condition) {
  43190. throw new Error(("[vue-router] " + message))
  43191. }
  43192. }
  43193. function warn (condition, message) {
  43194. if ( true && !condition) {
  43195. typeof console !== 'undefined' && console.warn(("[vue-router] " + message));
  43196. }
  43197. }
  43198. function isError (err) {
  43199. return Object.prototype.toString.call(err).indexOf('Error') > -1
  43200. }
  43201. function isExtendedError (constructor, err) {
  43202. return (
  43203. err instanceof constructor ||
  43204. // _name is to support IE9 too
  43205. (err && (err.name === constructor.name || err._name === constructor._name))
  43206. )
  43207. }
  43208. function extend (a, b) {
  43209. for (var key in b) {
  43210. a[key] = b[key];
  43211. }
  43212. return a
  43213. }
  43214. var View = {
  43215. name: 'RouterView',
  43216. functional: true,
  43217. props: {
  43218. name: {
  43219. type: String,
  43220. default: 'default'
  43221. }
  43222. },
  43223. render: function render (_, ref) {
  43224. var props = ref.props;
  43225. var children = ref.children;
  43226. var parent = ref.parent;
  43227. var data = ref.data;
  43228. // used by devtools to display a router-view badge
  43229. data.routerView = true;
  43230. // directly use parent context's createElement() function
  43231. // so that components rendered by router-view can resolve named slots
  43232. var h = parent.$createElement;
  43233. var name = props.name;
  43234. var route = parent.$route;
  43235. var cache = parent._routerViewCache || (parent._routerViewCache = {});
  43236. // determine current view depth, also check to see if the tree
  43237. // has been toggled inactive but kept-alive.
  43238. var depth = 0;
  43239. var inactive = false;
  43240. while (parent && parent._routerRoot !== parent) {
  43241. var vnodeData = parent.$vnode ? parent.$vnode.data : {};
  43242. if (vnodeData.routerView) {
  43243. depth++;
  43244. }
  43245. if (vnodeData.keepAlive && parent._directInactive && parent._inactive) {
  43246. inactive = true;
  43247. }
  43248. parent = parent.$parent;
  43249. }
  43250. data.routerViewDepth = depth;
  43251. // render previous view if the tree is inactive and kept-alive
  43252. if (inactive) {
  43253. var cachedData = cache[name];
  43254. var cachedComponent = cachedData && cachedData.component;
  43255. if (cachedComponent) {
  43256. // #2301
  43257. // pass props
  43258. if (cachedData.configProps) {
  43259. fillPropsinData(cachedComponent, data, cachedData.route, cachedData.configProps);
  43260. }
  43261. return h(cachedComponent, data, children)
  43262. } else {
  43263. // render previous empty view
  43264. return h()
  43265. }
  43266. }
  43267. var matched = route.matched[depth];
  43268. var component = matched && matched.components[name];
  43269. // render empty node if no matched route or no config component
  43270. if (!matched || !component) {
  43271. cache[name] = null;
  43272. return h()
  43273. }
  43274. // cache component
  43275. cache[name] = { component: component };
  43276. // attach instance registration hook
  43277. // this will be called in the instance's injected lifecycle hooks
  43278. data.registerRouteInstance = function (vm, val) {
  43279. // val could be undefined for unregistration
  43280. var current = matched.instances[name];
  43281. if (
  43282. (val && current !== vm) ||
  43283. (!val && current === vm)
  43284. ) {
  43285. matched.instances[name] = val;
  43286. }
  43287. }
  43288. // also register instance in prepatch hook
  43289. // in case the same component instance is reused across different routes
  43290. ;(data.hook || (data.hook = {})).prepatch = function (_, vnode) {
  43291. matched.instances[name] = vnode.componentInstance;
  43292. };
  43293. // register instance in init hook
  43294. // in case kept-alive component be actived when routes changed
  43295. data.hook.init = function (vnode) {
  43296. if (vnode.data.keepAlive &&
  43297. vnode.componentInstance &&
  43298. vnode.componentInstance !== matched.instances[name]
  43299. ) {
  43300. matched.instances[name] = vnode.componentInstance;
  43301. }
  43302. };
  43303. var configProps = matched.props && matched.props[name];
  43304. // save route and configProps in cachce
  43305. if (configProps) {
  43306. extend(cache[name], {
  43307. route: route,
  43308. configProps: configProps
  43309. });
  43310. fillPropsinData(component, data, route, configProps);
  43311. }
  43312. return h(component, data, children)
  43313. }
  43314. };
  43315. function fillPropsinData (component, data, route, configProps) {
  43316. // resolve props
  43317. var propsToPass = data.props = resolveProps(route, configProps);
  43318. if (propsToPass) {
  43319. // clone to prevent mutation
  43320. propsToPass = data.props = extend({}, propsToPass);
  43321. // pass non-declared props as attrs
  43322. var attrs = data.attrs = data.attrs || {};
  43323. for (var key in propsToPass) {
  43324. if (!component.props || !(key in component.props)) {
  43325. attrs[key] = propsToPass[key];
  43326. delete propsToPass[key];
  43327. }
  43328. }
  43329. }
  43330. }
  43331. function resolveProps (route, config) {
  43332. switch (typeof config) {
  43333. case 'undefined':
  43334. return
  43335. case 'object':
  43336. return config
  43337. case 'function':
  43338. return config(route)
  43339. case 'boolean':
  43340. return config ? route.params : undefined
  43341. default:
  43342. if (true) {
  43343. warn(
  43344. false,
  43345. "props in \"" + (route.path) + "\" is a " + (typeof config) + ", " +
  43346. "expecting an object, function or boolean."
  43347. );
  43348. }
  43349. }
  43350. }
  43351. /* */
  43352. var encodeReserveRE = /[!'()*]/g;
  43353. var encodeReserveReplacer = function (c) { return '%' + c.charCodeAt(0).toString(16); };
  43354. var commaRE = /%2C/g;
  43355. // fixed encodeURIComponent which is more conformant to RFC3986:
  43356. // - escapes [!'()*]
  43357. // - preserve commas
  43358. var encode = function (str) { return encodeURIComponent(str)
  43359. .replace(encodeReserveRE, encodeReserveReplacer)
  43360. .replace(commaRE, ','); };
  43361. var decode = decodeURIComponent;
  43362. function resolveQuery (
  43363. query,
  43364. extraQuery,
  43365. _parseQuery
  43366. ) {
  43367. if ( extraQuery === void 0 ) extraQuery = {};
  43368. var parse = _parseQuery || parseQuery;
  43369. var parsedQuery;
  43370. try {
  43371. parsedQuery = parse(query || '');
  43372. } catch (e) {
  43373. true && warn(false, e.message);
  43374. parsedQuery = {};
  43375. }
  43376. for (var key in extraQuery) {
  43377. parsedQuery[key] = extraQuery[key];
  43378. }
  43379. return parsedQuery
  43380. }
  43381. function parseQuery (query) {
  43382. var res = {};
  43383. query = query.trim().replace(/^(\?|#|&)/, '');
  43384. if (!query) {
  43385. return res
  43386. }
  43387. query.split('&').forEach(function (param) {
  43388. var parts = param.replace(/\+/g, ' ').split('=');
  43389. var key = decode(parts.shift());
  43390. var val = parts.length > 0
  43391. ? decode(parts.join('='))
  43392. : null;
  43393. if (res[key] === undefined) {
  43394. res[key] = val;
  43395. } else if (Array.isArray(res[key])) {
  43396. res[key].push(val);
  43397. } else {
  43398. res[key] = [res[key], val];
  43399. }
  43400. });
  43401. return res
  43402. }
  43403. function stringifyQuery (obj) {
  43404. var res = obj ? Object.keys(obj).map(function (key) {
  43405. var val = obj[key];
  43406. if (val === undefined) {
  43407. return ''
  43408. }
  43409. if (val === null) {
  43410. return encode(key)
  43411. }
  43412. if (Array.isArray(val)) {
  43413. var result = [];
  43414. val.forEach(function (val2) {
  43415. if (val2 === undefined) {
  43416. return
  43417. }
  43418. if (val2 === null) {
  43419. result.push(encode(key));
  43420. } else {
  43421. result.push(encode(key) + '=' + encode(val2));
  43422. }
  43423. });
  43424. return result.join('&')
  43425. }
  43426. return encode(key) + '=' + encode(val)
  43427. }).filter(function (x) { return x.length > 0; }).join('&') : null;
  43428. return res ? ("?" + res) : ''
  43429. }
  43430. /* */
  43431. var trailingSlashRE = /\/?$/;
  43432. function createRoute (
  43433. record,
  43434. location,
  43435. redirectedFrom,
  43436. router
  43437. ) {
  43438. var stringifyQuery = router && router.options.stringifyQuery;
  43439. var query = location.query || {};
  43440. try {
  43441. query = clone(query);
  43442. } catch (e) {}
  43443. var route = {
  43444. name: location.name || (record && record.name),
  43445. meta: (record && record.meta) || {},
  43446. path: location.path || '/',
  43447. hash: location.hash || '',
  43448. query: query,
  43449. params: location.params || {},
  43450. fullPath: getFullPath(location, stringifyQuery),
  43451. matched: record ? formatMatch(record) : []
  43452. };
  43453. if (redirectedFrom) {
  43454. route.redirectedFrom = getFullPath(redirectedFrom, stringifyQuery);
  43455. }
  43456. return Object.freeze(route)
  43457. }
  43458. function clone (value) {
  43459. if (Array.isArray(value)) {
  43460. return value.map(clone)
  43461. } else if (value && typeof value === 'object') {
  43462. var res = {};
  43463. for (var key in value) {
  43464. res[key] = clone(value[key]);
  43465. }
  43466. return res
  43467. } else {
  43468. return value
  43469. }
  43470. }
  43471. // the starting route that represents the initial state
  43472. var START = createRoute(null, {
  43473. path: '/'
  43474. });
  43475. function formatMatch (record) {
  43476. var res = [];
  43477. while (record) {
  43478. res.unshift(record);
  43479. record = record.parent;
  43480. }
  43481. return res
  43482. }
  43483. function getFullPath (
  43484. ref,
  43485. _stringifyQuery
  43486. ) {
  43487. var path = ref.path;
  43488. var query = ref.query; if ( query === void 0 ) query = {};
  43489. var hash = ref.hash; if ( hash === void 0 ) hash = '';
  43490. var stringify = _stringifyQuery || stringifyQuery;
  43491. return (path || '/') + stringify(query) + hash
  43492. }
  43493. function isSameRoute (a, b) {
  43494. if (b === START) {
  43495. return a === b
  43496. } else if (!b) {
  43497. return false
  43498. } else if (a.path && b.path) {
  43499. return (
  43500. a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') &&
  43501. a.hash === b.hash &&
  43502. isObjectEqual(a.query, b.query)
  43503. )
  43504. } else if (a.name && b.name) {
  43505. return (
  43506. a.name === b.name &&
  43507. a.hash === b.hash &&
  43508. isObjectEqual(a.query, b.query) &&
  43509. isObjectEqual(a.params, b.params)
  43510. )
  43511. } else {
  43512. return false
  43513. }
  43514. }
  43515. function isObjectEqual (a, b) {
  43516. if ( a === void 0 ) a = {};
  43517. if ( b === void 0 ) b = {};
  43518. // handle null value #1566
  43519. if (!a || !b) { return a === b }
  43520. var aKeys = Object.keys(a);
  43521. var bKeys = Object.keys(b);
  43522. if (aKeys.length !== bKeys.length) {
  43523. return false
  43524. }
  43525. return aKeys.every(function (key) {
  43526. var aVal = a[key];
  43527. var bVal = b[key];
  43528. // check nested equality
  43529. if (typeof aVal === 'object' && typeof bVal === 'object') {
  43530. return isObjectEqual(aVal, bVal)
  43531. }
  43532. return String(aVal) === String(bVal)
  43533. })
  43534. }
  43535. function isIncludedRoute (current, target) {
  43536. return (
  43537. current.path.replace(trailingSlashRE, '/').indexOf(
  43538. target.path.replace(trailingSlashRE, '/')
  43539. ) === 0 &&
  43540. (!target.hash || current.hash === target.hash) &&
  43541. queryIncludes(current.query, target.query)
  43542. )
  43543. }
  43544. function queryIncludes (current, target) {
  43545. for (var key in target) {
  43546. if (!(key in current)) {
  43547. return false
  43548. }
  43549. }
  43550. return true
  43551. }
  43552. /* */
  43553. function resolvePath (
  43554. relative,
  43555. base,
  43556. append
  43557. ) {
  43558. var firstChar = relative.charAt(0);
  43559. if (firstChar === '/') {
  43560. return relative
  43561. }
  43562. if (firstChar === '?' || firstChar === '#') {
  43563. return base + relative
  43564. }
  43565. var stack = base.split('/');
  43566. // remove trailing segment if:
  43567. // - not appending
  43568. // - appending to trailing slash (last segment is empty)
  43569. if (!append || !stack[stack.length - 1]) {
  43570. stack.pop();
  43571. }
  43572. // resolve relative path
  43573. var segments = relative.replace(/^\//, '').split('/');
  43574. for (var i = 0; i < segments.length; i++) {
  43575. var segment = segments[i];
  43576. if (segment === '..') {
  43577. stack.pop();
  43578. } else if (segment !== '.') {
  43579. stack.push(segment);
  43580. }
  43581. }
  43582. // ensure leading slash
  43583. if (stack[0] !== '') {
  43584. stack.unshift('');
  43585. }
  43586. return stack.join('/')
  43587. }
  43588. function parsePath (path) {
  43589. var hash = '';
  43590. var query = '';
  43591. var hashIndex = path.indexOf('#');
  43592. if (hashIndex >= 0) {
  43593. hash = path.slice(hashIndex);
  43594. path = path.slice(0, hashIndex);
  43595. }
  43596. var queryIndex = path.indexOf('?');
  43597. if (queryIndex >= 0) {
  43598. query = path.slice(queryIndex + 1);
  43599. path = path.slice(0, queryIndex);
  43600. }
  43601. return {
  43602. path: path,
  43603. query: query,
  43604. hash: hash
  43605. }
  43606. }
  43607. function cleanPath (path) {
  43608. return path.replace(/\/\//g, '/')
  43609. }
  43610. var isarray = Array.isArray || function (arr) {
  43611. return Object.prototype.toString.call(arr) == '[object Array]';
  43612. };
  43613. /**
  43614. * Expose `pathToRegexp`.
  43615. */
  43616. var pathToRegexp_1 = pathToRegexp;
  43617. var parse_1 = parse;
  43618. var compile_1 = compile;
  43619. var tokensToFunction_1 = tokensToFunction;
  43620. var tokensToRegExp_1 = tokensToRegExp;
  43621. /**
  43622. * The main path matching regexp utility.
  43623. *
  43624. * @type {RegExp}
  43625. */
  43626. var PATH_REGEXP = new RegExp([
  43627. // Match escaped characters that would otherwise appear in future matches.
  43628. // This allows the user to escape special characters that won't transform.
  43629. '(\\\\.)',
  43630. // Match Express-style parameters and un-named parameters with a prefix
  43631. // and optional suffixes. Matches appear as:
  43632. //
  43633. // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
  43634. // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
  43635. // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
  43636. '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
  43637. ].join('|'), 'g');
  43638. /**
  43639. * Parse a string for the raw tokens.
  43640. *
  43641. * @param {string} str
  43642. * @param {Object=} options
  43643. * @return {!Array}
  43644. */
  43645. function parse (str, options) {
  43646. var tokens = [];
  43647. var key = 0;
  43648. var index = 0;
  43649. var path = '';
  43650. var defaultDelimiter = options && options.delimiter || '/';
  43651. var res;
  43652. while ((res = PATH_REGEXP.exec(str)) != null) {
  43653. var m = res[0];
  43654. var escaped = res[1];
  43655. var offset = res.index;
  43656. path += str.slice(index, offset);
  43657. index = offset + m.length;
  43658. // Ignore already escaped sequences.
  43659. if (escaped) {
  43660. path += escaped[1];
  43661. continue
  43662. }
  43663. var next = str[index];
  43664. var prefix = res[2];
  43665. var name = res[3];
  43666. var capture = res[4];
  43667. var group = res[5];
  43668. var modifier = res[6];
  43669. var asterisk = res[7];
  43670. // Push the current path onto the tokens.
  43671. if (path) {
  43672. tokens.push(path);
  43673. path = '';
  43674. }
  43675. var partial = prefix != null && next != null && next !== prefix;
  43676. var repeat = modifier === '+' || modifier === '*';
  43677. var optional = modifier === '?' || modifier === '*';
  43678. var delimiter = res[2] || defaultDelimiter;
  43679. var pattern = capture || group;
  43680. tokens.push({
  43681. name: name || key++,
  43682. prefix: prefix || '',
  43683. delimiter: delimiter,
  43684. optional: optional,
  43685. repeat: repeat,
  43686. partial: partial,
  43687. asterisk: !!asterisk,
  43688. pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
  43689. });
  43690. }
  43691. // Match any characters still remaining.
  43692. if (index < str.length) {
  43693. path += str.substr(index);
  43694. }
  43695. // If the path exists, push it onto the end.
  43696. if (path) {
  43697. tokens.push(path);
  43698. }
  43699. return tokens
  43700. }
  43701. /**
  43702. * Compile a string to a template function for the path.
  43703. *
  43704. * @param {string} str
  43705. * @param {Object=} options
  43706. * @return {!function(Object=, Object=)}
  43707. */
  43708. function compile (str, options) {
  43709. return tokensToFunction(parse(str, options))
  43710. }
  43711. /**
  43712. * Prettier encoding of URI path segments.
  43713. *
  43714. * @param {string}
  43715. * @return {string}
  43716. */
  43717. function encodeURIComponentPretty (str) {
  43718. return encodeURI(str).replace(/[\/?#]/g, function (c) {
  43719. return '%' + c.charCodeAt(0).toString(16).toUpperCase()
  43720. })
  43721. }
  43722. /**
  43723. * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
  43724. *
  43725. * @param {string}
  43726. * @return {string}
  43727. */
  43728. function encodeAsterisk (str) {
  43729. return encodeURI(str).replace(/[?#]/g, function (c) {
  43730. return '%' + c.charCodeAt(0).toString(16).toUpperCase()
  43731. })
  43732. }
  43733. /**
  43734. * Expose a method for transforming tokens into the path function.
  43735. */
  43736. function tokensToFunction (tokens) {
  43737. // Compile all the tokens into regexps.
  43738. var matches = new Array(tokens.length);
  43739. // Compile all the patterns before compilation.
  43740. for (var i = 0; i < tokens.length; i++) {
  43741. if (typeof tokens[i] === 'object') {
  43742. matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
  43743. }
  43744. }
  43745. return function (obj, opts) {
  43746. var path = '';
  43747. var data = obj || {};
  43748. var options = opts || {};
  43749. var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
  43750. for (var i = 0; i < tokens.length; i++) {
  43751. var token = tokens[i];
  43752. if (typeof token === 'string') {
  43753. path += token;
  43754. continue
  43755. }
  43756. var value = data[token.name];
  43757. var segment;
  43758. if (value == null) {
  43759. if (token.optional) {
  43760. // Prepend partial segment prefixes.
  43761. if (token.partial) {
  43762. path += token.prefix;
  43763. }
  43764. continue
  43765. } else {
  43766. throw new TypeError('Expected "' + token.name + '" to be defined')
  43767. }
  43768. }
  43769. if (isarray(value)) {
  43770. if (!token.repeat) {
  43771. throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
  43772. }
  43773. if (value.length === 0) {
  43774. if (token.optional) {
  43775. continue
  43776. } else {
  43777. throw new TypeError('Expected "' + token.name + '" to not be empty')
  43778. }
  43779. }
  43780. for (var j = 0; j < value.length; j++) {
  43781. segment = encode(value[j]);
  43782. if (!matches[i].test(segment)) {
  43783. throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
  43784. }
  43785. path += (j === 0 ? token.prefix : token.delimiter) + segment;
  43786. }
  43787. continue
  43788. }
  43789. segment = token.asterisk ? encodeAsterisk(value) : encode(value);
  43790. if (!matches[i].test(segment)) {
  43791. throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
  43792. }
  43793. path += token.prefix + segment;
  43794. }
  43795. return path
  43796. }
  43797. }
  43798. /**
  43799. * Escape a regular expression string.
  43800. *
  43801. * @param {string} str
  43802. * @return {string}
  43803. */
  43804. function escapeString (str) {
  43805. return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
  43806. }
  43807. /**
  43808. * Escape the capturing group by escaping special characters and meaning.
  43809. *
  43810. * @param {string} group
  43811. * @return {string}
  43812. */
  43813. function escapeGroup (group) {
  43814. return group.replace(/([=!:$\/()])/g, '\\$1')
  43815. }
  43816. /**
  43817. * Attach the keys as a property of the regexp.
  43818. *
  43819. * @param {!RegExp} re
  43820. * @param {Array} keys
  43821. * @return {!RegExp}
  43822. */
  43823. function attachKeys (re, keys) {
  43824. re.keys = keys;
  43825. return re
  43826. }
  43827. /**
  43828. * Get the flags for a regexp from the options.
  43829. *
  43830. * @param {Object} options
  43831. * @return {string}
  43832. */
  43833. function flags (options) {
  43834. return options.sensitive ? '' : 'i'
  43835. }
  43836. /**
  43837. * Pull out keys from a regexp.
  43838. *
  43839. * @param {!RegExp} path
  43840. * @param {!Array} keys
  43841. * @return {!RegExp}
  43842. */
  43843. function regexpToRegexp (path, keys) {
  43844. // Use a negative lookahead to match only capturing groups.
  43845. var groups = path.source.match(/\((?!\?)/g);
  43846. if (groups) {
  43847. for (var i = 0; i < groups.length; i++) {
  43848. keys.push({
  43849. name: i,
  43850. prefix: null,
  43851. delimiter: null,
  43852. optional: false,
  43853. repeat: false,
  43854. partial: false,
  43855. asterisk: false,
  43856. pattern: null
  43857. });
  43858. }
  43859. }
  43860. return attachKeys(path, keys)
  43861. }
  43862. /**
  43863. * Transform an array into a regexp.
  43864. *
  43865. * @param {!Array} path
  43866. * @param {Array} keys
  43867. * @param {!Object} options
  43868. * @return {!RegExp}
  43869. */
  43870. function arrayToRegexp (path, keys, options) {
  43871. var parts = [];
  43872. for (var i = 0; i < path.length; i++) {
  43873. parts.push(pathToRegexp(path[i], keys, options).source);
  43874. }
  43875. var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
  43876. return attachKeys(regexp, keys)
  43877. }
  43878. /**
  43879. * Create a path regexp from string input.
  43880. *
  43881. * @param {string} path
  43882. * @param {!Array} keys
  43883. * @param {!Object} options
  43884. * @return {!RegExp}
  43885. */
  43886. function stringToRegexp (path, keys, options) {
  43887. return tokensToRegExp(parse(path, options), keys, options)
  43888. }
  43889. /**
  43890. * Expose a function for taking tokens and returning a RegExp.
  43891. *
  43892. * @param {!Array} tokens
  43893. * @param {(Array|Object)=} keys
  43894. * @param {Object=} options
  43895. * @return {!RegExp}
  43896. */
  43897. function tokensToRegExp (tokens, keys, options) {
  43898. if (!isarray(keys)) {
  43899. options = /** @type {!Object} */ (keys || options);
  43900. keys = [];
  43901. }
  43902. options = options || {};
  43903. var strict = options.strict;
  43904. var end = options.end !== false;
  43905. var route = '';
  43906. // Iterate over the tokens and create our regexp string.
  43907. for (var i = 0; i < tokens.length; i++) {
  43908. var token = tokens[i];
  43909. if (typeof token === 'string') {
  43910. route += escapeString(token);
  43911. } else {
  43912. var prefix = escapeString(token.prefix);
  43913. var capture = '(?:' + token.pattern + ')';
  43914. keys.push(token);
  43915. if (token.repeat) {
  43916. capture += '(?:' + prefix + capture + ')*';
  43917. }
  43918. if (token.optional) {
  43919. if (!token.partial) {
  43920. capture = '(?:' + prefix + '(' + capture + '))?';
  43921. } else {
  43922. capture = prefix + '(' + capture + ')?';
  43923. }
  43924. } else {
  43925. capture = prefix + '(' + capture + ')';
  43926. }
  43927. route += capture;
  43928. }
  43929. }
  43930. var delimiter = escapeString(options.delimiter || '/');
  43931. var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
  43932. // In non-strict mode we allow a slash at the end of match. If the path to
  43933. // match already ends with a slash, we remove it for consistency. The slash
  43934. // is valid at the end of a path match, not in the middle. This is important
  43935. // in non-ending mode, where "/test/" shouldn't match "/test//route".
  43936. if (!strict) {
  43937. route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
  43938. }
  43939. if (end) {
  43940. route += '$';
  43941. } else {
  43942. // In non-ending mode, we need the capturing groups to match as much as
  43943. // possible by using a positive lookahead to the end or next path segment.
  43944. route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
  43945. }
  43946. return attachKeys(new RegExp('^' + route, flags(options)), keys)
  43947. }
  43948. /**
  43949. * Normalize the given path string, returning a regular expression.
  43950. *
  43951. * An empty array can be passed in for the keys, which will hold the
  43952. * placeholder key descriptions. For example, using `/user/:id`, `keys` will
  43953. * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
  43954. *
  43955. * @param {(string|RegExp|Array)} path
  43956. * @param {(Array|Object)=} keys
  43957. * @param {Object=} options
  43958. * @return {!RegExp}
  43959. */
  43960. function pathToRegexp (path, keys, options) {
  43961. if (!isarray(keys)) {
  43962. options = /** @type {!Object} */ (keys || options);
  43963. keys = [];
  43964. }
  43965. options = options || {};
  43966. if (path instanceof RegExp) {
  43967. return regexpToRegexp(path, /** @type {!Array} */ (keys))
  43968. }
  43969. if (isarray(path)) {
  43970. return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)
  43971. }
  43972. return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
  43973. }
  43974. pathToRegexp_1.parse = parse_1;
  43975. pathToRegexp_1.compile = compile_1;
  43976. pathToRegexp_1.tokensToFunction = tokensToFunction_1;
  43977. pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
  43978. /* */
  43979. // $flow-disable-line
  43980. var regexpCompileCache = Object.create(null);
  43981. function fillParams (
  43982. path,
  43983. params,
  43984. routeMsg
  43985. ) {
  43986. params = params || {};
  43987. try {
  43988. var filler =
  43989. regexpCompileCache[path] ||
  43990. (regexpCompileCache[path] = pathToRegexp_1.compile(path));
  43991. // Fix #2505 resolving asterisk routes { name: 'not-found', params: { pathMatch: '/not-found' }}
  43992. // and fix #3106 so that you can work with location descriptor object having params.pathMatch equal to empty string
  43993. if (typeof params.pathMatch === 'string') { params[0] = params.pathMatch; }
  43994. return filler(params, { pretty: true })
  43995. } catch (e) {
  43996. if (true) {
  43997. // Fix #3072 no warn if `pathMatch` is string
  43998. warn(typeof params.pathMatch === 'string', ("missing param for " + routeMsg + ": " + (e.message)));
  43999. }
  44000. return ''
  44001. } finally {
  44002. // delete the 0 if it was added
  44003. delete params[0];
  44004. }
  44005. }
  44006. /* */
  44007. function normalizeLocation (
  44008. raw,
  44009. current,
  44010. append,
  44011. router
  44012. ) {
  44013. var next = typeof raw === 'string' ? { path: raw } : raw;
  44014. // named target
  44015. if (next._normalized) {
  44016. return next
  44017. } else if (next.name) {
  44018. next = extend({}, raw);
  44019. var params = next.params;
  44020. if (params && typeof params === 'object') {
  44021. next.params = extend({}, params);
  44022. }
  44023. return next
  44024. }
  44025. // relative params
  44026. if (!next.path && next.params && current) {
  44027. next = extend({}, next);
  44028. next._normalized = true;
  44029. var params$1 = extend(extend({}, current.params), next.params);
  44030. if (current.name) {
  44031. next.name = current.name;
  44032. next.params = params$1;
  44033. } else if (current.matched.length) {
  44034. var rawPath = current.matched[current.matched.length - 1].path;
  44035. next.path = fillParams(rawPath, params$1, ("path " + (current.path)));
  44036. } else if (true) {
  44037. warn(false, "relative params navigation requires a current route.");
  44038. }
  44039. return next
  44040. }
  44041. var parsedPath = parsePath(next.path || '');
  44042. var basePath = (current && current.path) || '/';
  44043. var path = parsedPath.path
  44044. ? resolvePath(parsedPath.path, basePath, append || next.append)
  44045. : basePath;
  44046. var query = resolveQuery(
  44047. parsedPath.query,
  44048. next.query,
  44049. router && router.options.parseQuery
  44050. );
  44051. var hash = next.hash || parsedPath.hash;
  44052. if (hash && hash.charAt(0) !== '#') {
  44053. hash = "#" + hash;
  44054. }
  44055. return {
  44056. _normalized: true,
  44057. path: path,
  44058. query: query,
  44059. hash: hash
  44060. }
  44061. }
  44062. /* */
  44063. // work around weird flow bug
  44064. var toTypes = [String, Object];
  44065. var eventTypes = [String, Array];
  44066. var noop = function () {};
  44067. var Link = {
  44068. name: 'RouterLink',
  44069. props: {
  44070. to: {
  44071. type: toTypes,
  44072. required: true
  44073. },
  44074. tag: {
  44075. type: String,
  44076. default: 'a'
  44077. },
  44078. exact: Boolean,
  44079. append: Boolean,
  44080. replace: Boolean,
  44081. activeClass: String,
  44082. exactActiveClass: String,
  44083. event: {
  44084. type: eventTypes,
  44085. default: 'click'
  44086. }
  44087. },
  44088. render: function render (h) {
  44089. var this$1 = this;
  44090. var router = this.$router;
  44091. var current = this.$route;
  44092. var ref = router.resolve(
  44093. this.to,
  44094. current,
  44095. this.append
  44096. );
  44097. var location = ref.location;
  44098. var route = ref.route;
  44099. var href = ref.href;
  44100. var classes = {};
  44101. var globalActiveClass = router.options.linkActiveClass;
  44102. var globalExactActiveClass = router.options.linkExactActiveClass;
  44103. // Support global empty active class
  44104. var activeClassFallback =
  44105. globalActiveClass == null ? 'router-link-active' : globalActiveClass;
  44106. var exactActiveClassFallback =
  44107. globalExactActiveClass == null
  44108. ? 'router-link-exact-active'
  44109. : globalExactActiveClass;
  44110. var activeClass =
  44111. this.activeClass == null ? activeClassFallback : this.activeClass;
  44112. var exactActiveClass =
  44113. this.exactActiveClass == null
  44114. ? exactActiveClassFallback
  44115. : this.exactActiveClass;
  44116. var compareTarget = route.redirectedFrom
  44117. ? createRoute(null, normalizeLocation(route.redirectedFrom), null, router)
  44118. : route;
  44119. classes[exactActiveClass] = isSameRoute(current, compareTarget);
  44120. classes[activeClass] = this.exact
  44121. ? classes[exactActiveClass]
  44122. : isIncludedRoute(current, compareTarget);
  44123. var handler = function (e) {
  44124. if (guardEvent(e)) {
  44125. if (this$1.replace) {
  44126. router.replace(location, noop);
  44127. } else {
  44128. router.push(location, noop);
  44129. }
  44130. }
  44131. };
  44132. var on = { click: guardEvent };
  44133. if (Array.isArray(this.event)) {
  44134. this.event.forEach(function (e) {
  44135. on[e] = handler;
  44136. });
  44137. } else {
  44138. on[this.event] = handler;
  44139. }
  44140. var data = { class: classes };
  44141. var scopedSlot =
  44142. !this.$scopedSlots.$hasNormal &&
  44143. this.$scopedSlots.default &&
  44144. this.$scopedSlots.default({
  44145. href: href,
  44146. route: route,
  44147. navigate: handler,
  44148. isActive: classes[activeClass],
  44149. isExactActive: classes[exactActiveClass]
  44150. });
  44151. if (scopedSlot) {
  44152. if (scopedSlot.length === 1) {
  44153. return scopedSlot[0]
  44154. } else if (scopedSlot.length > 1 || !scopedSlot.length) {
  44155. if (true) {
  44156. warn(
  44157. false,
  44158. ("RouterLink with to=\"" + (this.to) + "\" is trying to use a scoped slot but it didn't provide exactly one child. Wrapping the content with a span element.")
  44159. );
  44160. }
  44161. return scopedSlot.length === 0 ? h() : h('span', {}, scopedSlot)
  44162. }
  44163. }
  44164. if (this.tag === 'a') {
  44165. data.on = on;
  44166. data.attrs = { href: href };
  44167. } else {
  44168. // find the first <a> child and apply listener and href
  44169. var a = findAnchor(this.$slots.default);
  44170. if (a) {
  44171. // in case the <a> is a static node
  44172. a.isStatic = false;
  44173. var aData = (a.data = extend({}, a.data));
  44174. aData.on = aData.on || {};
  44175. // transform existing events in both objects into arrays so we can push later
  44176. for (var event in aData.on) {
  44177. var handler$1 = aData.on[event];
  44178. if (event in on) {
  44179. aData.on[event] = Array.isArray(handler$1) ? handler$1 : [handler$1];
  44180. }
  44181. }
  44182. // append new listeners for router-link
  44183. for (var event$1 in on) {
  44184. if (event$1 in aData.on) {
  44185. // on[event] is always a function
  44186. aData.on[event$1].push(on[event$1]);
  44187. } else {
  44188. aData.on[event$1] = handler;
  44189. }
  44190. }
  44191. var aAttrs = (a.data.attrs = extend({}, a.data.attrs));
  44192. aAttrs.href = href;
  44193. } else {
  44194. // doesn't have <a> child, apply listener to self
  44195. data.on = on;
  44196. }
  44197. }
  44198. return h(this.tag, data, this.$slots.default)
  44199. }
  44200. };
  44201. function guardEvent (e) {
  44202. // don't redirect with control keys
  44203. if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) { return }
  44204. // don't redirect when preventDefault called
  44205. if (e.defaultPrevented) { return }
  44206. // don't redirect on right click
  44207. if (e.button !== undefined && e.button !== 0) { return }
  44208. // don't redirect if `target="_blank"`
  44209. if (e.currentTarget && e.currentTarget.getAttribute) {
  44210. var target = e.currentTarget.getAttribute('target');
  44211. if (/\b_blank\b/i.test(target)) { return }
  44212. }
  44213. // this may be a Weex event which doesn't have this method
  44214. if (e.preventDefault) {
  44215. e.preventDefault();
  44216. }
  44217. return true
  44218. }
  44219. function findAnchor (children) {
  44220. if (children) {
  44221. var child;
  44222. for (var i = 0; i < children.length; i++) {
  44223. child = children[i];
  44224. if (child.tag === 'a') {
  44225. return child
  44226. }
  44227. if (child.children && (child = findAnchor(child.children))) {
  44228. return child
  44229. }
  44230. }
  44231. }
  44232. }
  44233. var _Vue;
  44234. function install (Vue) {
  44235. if (install.installed && _Vue === Vue) { return }
  44236. install.installed = true;
  44237. _Vue = Vue;
  44238. var isDef = function (v) { return v !== undefined; };
  44239. var registerInstance = function (vm, callVal) {
  44240. var i = vm.$options._parentVnode;
  44241. if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) {
  44242. i(vm, callVal);
  44243. }
  44244. };
  44245. Vue.mixin({
  44246. beforeCreate: function beforeCreate () {
  44247. if (isDef(this.$options.router)) {
  44248. this._routerRoot = this;
  44249. this._router = this.$options.router;
  44250. this._router.init(this);
  44251. Vue.util.defineReactive(this, '_route', this._router.history.current);
  44252. } else {
  44253. this._routerRoot = (this.$parent && this.$parent._routerRoot) || this;
  44254. }
  44255. registerInstance(this, this);
  44256. },
  44257. destroyed: function destroyed () {
  44258. registerInstance(this);
  44259. }
  44260. });
  44261. Object.defineProperty(Vue.prototype, '$router', {
  44262. get: function get () { return this._routerRoot._router }
  44263. });
  44264. Object.defineProperty(Vue.prototype, '$route', {
  44265. get: function get () { return this._routerRoot._route }
  44266. });
  44267. Vue.component('RouterView', View);
  44268. Vue.component('RouterLink', Link);
  44269. var strats = Vue.config.optionMergeStrategies;
  44270. // use the same hook merging strategy for route hooks
  44271. strats.beforeRouteEnter = strats.beforeRouteLeave = strats.beforeRouteUpdate = strats.created;
  44272. }
  44273. /* */
  44274. var inBrowser = typeof window !== 'undefined';
  44275. /* */
  44276. function createRouteMap (
  44277. routes,
  44278. oldPathList,
  44279. oldPathMap,
  44280. oldNameMap
  44281. ) {
  44282. // the path list is used to control path matching priority
  44283. var pathList = oldPathList || [];
  44284. // $flow-disable-line
  44285. var pathMap = oldPathMap || Object.create(null);
  44286. // $flow-disable-line
  44287. var nameMap = oldNameMap || Object.create(null);
  44288. routes.forEach(function (route) {
  44289. addRouteRecord(pathList, pathMap, nameMap, route);
  44290. });
  44291. // ensure wildcard routes are always at the end
  44292. for (var i = 0, l = pathList.length; i < l; i++) {
  44293. if (pathList[i] === '*') {
  44294. pathList.push(pathList.splice(i, 1)[0]);
  44295. l--;
  44296. i--;
  44297. }
  44298. }
  44299. if (true) {
  44300. // warn if routes do not include leading slashes
  44301. var found = pathList
  44302. // check for missing leading slash
  44303. .filter(function (path) { return path && path.charAt(0) !== '*' && path.charAt(0) !== '/'; });
  44304. if (found.length > 0) {
  44305. var pathNames = found.map(function (path) { return ("- " + path); }).join('\n');
  44306. warn(false, ("Non-nested routes must include a leading slash character. Fix the following routes: \n" + pathNames));
  44307. }
  44308. }
  44309. return {
  44310. pathList: pathList,
  44311. pathMap: pathMap,
  44312. nameMap: nameMap
  44313. }
  44314. }
  44315. function addRouteRecord (
  44316. pathList,
  44317. pathMap,
  44318. nameMap,
  44319. route,
  44320. parent,
  44321. matchAs
  44322. ) {
  44323. var path = route.path;
  44324. var name = route.name;
  44325. if (true) {
  44326. assert(path != null, "\"path\" is required in a route configuration.");
  44327. assert(
  44328. typeof route.component !== 'string',
  44329. "route config \"component\" for path: " + (String(
  44330. path || name
  44331. )) + " cannot be a " + "string id. Use an actual component instead."
  44332. );
  44333. }
  44334. var pathToRegexpOptions =
  44335. route.pathToRegexpOptions || {};
  44336. var normalizedPath = normalizePath(path, parent, pathToRegexpOptions.strict);
  44337. if (typeof route.caseSensitive === 'boolean') {
  44338. pathToRegexpOptions.sensitive = route.caseSensitive;
  44339. }
  44340. var record = {
  44341. path: normalizedPath,
  44342. regex: compileRouteRegex(normalizedPath, pathToRegexpOptions),
  44343. components: route.components || { default: route.component },
  44344. instances: {},
  44345. name: name,
  44346. parent: parent,
  44347. matchAs: matchAs,
  44348. redirect: route.redirect,
  44349. beforeEnter: route.beforeEnter,
  44350. meta: route.meta || {},
  44351. props:
  44352. route.props == null
  44353. ? {}
  44354. : route.components
  44355. ? route.props
  44356. : { default: route.props }
  44357. };
  44358. if (route.children) {
  44359. // Warn if route is named, does not redirect and has a default child route.
  44360. // If users navigate to this route by name, the default child will
  44361. // not be rendered (GH Issue #629)
  44362. if (true) {
  44363. if (
  44364. route.name &&
  44365. !route.redirect &&
  44366. route.children.some(function (child) { return /^\/?$/.test(child.path); })
  44367. ) {
  44368. warn(
  44369. false,
  44370. "Named Route '" + (route.name) + "' has a default child route. " +
  44371. "When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), " +
  44372. "the default child route will not be rendered. Remove the name from " +
  44373. "this route and use the name of the default child route for named " +
  44374. "links instead."
  44375. );
  44376. }
  44377. }
  44378. route.children.forEach(function (child) {
  44379. var childMatchAs = matchAs
  44380. ? cleanPath((matchAs + "/" + (child.path)))
  44381. : undefined;
  44382. addRouteRecord(pathList, pathMap, nameMap, child, record, childMatchAs);
  44383. });
  44384. }
  44385. if (!pathMap[record.path]) {
  44386. pathList.push(record.path);
  44387. pathMap[record.path] = record;
  44388. }
  44389. if (route.alias !== undefined) {
  44390. var aliases = Array.isArray(route.alias) ? route.alias : [route.alias];
  44391. for (var i = 0; i < aliases.length; ++i) {
  44392. var alias = aliases[i];
  44393. if ( true && alias === path) {
  44394. warn(
  44395. false,
  44396. ("Found an alias with the same value as the path: \"" + path + "\". You have to remove that alias. It will be ignored in development.")
  44397. );
  44398. // skip in dev to make it work
  44399. continue
  44400. }
  44401. var aliasRoute = {
  44402. path: alias,
  44403. children: route.children
  44404. };
  44405. addRouteRecord(
  44406. pathList,
  44407. pathMap,
  44408. nameMap,
  44409. aliasRoute,
  44410. parent,
  44411. record.path || '/' // matchAs
  44412. );
  44413. }
  44414. }
  44415. if (name) {
  44416. if (!nameMap[name]) {
  44417. nameMap[name] = record;
  44418. } else if ( true && !matchAs) {
  44419. warn(
  44420. false,
  44421. "Duplicate named routes definition: " +
  44422. "{ name: \"" + name + "\", path: \"" + (record.path) + "\" }"
  44423. );
  44424. }
  44425. }
  44426. }
  44427. function compileRouteRegex (
  44428. path,
  44429. pathToRegexpOptions
  44430. ) {
  44431. var regex = pathToRegexp_1(path, [], pathToRegexpOptions);
  44432. if (true) {
  44433. var keys = Object.create(null);
  44434. regex.keys.forEach(function (key) {
  44435. warn(
  44436. !keys[key.name],
  44437. ("Duplicate param keys in route with path: \"" + path + "\"")
  44438. );
  44439. keys[key.name] = true;
  44440. });
  44441. }
  44442. return regex
  44443. }
  44444. function normalizePath (
  44445. path,
  44446. parent,
  44447. strict
  44448. ) {
  44449. if (!strict) { path = path.replace(/\/$/, ''); }
  44450. if (path[0] === '/') { return path }
  44451. if (parent == null) { return path }
  44452. return cleanPath(((parent.path) + "/" + path))
  44453. }
  44454. /* */
  44455. function createMatcher (
  44456. routes,
  44457. router
  44458. ) {
  44459. var ref = createRouteMap(routes);
  44460. var pathList = ref.pathList;
  44461. var pathMap = ref.pathMap;
  44462. var nameMap = ref.nameMap;
  44463. function addRoutes (routes) {
  44464. createRouteMap(routes, pathList, pathMap, nameMap);
  44465. }
  44466. function match (
  44467. raw,
  44468. currentRoute,
  44469. redirectedFrom
  44470. ) {
  44471. var location = normalizeLocation(raw, currentRoute, false, router);
  44472. var name = location.name;
  44473. if (name) {
  44474. var record = nameMap[name];
  44475. if (true) {
  44476. warn(record, ("Route with name '" + name + "' does not exist"));
  44477. }
  44478. if (!record) { return _createRoute(null, location) }
  44479. var paramNames = record.regex.keys
  44480. .filter(function (key) { return !key.optional; })
  44481. .map(function (key) { return key.name; });
  44482. if (typeof location.params !== 'object') {
  44483. location.params = {};
  44484. }
  44485. if (currentRoute && typeof currentRoute.params === 'object') {
  44486. for (var key in currentRoute.params) {
  44487. if (!(key in location.params) && paramNames.indexOf(key) > -1) {
  44488. location.params[key] = currentRoute.params[key];
  44489. }
  44490. }
  44491. }
  44492. location.path = fillParams(record.path, location.params, ("named route \"" + name + "\""));
  44493. return _createRoute(record, location, redirectedFrom)
  44494. } else if (location.path) {
  44495. location.params = {};
  44496. for (var i = 0; i < pathList.length; i++) {
  44497. var path = pathList[i];
  44498. var record$1 = pathMap[path];
  44499. if (matchRoute(record$1.regex, location.path, location.params)) {
  44500. return _createRoute(record$1, location, redirectedFrom)
  44501. }
  44502. }
  44503. }
  44504. // no match
  44505. return _createRoute(null, location)
  44506. }
  44507. function redirect (
  44508. record,
  44509. location
  44510. ) {
  44511. var originalRedirect = record.redirect;
  44512. var redirect = typeof originalRedirect === 'function'
  44513. ? originalRedirect(createRoute(record, location, null, router))
  44514. : originalRedirect;
  44515. if (typeof redirect === 'string') {
  44516. redirect = { path: redirect };
  44517. }
  44518. if (!redirect || typeof redirect !== 'object') {
  44519. if (true) {
  44520. warn(
  44521. false, ("invalid redirect option: " + (JSON.stringify(redirect)))
  44522. );
  44523. }
  44524. return _createRoute(null, location)
  44525. }
  44526. var re = redirect;
  44527. var name = re.name;
  44528. var path = re.path;
  44529. var query = location.query;
  44530. var hash = location.hash;
  44531. var params = location.params;
  44532. query = re.hasOwnProperty('query') ? re.query : query;
  44533. hash = re.hasOwnProperty('hash') ? re.hash : hash;
  44534. params = re.hasOwnProperty('params') ? re.params : params;
  44535. if (name) {
  44536. // resolved named direct
  44537. var targetRecord = nameMap[name];
  44538. if (true) {
  44539. assert(targetRecord, ("redirect failed: named route \"" + name + "\" not found."));
  44540. }
  44541. return match({
  44542. _normalized: true,
  44543. name: name,
  44544. query: query,
  44545. hash: hash,
  44546. params: params
  44547. }, undefined, location)
  44548. } else if (path) {
  44549. // 1. resolve relative redirect
  44550. var rawPath = resolveRecordPath(path, record);
  44551. // 2. resolve params
  44552. var resolvedPath = fillParams(rawPath, params, ("redirect route with path \"" + rawPath + "\""));
  44553. // 3. rematch with existing query and hash
  44554. return match({
  44555. _normalized: true,
  44556. path: resolvedPath,
  44557. query: query,
  44558. hash: hash
  44559. }, undefined, location)
  44560. } else {
  44561. if (true) {
  44562. warn(false, ("invalid redirect option: " + (JSON.stringify(redirect))));
  44563. }
  44564. return _createRoute(null, location)
  44565. }
  44566. }
  44567. function alias (
  44568. record,
  44569. location,
  44570. matchAs
  44571. ) {
  44572. var aliasedPath = fillParams(matchAs, location.params, ("aliased route with path \"" + matchAs + "\""));
  44573. var aliasedMatch = match({
  44574. _normalized: true,
  44575. path: aliasedPath
  44576. });
  44577. if (aliasedMatch) {
  44578. var matched = aliasedMatch.matched;
  44579. var aliasedRecord = matched[matched.length - 1];
  44580. location.params = aliasedMatch.params;
  44581. return _createRoute(aliasedRecord, location)
  44582. }
  44583. return _createRoute(null, location)
  44584. }
  44585. function _createRoute (
  44586. record,
  44587. location,
  44588. redirectedFrom
  44589. ) {
  44590. if (record && record.redirect) {
  44591. return redirect(record, redirectedFrom || location)
  44592. }
  44593. if (record && record.matchAs) {
  44594. return alias(record, location, record.matchAs)
  44595. }
  44596. return createRoute(record, location, redirectedFrom, router)
  44597. }
  44598. return {
  44599. match: match,
  44600. addRoutes: addRoutes
  44601. }
  44602. }
  44603. function matchRoute (
  44604. regex,
  44605. path,
  44606. params
  44607. ) {
  44608. var m = path.match(regex);
  44609. if (!m) {
  44610. return false
  44611. } else if (!params) {
  44612. return true
  44613. }
  44614. for (var i = 1, len = m.length; i < len; ++i) {
  44615. var key = regex.keys[i - 1];
  44616. var val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i];
  44617. if (key) {
  44618. // Fix #1994: using * with props: true generates a param named 0
  44619. params[key.name || 'pathMatch'] = val;
  44620. }
  44621. }
  44622. return true
  44623. }
  44624. function resolveRecordPath (path, record) {
  44625. return resolvePath(path, record.parent ? record.parent.path : '/', true)
  44626. }
  44627. /* */
  44628. // use User Timing api (if present) for more accurate key precision
  44629. var Time =
  44630. inBrowser && window.performance && window.performance.now
  44631. ? window.performance
  44632. : Date;
  44633. function genStateKey () {
  44634. return Time.now().toFixed(3)
  44635. }
  44636. var _key = genStateKey();
  44637. function getStateKey () {
  44638. return _key
  44639. }
  44640. function setStateKey (key) {
  44641. return (_key = key)
  44642. }
  44643. /* */
  44644. var positionStore = Object.create(null);
  44645. function setupScroll () {
  44646. // Fix for #1585 for Firefox
  44647. // Fix for #2195 Add optional third attribute to workaround a bug in safari https://bugs.webkit.org/show_bug.cgi?id=182678
  44648. // Fix for #2774 Support for apps loaded from Windows file shares not mapped to network drives: replaced location.origin with
  44649. // window.location.protocol + '//' + window.location.host
  44650. // location.host contains the port and location.hostname doesn't
  44651. var protocolAndPath = window.location.protocol + '//' + window.location.host;
  44652. var absolutePath = window.location.href.replace(protocolAndPath, '');
  44653. // preserve existing history state as it could be overriden by the user
  44654. var stateCopy = extend({}, window.history.state);
  44655. stateCopy.key = getStateKey();
  44656. window.history.replaceState(stateCopy, '', absolutePath);
  44657. window.addEventListener('popstate', function (e) {
  44658. saveScrollPosition();
  44659. if (e.state && e.state.key) {
  44660. setStateKey(e.state.key);
  44661. }
  44662. });
  44663. }
  44664. function handleScroll (
  44665. router,
  44666. to,
  44667. from,
  44668. isPop
  44669. ) {
  44670. if (!router.app) {
  44671. return
  44672. }
  44673. var behavior = router.options.scrollBehavior;
  44674. if (!behavior) {
  44675. return
  44676. }
  44677. if (true) {
  44678. assert(typeof behavior === 'function', "scrollBehavior must be a function");
  44679. }
  44680. // wait until re-render finishes before scrolling
  44681. router.app.$nextTick(function () {
  44682. var position = getScrollPosition();
  44683. var shouldScroll = behavior.call(
  44684. router,
  44685. to,
  44686. from,
  44687. isPop ? position : null
  44688. );
  44689. if (!shouldScroll) {
  44690. return
  44691. }
  44692. if (typeof shouldScroll.then === 'function') {
  44693. shouldScroll
  44694. .then(function (shouldScroll) {
  44695. scrollToPosition((shouldScroll), position);
  44696. })
  44697. .catch(function (err) {
  44698. if (true) {
  44699. assert(false, err.toString());
  44700. }
  44701. });
  44702. } else {
  44703. scrollToPosition(shouldScroll, position);
  44704. }
  44705. });
  44706. }
  44707. function saveScrollPosition () {
  44708. var key = getStateKey();
  44709. if (key) {
  44710. positionStore[key] = {
  44711. x: window.pageXOffset,
  44712. y: window.pageYOffset
  44713. };
  44714. }
  44715. }
  44716. function getScrollPosition () {
  44717. var key = getStateKey();
  44718. if (key) {
  44719. return positionStore[key]
  44720. }
  44721. }
  44722. function getElementPosition (el, offset) {
  44723. var docEl = document.documentElement;
  44724. var docRect = docEl.getBoundingClientRect();
  44725. var elRect = el.getBoundingClientRect();
  44726. return {
  44727. x: elRect.left - docRect.left - offset.x,
  44728. y: elRect.top - docRect.top - offset.y
  44729. }
  44730. }
  44731. function isValidPosition (obj) {
  44732. return isNumber(obj.x) || isNumber(obj.y)
  44733. }
  44734. function normalizePosition (obj) {
  44735. return {
  44736. x: isNumber(obj.x) ? obj.x : window.pageXOffset,
  44737. y: isNumber(obj.y) ? obj.y : window.pageYOffset
  44738. }
  44739. }
  44740. function normalizeOffset (obj) {
  44741. return {
  44742. x: isNumber(obj.x) ? obj.x : 0,
  44743. y: isNumber(obj.y) ? obj.y : 0
  44744. }
  44745. }
  44746. function isNumber (v) {
  44747. return typeof v === 'number'
  44748. }
  44749. var hashStartsWithNumberRE = /^#\d/;
  44750. function scrollToPosition (shouldScroll, position) {
  44751. var isObject = typeof shouldScroll === 'object';
  44752. if (isObject && typeof shouldScroll.selector === 'string') {
  44753. // getElementById would still fail if the selector contains a more complicated query like #main[data-attr]
  44754. // but at the same time, it doesn't make much sense to select an element with an id and an extra selector
  44755. var el = hashStartsWithNumberRE.test(shouldScroll.selector) // $flow-disable-line
  44756. ? document.getElementById(shouldScroll.selector.slice(1)) // $flow-disable-line
  44757. : document.querySelector(shouldScroll.selector);
  44758. if (el) {
  44759. var offset =
  44760. shouldScroll.offset && typeof shouldScroll.offset === 'object'
  44761. ? shouldScroll.offset
  44762. : {};
  44763. offset = normalizeOffset(offset);
  44764. position = getElementPosition(el, offset);
  44765. } else if (isValidPosition(shouldScroll)) {
  44766. position = normalizePosition(shouldScroll);
  44767. }
  44768. } else if (isObject && isValidPosition(shouldScroll)) {
  44769. position = normalizePosition(shouldScroll);
  44770. }
  44771. if (position) {
  44772. window.scrollTo(position.x, position.y);
  44773. }
  44774. }
  44775. /* */
  44776. var supportsPushState =
  44777. inBrowser &&
  44778. (function () {
  44779. var ua = window.navigator.userAgent;
  44780. if (
  44781. (ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
  44782. ua.indexOf('Mobile Safari') !== -1 &&
  44783. ua.indexOf('Chrome') === -1 &&
  44784. ua.indexOf('Windows Phone') === -1
  44785. ) {
  44786. return false
  44787. }
  44788. return window.history && 'pushState' in window.history
  44789. })();
  44790. function pushState (url, replace) {
  44791. saveScrollPosition();
  44792. // try...catch the pushState call to get around Safari
  44793. // DOM Exception 18 where it limits to 100 pushState calls
  44794. var history = window.history;
  44795. try {
  44796. if (replace) {
  44797. // preserve existing history state as it could be overriden by the user
  44798. var stateCopy = extend({}, history.state);
  44799. stateCopy.key = getStateKey();
  44800. history.replaceState(stateCopy, '', url);
  44801. } else {
  44802. history.pushState({ key: setStateKey(genStateKey()) }, '', url);
  44803. }
  44804. } catch (e) {
  44805. window.location[replace ? 'replace' : 'assign'](url);
  44806. }
  44807. }
  44808. function replaceState (url) {
  44809. pushState(url, true);
  44810. }
  44811. /* */
  44812. function runQueue (queue, fn, cb) {
  44813. var step = function (index) {
  44814. if (index >= queue.length) {
  44815. cb();
  44816. } else {
  44817. if (queue[index]) {
  44818. fn(queue[index], function () {
  44819. step(index + 1);
  44820. });
  44821. } else {
  44822. step(index + 1);
  44823. }
  44824. }
  44825. };
  44826. step(0);
  44827. }
  44828. /* */
  44829. function resolveAsyncComponents (matched) {
  44830. return function (to, from, next) {
  44831. var hasAsync = false;
  44832. var pending = 0;
  44833. var error = null;
  44834. flatMapComponents(matched, function (def, _, match, key) {
  44835. // if it's a function and doesn't have cid attached,
  44836. // assume it's an async component resolve function.
  44837. // we are not using Vue's default async resolving mechanism because
  44838. // we want to halt the navigation until the incoming component has been
  44839. // resolved.
  44840. if (typeof def === 'function' && def.cid === undefined) {
  44841. hasAsync = true;
  44842. pending++;
  44843. var resolve = once(function (resolvedDef) {
  44844. if (isESModule(resolvedDef)) {
  44845. resolvedDef = resolvedDef.default;
  44846. }
  44847. // save resolved on async factory in case it's used elsewhere
  44848. def.resolved = typeof resolvedDef === 'function'
  44849. ? resolvedDef
  44850. : _Vue.extend(resolvedDef);
  44851. match.components[key] = resolvedDef;
  44852. pending--;
  44853. if (pending <= 0) {
  44854. next();
  44855. }
  44856. });
  44857. var reject = once(function (reason) {
  44858. var msg = "Failed to resolve async component " + key + ": " + reason;
  44859. true && warn(false, msg);
  44860. if (!error) {
  44861. error = isError(reason)
  44862. ? reason
  44863. : new Error(msg);
  44864. next(error);
  44865. }
  44866. });
  44867. var res;
  44868. try {
  44869. res = def(resolve, reject);
  44870. } catch (e) {
  44871. reject(e);
  44872. }
  44873. if (res) {
  44874. if (typeof res.then === 'function') {
  44875. res.then(resolve, reject);
  44876. } else {
  44877. // new syntax in Vue 2.3
  44878. var comp = res.component;
  44879. if (comp && typeof comp.then === 'function') {
  44880. comp.then(resolve, reject);
  44881. }
  44882. }
  44883. }
  44884. }
  44885. });
  44886. if (!hasAsync) { next(); }
  44887. }
  44888. }
  44889. function flatMapComponents (
  44890. matched,
  44891. fn
  44892. ) {
  44893. return flatten(matched.map(function (m) {
  44894. return Object.keys(m.components).map(function (key) { return fn(
  44895. m.components[key],
  44896. m.instances[key],
  44897. m, key
  44898. ); })
  44899. }))
  44900. }
  44901. function flatten (arr) {
  44902. return Array.prototype.concat.apply([], arr)
  44903. }
  44904. var hasSymbol =
  44905. typeof Symbol === 'function' &&
  44906. typeof Symbol.toStringTag === 'symbol';
  44907. function isESModule (obj) {
  44908. return obj.__esModule || (hasSymbol && obj[Symbol.toStringTag] === 'Module')
  44909. }
  44910. // in Webpack 2, require.ensure now also returns a Promise
  44911. // so the resolve/reject functions may get called an extra time
  44912. // if the user uses an arrow function shorthand that happens to
  44913. // return that Promise.
  44914. function once (fn) {
  44915. var called = false;
  44916. return function () {
  44917. var args = [], len = arguments.length;
  44918. while ( len-- ) args[ len ] = arguments[ len ];
  44919. if (called) { return }
  44920. called = true;
  44921. return fn.apply(this, args)
  44922. }
  44923. }
  44924. var NavigationDuplicated = /*@__PURE__*/(function (Error) {
  44925. function NavigationDuplicated (normalizedLocation) {
  44926. Error.call(this);
  44927. this.name = this._name = 'NavigationDuplicated';
  44928. // passing the message to super() doesn't seem to work in the transpiled version
  44929. this.message = "Navigating to current location (\"" + (normalizedLocation.fullPath) + "\") is not allowed";
  44930. // add a stack property so services like Sentry can correctly display it
  44931. Object.defineProperty(this, 'stack', {
  44932. value: new Error().stack,
  44933. writable: true,
  44934. configurable: true
  44935. });
  44936. // we could also have used
  44937. // Error.captureStackTrace(this, this.constructor)
  44938. // but it only exists on node and chrome
  44939. }
  44940. if ( Error ) NavigationDuplicated.__proto__ = Error;
  44941. NavigationDuplicated.prototype = Object.create( Error && Error.prototype );
  44942. NavigationDuplicated.prototype.constructor = NavigationDuplicated;
  44943. return NavigationDuplicated;
  44944. }(Error));
  44945. // support IE9
  44946. NavigationDuplicated._name = 'NavigationDuplicated';
  44947. /* */
  44948. var History = function History (router, base) {
  44949. this.router = router;
  44950. this.base = normalizeBase(base);
  44951. // start with a route object that stands for "nowhere"
  44952. this.current = START;
  44953. this.pending = null;
  44954. this.ready = false;
  44955. this.readyCbs = [];
  44956. this.readyErrorCbs = [];
  44957. this.errorCbs = [];
  44958. };
  44959. History.prototype.listen = function listen (cb) {
  44960. this.cb = cb;
  44961. };
  44962. History.prototype.onReady = function onReady (cb, errorCb) {
  44963. if (this.ready) {
  44964. cb();
  44965. } else {
  44966. this.readyCbs.push(cb);
  44967. if (errorCb) {
  44968. this.readyErrorCbs.push(errorCb);
  44969. }
  44970. }
  44971. };
  44972. History.prototype.onError = function onError (errorCb) {
  44973. this.errorCbs.push(errorCb);
  44974. };
  44975. History.prototype.transitionTo = function transitionTo (
  44976. location,
  44977. onComplete,
  44978. onAbort
  44979. ) {
  44980. var this$1 = this;
  44981. var route = this.router.match(location, this.current);
  44982. this.confirmTransition(
  44983. route,
  44984. function () {
  44985. this$1.updateRoute(route);
  44986. onComplete && onComplete(route);
  44987. this$1.ensureURL();
  44988. // fire ready cbs once
  44989. if (!this$1.ready) {
  44990. this$1.ready = true;
  44991. this$1.readyCbs.forEach(function (cb) {
  44992. cb(route);
  44993. });
  44994. }
  44995. },
  44996. function (err) {
  44997. if (onAbort) {
  44998. onAbort(err);
  44999. }
  45000. if (err && !this$1.ready) {
  45001. this$1.ready = true;
  45002. this$1.readyErrorCbs.forEach(function (cb) {
  45003. cb(err);
  45004. });
  45005. }
  45006. }
  45007. );
  45008. };
  45009. History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) {
  45010. var this$1 = this;
  45011. var current = this.current;
  45012. var abort = function (err) {
  45013. // after merging https://github.com/vuejs/vue-router/pull/2771 we
  45014. // When the user navigates through history through back/forward buttons
  45015. // we do not want to throw the error. We only throw it if directly calling
  45016. // push/replace. That's why it's not included in isError
  45017. if (!isExtendedError(NavigationDuplicated, err) && isError(err)) {
  45018. if (this$1.errorCbs.length) {
  45019. this$1.errorCbs.forEach(function (cb) {
  45020. cb(err);
  45021. });
  45022. } else {
  45023. warn(false, 'uncaught error during route navigation:');
  45024. console.error(err);
  45025. }
  45026. }
  45027. onAbort && onAbort(err);
  45028. };
  45029. if (
  45030. isSameRoute(route, current) &&
  45031. // in the case the route map has been dynamically appended to
  45032. route.matched.length === current.matched.length
  45033. ) {
  45034. this.ensureURL();
  45035. return abort(new NavigationDuplicated(route))
  45036. }
  45037. var ref = resolveQueue(
  45038. this.current.matched,
  45039. route.matched
  45040. );
  45041. var updated = ref.updated;
  45042. var deactivated = ref.deactivated;
  45043. var activated = ref.activated;
  45044. var queue = [].concat(
  45045. // in-component leave guards
  45046. extractLeaveGuards(deactivated),
  45047. // global before hooks
  45048. this.router.beforeHooks,
  45049. // in-component update hooks
  45050. extractUpdateHooks(updated),
  45051. // in-config enter guards
  45052. activated.map(function (m) { return m.beforeEnter; }),
  45053. // async components
  45054. resolveAsyncComponents(activated)
  45055. );
  45056. this.pending = route;
  45057. var iterator = function (hook, next) {
  45058. if (this$1.pending !== route) {
  45059. return abort()
  45060. }
  45061. try {
  45062. hook(route, current, function (to) {
  45063. if (to === false || isError(to)) {
  45064. // next(false) -> abort navigation, ensure current URL
  45065. this$1.ensureURL(true);
  45066. abort(to);
  45067. } else if (
  45068. typeof to === 'string' ||
  45069. (typeof to === 'object' &&
  45070. (typeof to.path === 'string' || typeof to.name === 'string'))
  45071. ) {
  45072. // next('/') or next({ path: '/' }) -> redirect
  45073. abort();
  45074. if (typeof to === 'object' && to.replace) {
  45075. this$1.replace(to);
  45076. } else {
  45077. this$1.push(to);
  45078. }
  45079. } else {
  45080. // confirm transition and pass on the value
  45081. next(to);
  45082. }
  45083. });
  45084. } catch (e) {
  45085. abort(e);
  45086. }
  45087. };
  45088. runQueue(queue, iterator, function () {
  45089. var postEnterCbs = [];
  45090. var isValid = function () { return this$1.current === route; };
  45091. // wait until async components are resolved before
  45092. // extracting in-component enter guards
  45093. var enterGuards = extractEnterGuards(activated, postEnterCbs, isValid);
  45094. var queue = enterGuards.concat(this$1.router.resolveHooks);
  45095. runQueue(queue, iterator, function () {
  45096. if (this$1.pending !== route) {
  45097. return abort()
  45098. }
  45099. this$1.pending = null;
  45100. onComplete(route);
  45101. if (this$1.router.app) {
  45102. this$1.router.app.$nextTick(function () {
  45103. postEnterCbs.forEach(function (cb) {
  45104. cb();
  45105. });
  45106. });
  45107. }
  45108. });
  45109. });
  45110. };
  45111. History.prototype.updateRoute = function updateRoute (route) {
  45112. var prev = this.current;
  45113. this.current = route;
  45114. this.cb && this.cb(route);
  45115. this.router.afterHooks.forEach(function (hook) {
  45116. hook && hook(route, prev);
  45117. });
  45118. };
  45119. function normalizeBase (base) {
  45120. if (!base) {
  45121. if (inBrowser) {
  45122. // respect <base> tag
  45123. var baseEl = document.querySelector('base');
  45124. base = (baseEl && baseEl.getAttribute('href')) || '/';
  45125. // strip full URL origin
  45126. base = base.replace(/^https?:\/\/[^\/]+/, '');
  45127. } else {
  45128. base = '/';
  45129. }
  45130. }
  45131. // make sure there's the starting slash
  45132. if (base.charAt(0) !== '/') {
  45133. base = '/' + base;
  45134. }
  45135. // remove trailing slash
  45136. return base.replace(/\/$/, '')
  45137. }
  45138. function resolveQueue (
  45139. current,
  45140. next
  45141. ) {
  45142. var i;
  45143. var max = Math.max(current.length, next.length);
  45144. for (i = 0; i < max; i++) {
  45145. if (current[i] !== next[i]) {
  45146. break
  45147. }
  45148. }
  45149. return {
  45150. updated: next.slice(0, i),
  45151. activated: next.slice(i),
  45152. deactivated: current.slice(i)
  45153. }
  45154. }
  45155. function extractGuards (
  45156. records,
  45157. name,
  45158. bind,
  45159. reverse
  45160. ) {
  45161. var guards = flatMapComponents(records, function (def, instance, match, key) {
  45162. var guard = extractGuard(def, name);
  45163. if (guard) {
  45164. return Array.isArray(guard)
  45165. ? guard.map(function (guard) { return bind(guard, instance, match, key); })
  45166. : bind(guard, instance, match, key)
  45167. }
  45168. });
  45169. return flatten(reverse ? guards.reverse() : guards)
  45170. }
  45171. function extractGuard (
  45172. def,
  45173. key
  45174. ) {
  45175. if (typeof def !== 'function') {
  45176. // extend now so that global mixins are applied.
  45177. def = _Vue.extend(def);
  45178. }
  45179. return def.options[key]
  45180. }
  45181. function extractLeaveGuards (deactivated) {
  45182. return extractGuards(deactivated, 'beforeRouteLeave', bindGuard, true)
  45183. }
  45184. function extractUpdateHooks (updated) {
  45185. return extractGuards(updated, 'beforeRouteUpdate', bindGuard)
  45186. }
  45187. function bindGuard (guard, instance) {
  45188. if (instance) {
  45189. return function boundRouteGuard () {
  45190. return guard.apply(instance, arguments)
  45191. }
  45192. }
  45193. }
  45194. function extractEnterGuards (
  45195. activated,
  45196. cbs,
  45197. isValid
  45198. ) {
  45199. return extractGuards(
  45200. activated,
  45201. 'beforeRouteEnter',
  45202. function (guard, _, match, key) {
  45203. return bindEnterGuard(guard, match, key, cbs, isValid)
  45204. }
  45205. )
  45206. }
  45207. function bindEnterGuard (
  45208. guard,
  45209. match,
  45210. key,
  45211. cbs,
  45212. isValid
  45213. ) {
  45214. return function routeEnterGuard (to, from, next) {
  45215. return guard(to, from, function (cb) {
  45216. if (typeof cb === 'function') {
  45217. cbs.push(function () {
  45218. // #750
  45219. // if a router-view is wrapped with an out-in transition,
  45220. // the instance may not have been registered at this time.
  45221. // we will need to poll for registration until current route
  45222. // is no longer valid.
  45223. poll(cb, match.instances, key, isValid);
  45224. });
  45225. }
  45226. next(cb);
  45227. })
  45228. }
  45229. }
  45230. function poll (
  45231. cb, // somehow flow cannot infer this is a function
  45232. instances,
  45233. key,
  45234. isValid
  45235. ) {
  45236. if (
  45237. instances[key] &&
  45238. !instances[key]._isBeingDestroyed // do not reuse being destroyed instance
  45239. ) {
  45240. cb(instances[key]);
  45241. } else if (isValid()) {
  45242. setTimeout(function () {
  45243. poll(cb, instances, key, isValid);
  45244. }, 16);
  45245. }
  45246. }
  45247. /* */
  45248. var HTML5History = /*@__PURE__*/(function (History) {
  45249. function HTML5History (router, base) {
  45250. var this$1 = this;
  45251. History.call(this, router, base);
  45252. var expectScroll = router.options.scrollBehavior;
  45253. var supportsScroll = supportsPushState && expectScroll;
  45254. if (supportsScroll) {
  45255. setupScroll();
  45256. }
  45257. var initLocation = getLocation(this.base);
  45258. window.addEventListener('popstate', function (e) {
  45259. var current = this$1.current;
  45260. // Avoiding first `popstate` event dispatched in some browsers but first
  45261. // history route not updated since async guard at the same time.
  45262. var location = getLocation(this$1.base);
  45263. if (this$1.current === START && location === initLocation) {
  45264. return
  45265. }
  45266. this$1.transitionTo(location, function (route) {
  45267. if (supportsScroll) {
  45268. handleScroll(router, route, current, true);
  45269. }
  45270. });
  45271. });
  45272. }
  45273. if ( History ) HTML5History.__proto__ = History;
  45274. HTML5History.prototype = Object.create( History && History.prototype );
  45275. HTML5History.prototype.constructor = HTML5History;
  45276. HTML5History.prototype.go = function go (n) {
  45277. window.history.go(n);
  45278. };
  45279. HTML5History.prototype.push = function push (location, onComplete, onAbort) {
  45280. var this$1 = this;
  45281. var ref = this;
  45282. var fromRoute = ref.current;
  45283. this.transitionTo(location, function (route) {
  45284. pushState(cleanPath(this$1.base + route.fullPath));
  45285. handleScroll(this$1.router, route, fromRoute, false);
  45286. onComplete && onComplete(route);
  45287. }, onAbort);
  45288. };
  45289. HTML5History.prototype.replace = function replace (location, onComplete, onAbort) {
  45290. var this$1 = this;
  45291. var ref = this;
  45292. var fromRoute = ref.current;
  45293. this.transitionTo(location, function (route) {
  45294. replaceState(cleanPath(this$1.base + route.fullPath));
  45295. handleScroll(this$1.router, route, fromRoute, false);
  45296. onComplete && onComplete(route);
  45297. }, onAbort);
  45298. };
  45299. HTML5History.prototype.ensureURL = function ensureURL (push) {
  45300. if (getLocation(this.base) !== this.current.fullPath) {
  45301. var current = cleanPath(this.base + this.current.fullPath);
  45302. push ? pushState(current) : replaceState(current);
  45303. }
  45304. };
  45305. HTML5History.prototype.getCurrentLocation = function getCurrentLocation () {
  45306. return getLocation(this.base)
  45307. };
  45308. return HTML5History;
  45309. }(History));
  45310. function getLocation (base) {
  45311. var path = decodeURI(window.location.pathname);
  45312. if (base && path.indexOf(base) === 0) {
  45313. path = path.slice(base.length);
  45314. }
  45315. return (path || '/') + window.location.search + window.location.hash
  45316. }
  45317. /* */
  45318. var HashHistory = /*@__PURE__*/(function (History) {
  45319. function HashHistory (router, base, fallback) {
  45320. History.call(this, router, base);
  45321. // check history fallback deeplinking
  45322. if (fallback && checkFallback(this.base)) {
  45323. return
  45324. }
  45325. ensureSlash();
  45326. }
  45327. if ( History ) HashHistory.__proto__ = History;
  45328. HashHistory.prototype = Object.create( History && History.prototype );
  45329. HashHistory.prototype.constructor = HashHistory;
  45330. // this is delayed until the app mounts
  45331. // to avoid the hashchange listener being fired too early
  45332. HashHistory.prototype.setupListeners = function setupListeners () {
  45333. var this$1 = this;
  45334. var router = this.router;
  45335. var expectScroll = router.options.scrollBehavior;
  45336. var supportsScroll = supportsPushState && expectScroll;
  45337. if (supportsScroll) {
  45338. setupScroll();
  45339. }
  45340. window.addEventListener(
  45341. supportsPushState ? 'popstate' : 'hashchange',
  45342. function () {
  45343. var current = this$1.current;
  45344. if (!ensureSlash()) {
  45345. return
  45346. }
  45347. this$1.transitionTo(getHash(), function (route) {
  45348. if (supportsScroll) {
  45349. handleScroll(this$1.router, route, current, true);
  45350. }
  45351. if (!supportsPushState) {
  45352. replaceHash(route.fullPath);
  45353. }
  45354. });
  45355. }
  45356. );
  45357. };
  45358. HashHistory.prototype.push = function push (location, onComplete, onAbort) {
  45359. var this$1 = this;
  45360. var ref = this;
  45361. var fromRoute = ref.current;
  45362. this.transitionTo(
  45363. location,
  45364. function (route) {
  45365. pushHash(route.fullPath);
  45366. handleScroll(this$1.router, route, fromRoute, false);
  45367. onComplete && onComplete(route);
  45368. },
  45369. onAbort
  45370. );
  45371. };
  45372. HashHistory.prototype.replace = function replace (location, onComplete, onAbort) {
  45373. var this$1 = this;
  45374. var ref = this;
  45375. var fromRoute = ref.current;
  45376. this.transitionTo(
  45377. location,
  45378. function (route) {
  45379. replaceHash(route.fullPath);
  45380. handleScroll(this$1.router, route, fromRoute, false);
  45381. onComplete && onComplete(route);
  45382. },
  45383. onAbort
  45384. );
  45385. };
  45386. HashHistory.prototype.go = function go (n) {
  45387. window.history.go(n);
  45388. };
  45389. HashHistory.prototype.ensureURL = function ensureURL (push) {
  45390. var current = this.current.fullPath;
  45391. if (getHash() !== current) {
  45392. push ? pushHash(current) : replaceHash(current);
  45393. }
  45394. };
  45395. HashHistory.prototype.getCurrentLocation = function getCurrentLocation () {
  45396. return getHash()
  45397. };
  45398. return HashHistory;
  45399. }(History));
  45400. function checkFallback (base) {
  45401. var location = getLocation(base);
  45402. if (!/^\/#/.test(location)) {
  45403. window.location.replace(cleanPath(base + '/#' + location));
  45404. return true
  45405. }
  45406. }
  45407. function ensureSlash () {
  45408. var path = getHash();
  45409. if (path.charAt(0) === '/') {
  45410. return true
  45411. }
  45412. replaceHash('/' + path);
  45413. return false
  45414. }
  45415. function getHash () {
  45416. // We can't use window.location.hash here because it's not
  45417. // consistent across browsers - Firefox will pre-decode it!
  45418. var href = window.location.href;
  45419. var index = href.indexOf('#');
  45420. // empty path
  45421. if (index < 0) { return '' }
  45422. href = href.slice(index + 1);
  45423. // decode the hash but not the search or hash
  45424. // as search(query) is already decoded
  45425. // https://github.com/vuejs/vue-router/issues/2708
  45426. var searchIndex = href.indexOf('?');
  45427. if (searchIndex < 0) {
  45428. var hashIndex = href.indexOf('#');
  45429. if (hashIndex > -1) {
  45430. href = decodeURI(href.slice(0, hashIndex)) + href.slice(hashIndex);
  45431. } else { href = decodeURI(href); }
  45432. } else {
  45433. href = decodeURI(href.slice(0, searchIndex)) + href.slice(searchIndex);
  45434. }
  45435. return href
  45436. }
  45437. function getUrl (path) {
  45438. var href = window.location.href;
  45439. var i = href.indexOf('#');
  45440. var base = i >= 0 ? href.slice(0, i) : href;
  45441. return (base + "#" + path)
  45442. }
  45443. function pushHash (path) {
  45444. if (supportsPushState) {
  45445. pushState(getUrl(path));
  45446. } else {
  45447. window.location.hash = path;
  45448. }
  45449. }
  45450. function replaceHash (path) {
  45451. if (supportsPushState) {
  45452. replaceState(getUrl(path));
  45453. } else {
  45454. window.location.replace(getUrl(path));
  45455. }
  45456. }
  45457. /* */
  45458. var AbstractHistory = /*@__PURE__*/(function (History) {
  45459. function AbstractHistory (router, base) {
  45460. History.call(this, router, base);
  45461. this.stack = [];
  45462. this.index = -1;
  45463. }
  45464. if ( History ) AbstractHistory.__proto__ = History;
  45465. AbstractHistory.prototype = Object.create( History && History.prototype );
  45466. AbstractHistory.prototype.constructor = AbstractHistory;
  45467. AbstractHistory.prototype.push = function push (location, onComplete, onAbort) {
  45468. var this$1 = this;
  45469. this.transitionTo(
  45470. location,
  45471. function (route) {
  45472. this$1.stack = this$1.stack.slice(0, this$1.index + 1).concat(route);
  45473. this$1.index++;
  45474. onComplete && onComplete(route);
  45475. },
  45476. onAbort
  45477. );
  45478. };
  45479. AbstractHistory.prototype.replace = function replace (location, onComplete, onAbort) {
  45480. var this$1 = this;
  45481. this.transitionTo(
  45482. location,
  45483. function (route) {
  45484. this$1.stack = this$1.stack.slice(0, this$1.index).concat(route);
  45485. onComplete && onComplete(route);
  45486. },
  45487. onAbort
  45488. );
  45489. };
  45490. AbstractHistory.prototype.go = function go (n) {
  45491. var this$1 = this;
  45492. var targetIndex = this.index + n;
  45493. if (targetIndex < 0 || targetIndex >= this.stack.length) {
  45494. return
  45495. }
  45496. var route = this.stack[targetIndex];
  45497. this.confirmTransition(
  45498. route,
  45499. function () {
  45500. this$1.index = targetIndex;
  45501. this$1.updateRoute(route);
  45502. },
  45503. function (err) {
  45504. if (isExtendedError(NavigationDuplicated, err)) {
  45505. this$1.index = targetIndex;
  45506. }
  45507. }
  45508. );
  45509. };
  45510. AbstractHistory.prototype.getCurrentLocation = function getCurrentLocation () {
  45511. var current = this.stack[this.stack.length - 1];
  45512. return current ? current.fullPath : '/'
  45513. };
  45514. AbstractHistory.prototype.ensureURL = function ensureURL () {
  45515. // noop
  45516. };
  45517. return AbstractHistory;
  45518. }(History));
  45519. /* */
  45520. var VueRouter = function VueRouter (options) {
  45521. if ( options === void 0 ) options = {};
  45522. this.app = null;
  45523. this.apps = [];
  45524. this.options = options;
  45525. this.beforeHooks = [];
  45526. this.resolveHooks = [];
  45527. this.afterHooks = [];
  45528. this.matcher = createMatcher(options.routes || [], this);
  45529. var mode = options.mode || 'hash';
  45530. this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false;
  45531. if (this.fallback) {
  45532. mode = 'hash';
  45533. }
  45534. if (!inBrowser) {
  45535. mode = 'abstract';
  45536. }
  45537. this.mode = mode;
  45538. switch (mode) {
  45539. case 'history':
  45540. this.history = new HTML5History(this, options.base);
  45541. break
  45542. case 'hash':
  45543. this.history = new HashHistory(this, options.base, this.fallback);
  45544. break
  45545. case 'abstract':
  45546. this.history = new AbstractHistory(this, options.base);
  45547. break
  45548. default:
  45549. if (true) {
  45550. assert(false, ("invalid mode: " + mode));
  45551. }
  45552. }
  45553. };
  45554. var prototypeAccessors = { currentRoute: { configurable: true } };
  45555. VueRouter.prototype.match = function match (
  45556. raw,
  45557. current,
  45558. redirectedFrom
  45559. ) {
  45560. return this.matcher.match(raw, current, redirectedFrom)
  45561. };
  45562. prototypeAccessors.currentRoute.get = function () {
  45563. return this.history && this.history.current
  45564. };
  45565. VueRouter.prototype.init = function init (app /* Vue component instance */) {
  45566. var this$1 = this;
  45567. true && assert(
  45568. install.installed,
  45569. "not installed. Make sure to call `Vue.use(VueRouter)` " +
  45570. "before creating root instance."
  45571. );
  45572. this.apps.push(app);
  45573. // set up app destroyed handler
  45574. // https://github.com/vuejs/vue-router/issues/2639
  45575. app.$once('hook:destroyed', function () {
  45576. // clean out app from this.apps array once destroyed
  45577. var index = this$1.apps.indexOf(app);
  45578. if (index > -1) { this$1.apps.splice(index, 1); }
  45579. // ensure we still have a main app or null if no apps
  45580. // we do not release the router so it can be reused
  45581. if (this$1.app === app) { this$1.app = this$1.apps[0] || null; }
  45582. });
  45583. // main app previously initialized
  45584. // return as we don't need to set up new history listener
  45585. if (this.app) {
  45586. return
  45587. }
  45588. this.app = app;
  45589. var history = this.history;
  45590. if (history instanceof HTML5History) {
  45591. history.transitionTo(history.getCurrentLocation());
  45592. } else if (history instanceof HashHistory) {
  45593. var setupHashListener = function () {
  45594. history.setupListeners();
  45595. };
  45596. history.transitionTo(
  45597. history.getCurrentLocation(),
  45598. setupHashListener,
  45599. setupHashListener
  45600. );
  45601. }
  45602. history.listen(function (route) {
  45603. this$1.apps.forEach(function (app) {
  45604. app._route = route;
  45605. });
  45606. });
  45607. };
  45608. VueRouter.prototype.beforeEach = function beforeEach (fn) {
  45609. return registerHook(this.beforeHooks, fn)
  45610. };
  45611. VueRouter.prototype.beforeResolve = function beforeResolve (fn) {
  45612. return registerHook(this.resolveHooks, fn)
  45613. };
  45614. VueRouter.prototype.afterEach = function afterEach (fn) {
  45615. return registerHook(this.afterHooks, fn)
  45616. };
  45617. VueRouter.prototype.onReady = function onReady (cb, errorCb) {
  45618. this.history.onReady(cb, errorCb);
  45619. };
  45620. VueRouter.prototype.onError = function onError (errorCb) {
  45621. this.history.onError(errorCb);
  45622. };
  45623. VueRouter.prototype.push = function push (location, onComplete, onAbort) {
  45624. var this$1 = this;
  45625. // $flow-disable-line
  45626. if (!onComplete && !onAbort && typeof Promise !== 'undefined') {
  45627. return new Promise(function (resolve, reject) {
  45628. this$1.history.push(location, resolve, reject);
  45629. })
  45630. } else {
  45631. this.history.push(location, onComplete, onAbort);
  45632. }
  45633. };
  45634. VueRouter.prototype.replace = function replace (location, onComplete, onAbort) {
  45635. var this$1 = this;
  45636. // $flow-disable-line
  45637. if (!onComplete && !onAbort && typeof Promise !== 'undefined') {
  45638. return new Promise(function (resolve, reject) {
  45639. this$1.history.replace(location, resolve, reject);
  45640. })
  45641. } else {
  45642. this.history.replace(location, onComplete, onAbort);
  45643. }
  45644. };
  45645. VueRouter.prototype.go = function go (n) {
  45646. this.history.go(n);
  45647. };
  45648. VueRouter.prototype.back = function back () {
  45649. this.go(-1);
  45650. };
  45651. VueRouter.prototype.forward = function forward () {
  45652. this.go(1);
  45653. };
  45654. VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) {
  45655. var route = to
  45656. ? to.matched
  45657. ? to
  45658. : this.resolve(to).route
  45659. : this.currentRoute;
  45660. if (!route) {
  45661. return []
  45662. }
  45663. return [].concat.apply([], route.matched.map(function (m) {
  45664. return Object.keys(m.components).map(function (key) {
  45665. return m.components[key]
  45666. })
  45667. }))
  45668. };
  45669. VueRouter.prototype.resolve = function resolve (
  45670. to,
  45671. current,
  45672. append
  45673. ) {
  45674. current = current || this.history.current;
  45675. var location = normalizeLocation(
  45676. to,
  45677. current,
  45678. append,
  45679. this
  45680. );
  45681. var route = this.match(location, current);
  45682. var fullPath = route.redirectedFrom || route.fullPath;
  45683. var base = this.history.base;
  45684. var href = createHref(base, fullPath, this.mode);
  45685. return {
  45686. location: location,
  45687. route: route,
  45688. href: href,
  45689. // for backwards compat
  45690. normalizedTo: location,
  45691. resolved: route
  45692. }
  45693. };
  45694. VueRouter.prototype.addRoutes = function addRoutes (routes) {
  45695. this.matcher.addRoutes(routes);
  45696. if (this.history.current !== START) {
  45697. this.history.transitionTo(this.history.getCurrentLocation());
  45698. }
  45699. };
  45700. Object.defineProperties( VueRouter.prototype, prototypeAccessors );
  45701. function registerHook (list, fn) {
  45702. list.push(fn);
  45703. return function () {
  45704. var i = list.indexOf(fn);
  45705. if (i > -1) { list.splice(i, 1); }
  45706. }
  45707. }
  45708. function createHref (base, fullPath, mode) {
  45709. var path = mode === 'hash' ? '#' + fullPath : fullPath;
  45710. return base ? cleanPath(base + '/' + path) : path
  45711. }
  45712. VueRouter.install = install;
  45713. VueRouter.version = '3.1.6';
  45714. if (inBrowser && window.Vue) {
  45715. window.Vue.use(VueRouter);
  45716. }
  45717. /* harmony default export */ __webpack_exports__["default"] = (VueRouter);
  45718. /***/ }),
  45719. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  45720. /*!*************************************************!*\
  45721. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  45722. \*************************************************/
  45723. /*! no static exports found */
  45724. /***/ (function(module, exports, __webpack_require__) {
  45725. "use strict";
  45726. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  45727. * Vue.js v2.6.11
  45728. * (c) 2014-2019 Evan You
  45729. * Released under the MIT License.
  45730. */
  45731. /* */
  45732. var emptyObject = Object.freeze({});
  45733. // These helpers produce better VM code in JS engines due to their
  45734. // explicitness and function inlining.
  45735. function isUndef (v) {
  45736. return v === undefined || v === null
  45737. }
  45738. function isDef (v) {
  45739. return v !== undefined && v !== null
  45740. }
  45741. function isTrue (v) {
  45742. return v === true
  45743. }
  45744. function isFalse (v) {
  45745. return v === false
  45746. }
  45747. /**
  45748. * Check if value is primitive.
  45749. */
  45750. function isPrimitive (value) {
  45751. return (
  45752. typeof value === 'string' ||
  45753. typeof value === 'number' ||
  45754. // $flow-disable-line
  45755. typeof value === 'symbol' ||
  45756. typeof value === 'boolean'
  45757. )
  45758. }
  45759. /**
  45760. * Quick object check - this is primarily used to tell
  45761. * Objects from primitive values when we know the value
  45762. * is a JSON-compliant type.
  45763. */
  45764. function isObject (obj) {
  45765. return obj !== null && typeof obj === 'object'
  45766. }
  45767. /**
  45768. * Get the raw type string of a value, e.g., [object Object].
  45769. */
  45770. var _toString = Object.prototype.toString;
  45771. function toRawType (value) {
  45772. return _toString.call(value).slice(8, -1)
  45773. }
  45774. /**
  45775. * Strict object type check. Only returns true
  45776. * for plain JavaScript objects.
  45777. */
  45778. function isPlainObject (obj) {
  45779. return _toString.call(obj) === '[object Object]'
  45780. }
  45781. function isRegExp (v) {
  45782. return _toString.call(v) === '[object RegExp]'
  45783. }
  45784. /**
  45785. * Check if val is a valid array index.
  45786. */
  45787. function isValidArrayIndex (val) {
  45788. var n = parseFloat(String(val));
  45789. return n >= 0 && Math.floor(n) === n && isFinite(val)
  45790. }
  45791. function isPromise (val) {
  45792. return (
  45793. isDef(val) &&
  45794. typeof val.then === 'function' &&
  45795. typeof val.catch === 'function'
  45796. )
  45797. }
  45798. /**
  45799. * Convert a value to a string that is actually rendered.
  45800. */
  45801. function toString (val) {
  45802. return val == null
  45803. ? ''
  45804. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  45805. ? JSON.stringify(val, null, 2)
  45806. : String(val)
  45807. }
  45808. /**
  45809. * Convert an input value to a number for persistence.
  45810. * If the conversion fails, return original string.
  45811. */
  45812. function toNumber (val) {
  45813. var n = parseFloat(val);
  45814. return isNaN(n) ? val : n
  45815. }
  45816. /**
  45817. * Make a map and return a function for checking if a key
  45818. * is in that map.
  45819. */
  45820. function makeMap (
  45821. str,
  45822. expectsLowerCase
  45823. ) {
  45824. var map = Object.create(null);
  45825. var list = str.split(',');
  45826. for (var i = 0; i < list.length; i++) {
  45827. map[list[i]] = true;
  45828. }
  45829. return expectsLowerCase
  45830. ? function (val) { return map[val.toLowerCase()]; }
  45831. : function (val) { return map[val]; }
  45832. }
  45833. /**
  45834. * Check if a tag is a built-in tag.
  45835. */
  45836. var isBuiltInTag = makeMap('slot,component', true);
  45837. /**
  45838. * Check if an attribute is a reserved attribute.
  45839. */
  45840. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  45841. /**
  45842. * Remove an item from an array.
  45843. */
  45844. function remove (arr, item) {
  45845. if (arr.length) {
  45846. var index = arr.indexOf(item);
  45847. if (index > -1) {
  45848. return arr.splice(index, 1)
  45849. }
  45850. }
  45851. }
  45852. /**
  45853. * Check whether an object has the property.
  45854. */
  45855. var hasOwnProperty = Object.prototype.hasOwnProperty;
  45856. function hasOwn (obj, key) {
  45857. return hasOwnProperty.call(obj, key)
  45858. }
  45859. /**
  45860. * Create a cached version of a pure function.
  45861. */
  45862. function cached (fn) {
  45863. var cache = Object.create(null);
  45864. return (function cachedFn (str) {
  45865. var hit = cache[str];
  45866. return hit || (cache[str] = fn(str))
  45867. })
  45868. }
  45869. /**
  45870. * Camelize a hyphen-delimited string.
  45871. */
  45872. var camelizeRE = /-(\w)/g;
  45873. var camelize = cached(function (str) {
  45874. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  45875. });
  45876. /**
  45877. * Capitalize a string.
  45878. */
  45879. var capitalize = cached(function (str) {
  45880. return str.charAt(0).toUpperCase() + str.slice(1)
  45881. });
  45882. /**
  45883. * Hyphenate a camelCase string.
  45884. */
  45885. var hyphenateRE = /\B([A-Z])/g;
  45886. var hyphenate = cached(function (str) {
  45887. return str.replace(hyphenateRE, '-$1').toLowerCase()
  45888. });
  45889. /**
  45890. * Simple bind polyfill for environments that do not support it,
  45891. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  45892. * since native bind is now performant enough in most browsers.
  45893. * But removing it would mean breaking code that was able to run in
  45894. * PhantomJS 1.x, so this must be kept for backward compatibility.
  45895. */
  45896. /* istanbul ignore next */
  45897. function polyfillBind (fn, ctx) {
  45898. function boundFn (a) {
  45899. var l = arguments.length;
  45900. return l
  45901. ? l > 1
  45902. ? fn.apply(ctx, arguments)
  45903. : fn.call(ctx, a)
  45904. : fn.call(ctx)
  45905. }
  45906. boundFn._length = fn.length;
  45907. return boundFn
  45908. }
  45909. function nativeBind (fn, ctx) {
  45910. return fn.bind(ctx)
  45911. }
  45912. var bind = Function.prototype.bind
  45913. ? nativeBind
  45914. : polyfillBind;
  45915. /**
  45916. * Convert an Array-like object to a real Array.
  45917. */
  45918. function toArray (list, start) {
  45919. start = start || 0;
  45920. var i = list.length - start;
  45921. var ret = new Array(i);
  45922. while (i--) {
  45923. ret[i] = list[i + start];
  45924. }
  45925. return ret
  45926. }
  45927. /**
  45928. * Mix properties into target object.
  45929. */
  45930. function extend (to, _from) {
  45931. for (var key in _from) {
  45932. to[key] = _from[key];
  45933. }
  45934. return to
  45935. }
  45936. /**
  45937. * Merge an Array of Objects into a single Object.
  45938. */
  45939. function toObject (arr) {
  45940. var res = {};
  45941. for (var i = 0; i < arr.length; i++) {
  45942. if (arr[i]) {
  45943. extend(res, arr[i]);
  45944. }
  45945. }
  45946. return res
  45947. }
  45948. /* eslint-disable no-unused-vars */
  45949. /**
  45950. * Perform no operation.
  45951. * Stubbing args to make Flow happy without leaving useless transpiled code
  45952. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  45953. */
  45954. function noop (a, b, c) {}
  45955. /**
  45956. * Always return false.
  45957. */
  45958. var no = function (a, b, c) { return false; };
  45959. /* eslint-enable no-unused-vars */
  45960. /**
  45961. * Return the same value.
  45962. */
  45963. var identity = function (_) { return _; };
  45964. /**
  45965. * Generate a string containing static keys from compiler modules.
  45966. */
  45967. function genStaticKeys (modules) {
  45968. return modules.reduce(function (keys, m) {
  45969. return keys.concat(m.staticKeys || [])
  45970. }, []).join(',')
  45971. }
  45972. /**
  45973. * Check if two values are loosely equal - that is,
  45974. * if they are plain objects, do they have the same shape?
  45975. */
  45976. function looseEqual (a, b) {
  45977. if (a === b) { return true }
  45978. var isObjectA = isObject(a);
  45979. var isObjectB = isObject(b);
  45980. if (isObjectA && isObjectB) {
  45981. try {
  45982. var isArrayA = Array.isArray(a);
  45983. var isArrayB = Array.isArray(b);
  45984. if (isArrayA && isArrayB) {
  45985. return a.length === b.length && a.every(function (e, i) {
  45986. return looseEqual(e, b[i])
  45987. })
  45988. } else if (a instanceof Date && b instanceof Date) {
  45989. return a.getTime() === b.getTime()
  45990. } else if (!isArrayA && !isArrayB) {
  45991. var keysA = Object.keys(a);
  45992. var keysB = Object.keys(b);
  45993. return keysA.length === keysB.length && keysA.every(function (key) {
  45994. return looseEqual(a[key], b[key])
  45995. })
  45996. } else {
  45997. /* istanbul ignore next */
  45998. return false
  45999. }
  46000. } catch (e) {
  46001. /* istanbul ignore next */
  46002. return false
  46003. }
  46004. } else if (!isObjectA && !isObjectB) {
  46005. return String(a) === String(b)
  46006. } else {
  46007. return false
  46008. }
  46009. }
  46010. /**
  46011. * Return the first index at which a loosely equal value can be
  46012. * found in the array (if value is a plain object, the array must
  46013. * contain an object of the same shape), or -1 if it is not present.
  46014. */
  46015. function looseIndexOf (arr, val) {
  46016. for (var i = 0; i < arr.length; i++) {
  46017. if (looseEqual(arr[i], val)) { return i }
  46018. }
  46019. return -1
  46020. }
  46021. /**
  46022. * Ensure a function is called only once.
  46023. */
  46024. function once (fn) {
  46025. var called = false;
  46026. return function () {
  46027. if (!called) {
  46028. called = true;
  46029. fn.apply(this, arguments);
  46030. }
  46031. }
  46032. }
  46033. var SSR_ATTR = 'data-server-rendered';
  46034. var ASSET_TYPES = [
  46035. 'component',
  46036. 'directive',
  46037. 'filter'
  46038. ];
  46039. var LIFECYCLE_HOOKS = [
  46040. 'beforeCreate',
  46041. 'created',
  46042. 'beforeMount',
  46043. 'mounted',
  46044. 'beforeUpdate',
  46045. 'updated',
  46046. 'beforeDestroy',
  46047. 'destroyed',
  46048. 'activated',
  46049. 'deactivated',
  46050. 'errorCaptured',
  46051. 'serverPrefetch'
  46052. ];
  46053. /* */
  46054. var config = ({
  46055. /**
  46056. * Option merge strategies (used in core/util/options)
  46057. */
  46058. // $flow-disable-line
  46059. optionMergeStrategies: Object.create(null),
  46060. /**
  46061. * Whether to suppress warnings.
  46062. */
  46063. silent: false,
  46064. /**
  46065. * Show production mode tip message on boot?
  46066. */
  46067. productionTip: "development" !== 'production',
  46068. /**
  46069. * Whether to enable devtools
  46070. */
  46071. devtools: "development" !== 'production',
  46072. /**
  46073. * Whether to record perf
  46074. */
  46075. performance: false,
  46076. /**
  46077. * Error handler for watcher errors
  46078. */
  46079. errorHandler: null,
  46080. /**
  46081. * Warn handler for watcher warns
  46082. */
  46083. warnHandler: null,
  46084. /**
  46085. * Ignore certain custom elements
  46086. */
  46087. ignoredElements: [],
  46088. /**
  46089. * Custom user key aliases for v-on
  46090. */
  46091. // $flow-disable-line
  46092. keyCodes: Object.create(null),
  46093. /**
  46094. * Check if a tag is reserved so that it cannot be registered as a
  46095. * component. This is platform-dependent and may be overwritten.
  46096. */
  46097. isReservedTag: no,
  46098. /**
  46099. * Check if an attribute is reserved so that it cannot be used as a component
  46100. * prop. This is platform-dependent and may be overwritten.
  46101. */
  46102. isReservedAttr: no,
  46103. /**
  46104. * Check if a tag is an unknown element.
  46105. * Platform-dependent.
  46106. */
  46107. isUnknownElement: no,
  46108. /**
  46109. * Get the namespace of an element
  46110. */
  46111. getTagNamespace: noop,
  46112. /**
  46113. * Parse the real tag name for the specific platform.
  46114. */
  46115. parsePlatformTagName: identity,
  46116. /**
  46117. * Check if an attribute must be bound using property, e.g. value
  46118. * Platform-dependent.
  46119. */
  46120. mustUseProp: no,
  46121. /**
  46122. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  46123. * This will significantly reduce performance if set to false.
  46124. */
  46125. async: true,
  46126. /**
  46127. * Exposed for legacy reasons
  46128. */
  46129. _lifecycleHooks: LIFECYCLE_HOOKS
  46130. });
  46131. /* */
  46132. /**
  46133. * unicode letters used for parsing html tags, component names and property paths.
  46134. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  46135. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  46136. */
  46137. 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/;
  46138. /**
  46139. * Check if a string starts with $ or _
  46140. */
  46141. function isReserved (str) {
  46142. var c = (str + '').charCodeAt(0);
  46143. return c === 0x24 || c === 0x5F
  46144. }
  46145. /**
  46146. * Define a property.
  46147. */
  46148. function def (obj, key, val, enumerable) {
  46149. Object.defineProperty(obj, key, {
  46150. value: val,
  46151. enumerable: !!enumerable,
  46152. writable: true,
  46153. configurable: true
  46154. });
  46155. }
  46156. /**
  46157. * Parse simple path.
  46158. */
  46159. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  46160. function parsePath (path) {
  46161. if (bailRE.test(path)) {
  46162. return
  46163. }
  46164. var segments = path.split('.');
  46165. return function (obj) {
  46166. for (var i = 0; i < segments.length; i++) {
  46167. if (!obj) { return }
  46168. obj = obj[segments[i]];
  46169. }
  46170. return obj
  46171. }
  46172. }
  46173. /* */
  46174. // can we use __proto__?
  46175. var hasProto = '__proto__' in {};
  46176. // Browser environment sniffing
  46177. var inBrowser = typeof window !== 'undefined';
  46178. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  46179. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  46180. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  46181. var isIE = UA && /msie|trident/.test(UA);
  46182. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  46183. var isEdge = UA && UA.indexOf('edge/') > 0;
  46184. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  46185. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  46186. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  46187. var isPhantomJS = UA && /phantomjs/.test(UA);
  46188. var isFF = UA && UA.match(/firefox\/(\d+)/);
  46189. // Firefox has a "watch" function on Object.prototype...
  46190. var nativeWatch = ({}).watch;
  46191. var supportsPassive = false;
  46192. if (inBrowser) {
  46193. try {
  46194. var opts = {};
  46195. Object.defineProperty(opts, 'passive', ({
  46196. get: function get () {
  46197. /* istanbul ignore next */
  46198. supportsPassive = true;
  46199. }
  46200. })); // https://github.com/facebook/flow/issues/285
  46201. window.addEventListener('test-passive', null, opts);
  46202. } catch (e) {}
  46203. }
  46204. // this needs to be lazy-evaled because vue may be required before
  46205. // vue-server-renderer can set VUE_ENV
  46206. var _isServer;
  46207. var isServerRendering = function () {
  46208. if (_isServer === undefined) {
  46209. /* istanbul ignore if */
  46210. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  46211. // detect presence of vue-server-renderer and avoid
  46212. // Webpack shimming the process
  46213. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  46214. } else {
  46215. _isServer = false;
  46216. }
  46217. }
  46218. return _isServer
  46219. };
  46220. // detect devtools
  46221. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  46222. /* istanbul ignore next */
  46223. function isNative (Ctor) {
  46224. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  46225. }
  46226. var hasSymbol =
  46227. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  46228. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  46229. var _Set;
  46230. /* istanbul ignore if */ // $flow-disable-line
  46231. if (typeof Set !== 'undefined' && isNative(Set)) {
  46232. // use native Set when available.
  46233. _Set = Set;
  46234. } else {
  46235. // a non-standard Set polyfill that only works with primitive keys.
  46236. _Set = /*@__PURE__*/(function () {
  46237. function Set () {
  46238. this.set = Object.create(null);
  46239. }
  46240. Set.prototype.has = function has (key) {
  46241. return this.set[key] === true
  46242. };
  46243. Set.prototype.add = function add (key) {
  46244. this.set[key] = true;
  46245. };
  46246. Set.prototype.clear = function clear () {
  46247. this.set = Object.create(null);
  46248. };
  46249. return Set;
  46250. }());
  46251. }
  46252. /* */
  46253. var warn = noop;
  46254. var tip = noop;
  46255. var generateComponentTrace = (noop); // work around flow check
  46256. var formatComponentName = (noop);
  46257. {
  46258. var hasConsole = typeof console !== 'undefined';
  46259. var classifyRE = /(?:^|[-_])(\w)/g;
  46260. var classify = function (str) { return str
  46261. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  46262. .replace(/[-_]/g, ''); };
  46263. warn = function (msg, vm) {
  46264. var trace = vm ? generateComponentTrace(vm) : '';
  46265. if (config.warnHandler) {
  46266. config.warnHandler.call(null, msg, vm, trace);
  46267. } else if (hasConsole && (!config.silent)) {
  46268. console.error(("[Vue warn]: " + msg + trace));
  46269. }
  46270. };
  46271. tip = function (msg, vm) {
  46272. if (hasConsole && (!config.silent)) {
  46273. console.warn("[Vue tip]: " + msg + (
  46274. vm ? generateComponentTrace(vm) : ''
  46275. ));
  46276. }
  46277. };
  46278. formatComponentName = function (vm, includeFile) {
  46279. if (vm.$root === vm) {
  46280. return '<Root>'
  46281. }
  46282. var options = typeof vm === 'function' && vm.cid != null
  46283. ? vm.options
  46284. : vm._isVue
  46285. ? vm.$options || vm.constructor.options
  46286. : vm;
  46287. var name = options.name || options._componentTag;
  46288. var file = options.__file;
  46289. if (!name && file) {
  46290. var match = file.match(/([^/\\]+)\.vue$/);
  46291. name = match && match[1];
  46292. }
  46293. return (
  46294. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  46295. (file && includeFile !== false ? (" at " + file) : '')
  46296. )
  46297. };
  46298. var repeat = function (str, n) {
  46299. var res = '';
  46300. while (n) {
  46301. if (n % 2 === 1) { res += str; }
  46302. if (n > 1) { str += str; }
  46303. n >>= 1;
  46304. }
  46305. return res
  46306. };
  46307. generateComponentTrace = function (vm) {
  46308. if (vm._isVue && vm.$parent) {
  46309. var tree = [];
  46310. var currentRecursiveSequence = 0;
  46311. while (vm) {
  46312. if (tree.length > 0) {
  46313. var last = tree[tree.length - 1];
  46314. if (last.constructor === vm.constructor) {
  46315. currentRecursiveSequence++;
  46316. vm = vm.$parent;
  46317. continue
  46318. } else if (currentRecursiveSequence > 0) {
  46319. tree[tree.length - 1] = [last, currentRecursiveSequence];
  46320. currentRecursiveSequence = 0;
  46321. }
  46322. }
  46323. tree.push(vm);
  46324. vm = vm.$parent;
  46325. }
  46326. return '\n\nfound in\n\n' + tree
  46327. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  46328. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  46329. : formatComponentName(vm))); })
  46330. .join('\n')
  46331. } else {
  46332. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  46333. }
  46334. };
  46335. }
  46336. /* */
  46337. var uid = 0;
  46338. /**
  46339. * A dep is an observable that can have multiple
  46340. * directives subscribing to it.
  46341. */
  46342. var Dep = function Dep () {
  46343. this.id = uid++;
  46344. this.subs = [];
  46345. };
  46346. Dep.prototype.addSub = function addSub (sub) {
  46347. this.subs.push(sub);
  46348. };
  46349. Dep.prototype.removeSub = function removeSub (sub) {
  46350. remove(this.subs, sub);
  46351. };
  46352. Dep.prototype.depend = function depend () {
  46353. if (Dep.target) {
  46354. Dep.target.addDep(this);
  46355. }
  46356. };
  46357. Dep.prototype.notify = function notify () {
  46358. // stabilize the subscriber list first
  46359. var subs = this.subs.slice();
  46360. if (!config.async) {
  46361. // subs aren't sorted in scheduler if not running async
  46362. // we need to sort them now to make sure they fire in correct
  46363. // order
  46364. subs.sort(function (a, b) { return a.id - b.id; });
  46365. }
  46366. for (var i = 0, l = subs.length; i < l; i++) {
  46367. subs[i].update();
  46368. }
  46369. };
  46370. // The current target watcher being evaluated.
  46371. // This is globally unique because only one watcher
  46372. // can be evaluated at a time.
  46373. Dep.target = null;
  46374. var targetStack = [];
  46375. function pushTarget (target) {
  46376. targetStack.push(target);
  46377. Dep.target = target;
  46378. }
  46379. function popTarget () {
  46380. targetStack.pop();
  46381. Dep.target = targetStack[targetStack.length - 1];
  46382. }
  46383. /* */
  46384. var VNode = function VNode (
  46385. tag,
  46386. data,
  46387. children,
  46388. text,
  46389. elm,
  46390. context,
  46391. componentOptions,
  46392. asyncFactory
  46393. ) {
  46394. this.tag = tag;
  46395. this.data = data;
  46396. this.children = children;
  46397. this.text = text;
  46398. this.elm = elm;
  46399. this.ns = undefined;
  46400. this.context = context;
  46401. this.fnContext = undefined;
  46402. this.fnOptions = undefined;
  46403. this.fnScopeId = undefined;
  46404. this.key = data && data.key;
  46405. this.componentOptions = componentOptions;
  46406. this.componentInstance = undefined;
  46407. this.parent = undefined;
  46408. this.raw = false;
  46409. this.isStatic = false;
  46410. this.isRootInsert = true;
  46411. this.isComment = false;
  46412. this.isCloned = false;
  46413. this.isOnce = false;
  46414. this.asyncFactory = asyncFactory;
  46415. this.asyncMeta = undefined;
  46416. this.isAsyncPlaceholder = false;
  46417. };
  46418. var prototypeAccessors = { child: { configurable: true } };
  46419. // DEPRECATED: alias for componentInstance for backwards compat.
  46420. /* istanbul ignore next */
  46421. prototypeAccessors.child.get = function () {
  46422. return this.componentInstance
  46423. };
  46424. Object.defineProperties( VNode.prototype, prototypeAccessors );
  46425. var createEmptyVNode = function (text) {
  46426. if ( text === void 0 ) text = '';
  46427. var node = new VNode();
  46428. node.text = text;
  46429. node.isComment = true;
  46430. return node
  46431. };
  46432. function createTextVNode (val) {
  46433. return new VNode(undefined, undefined, undefined, String(val))
  46434. }
  46435. // optimized shallow clone
  46436. // used for static nodes and slot nodes because they may be reused across
  46437. // multiple renders, cloning them avoids errors when DOM manipulations rely
  46438. // on their elm reference.
  46439. function cloneVNode (vnode) {
  46440. var cloned = new VNode(
  46441. vnode.tag,
  46442. vnode.data,
  46443. // #7975
  46444. // clone children array to avoid mutating original in case of cloning
  46445. // a child.
  46446. vnode.children && vnode.children.slice(),
  46447. vnode.text,
  46448. vnode.elm,
  46449. vnode.context,
  46450. vnode.componentOptions,
  46451. vnode.asyncFactory
  46452. );
  46453. cloned.ns = vnode.ns;
  46454. cloned.isStatic = vnode.isStatic;
  46455. cloned.key = vnode.key;
  46456. cloned.isComment = vnode.isComment;
  46457. cloned.fnContext = vnode.fnContext;
  46458. cloned.fnOptions = vnode.fnOptions;
  46459. cloned.fnScopeId = vnode.fnScopeId;
  46460. cloned.asyncMeta = vnode.asyncMeta;
  46461. cloned.isCloned = true;
  46462. return cloned
  46463. }
  46464. /*
  46465. * not type checking this file because flow doesn't play well with
  46466. * dynamically accessing methods on Array prototype
  46467. */
  46468. var arrayProto = Array.prototype;
  46469. var arrayMethods = Object.create(arrayProto);
  46470. var methodsToPatch = [
  46471. 'push',
  46472. 'pop',
  46473. 'shift',
  46474. 'unshift',
  46475. 'splice',
  46476. 'sort',
  46477. 'reverse'
  46478. ];
  46479. /**
  46480. * Intercept mutating methods and emit events
  46481. */
  46482. methodsToPatch.forEach(function (method) {
  46483. // cache original method
  46484. var original = arrayProto[method];
  46485. def(arrayMethods, method, function mutator () {
  46486. var args = [], len = arguments.length;
  46487. while ( len-- ) args[ len ] = arguments[ len ];
  46488. var result = original.apply(this, args);
  46489. var ob = this.__ob__;
  46490. var inserted;
  46491. switch (method) {
  46492. case 'push':
  46493. case 'unshift':
  46494. inserted = args;
  46495. break
  46496. case 'splice':
  46497. inserted = args.slice(2);
  46498. break
  46499. }
  46500. if (inserted) { ob.observeArray(inserted); }
  46501. // notify change
  46502. ob.dep.notify();
  46503. return result
  46504. });
  46505. });
  46506. /* */
  46507. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  46508. /**
  46509. * In some cases we may want to disable observation inside a component's
  46510. * update computation.
  46511. */
  46512. var shouldObserve = true;
  46513. function toggleObserving (value) {
  46514. shouldObserve = value;
  46515. }
  46516. /**
  46517. * Observer class that is attached to each observed
  46518. * object. Once attached, the observer converts the target
  46519. * object's property keys into getter/setters that
  46520. * collect dependencies and dispatch updates.
  46521. */
  46522. var Observer = function Observer (value) {
  46523. this.value = value;
  46524. this.dep = new Dep();
  46525. this.vmCount = 0;
  46526. def(value, '__ob__', this);
  46527. if (Array.isArray(value)) {
  46528. if (hasProto) {
  46529. protoAugment(value, arrayMethods);
  46530. } else {
  46531. copyAugment(value, arrayMethods, arrayKeys);
  46532. }
  46533. this.observeArray(value);
  46534. } else {
  46535. this.walk(value);
  46536. }
  46537. };
  46538. /**
  46539. * Walk through all properties and convert them into
  46540. * getter/setters. This method should only be called when
  46541. * value type is Object.
  46542. */
  46543. Observer.prototype.walk = function walk (obj) {
  46544. var keys = Object.keys(obj);
  46545. for (var i = 0; i < keys.length; i++) {
  46546. defineReactive$$1(obj, keys[i]);
  46547. }
  46548. };
  46549. /**
  46550. * Observe a list of Array items.
  46551. */
  46552. Observer.prototype.observeArray = function observeArray (items) {
  46553. for (var i = 0, l = items.length; i < l; i++) {
  46554. observe(items[i]);
  46555. }
  46556. };
  46557. // helpers
  46558. /**
  46559. * Augment a target Object or Array by intercepting
  46560. * the prototype chain using __proto__
  46561. */
  46562. function protoAugment (target, src) {
  46563. /* eslint-disable no-proto */
  46564. target.__proto__ = src;
  46565. /* eslint-enable no-proto */
  46566. }
  46567. /**
  46568. * Augment a target Object or Array by defining
  46569. * hidden properties.
  46570. */
  46571. /* istanbul ignore next */
  46572. function copyAugment (target, src, keys) {
  46573. for (var i = 0, l = keys.length; i < l; i++) {
  46574. var key = keys[i];
  46575. def(target, key, src[key]);
  46576. }
  46577. }
  46578. /**
  46579. * Attempt to create an observer instance for a value,
  46580. * returns the new observer if successfully observed,
  46581. * or the existing observer if the value already has one.
  46582. */
  46583. function observe (value, asRootData) {
  46584. if (!isObject(value) || value instanceof VNode) {
  46585. return
  46586. }
  46587. var ob;
  46588. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  46589. ob = value.__ob__;
  46590. } else if (
  46591. shouldObserve &&
  46592. !isServerRendering() &&
  46593. (Array.isArray(value) || isPlainObject(value)) &&
  46594. Object.isExtensible(value) &&
  46595. !value._isVue
  46596. ) {
  46597. ob = new Observer(value);
  46598. }
  46599. if (asRootData && ob) {
  46600. ob.vmCount++;
  46601. }
  46602. return ob
  46603. }
  46604. /**
  46605. * Define a reactive property on an Object.
  46606. */
  46607. function defineReactive$$1 (
  46608. obj,
  46609. key,
  46610. val,
  46611. customSetter,
  46612. shallow
  46613. ) {
  46614. var dep = new Dep();
  46615. var property = Object.getOwnPropertyDescriptor(obj, key);
  46616. if (property && property.configurable === false) {
  46617. return
  46618. }
  46619. // cater for pre-defined getter/setters
  46620. var getter = property && property.get;
  46621. var setter = property && property.set;
  46622. if ((!getter || setter) && arguments.length === 2) {
  46623. val = obj[key];
  46624. }
  46625. var childOb = !shallow && observe(val);
  46626. Object.defineProperty(obj, key, {
  46627. enumerable: true,
  46628. configurable: true,
  46629. get: function reactiveGetter () {
  46630. var value = getter ? getter.call(obj) : val;
  46631. if (Dep.target) {
  46632. dep.depend();
  46633. if (childOb) {
  46634. childOb.dep.depend();
  46635. if (Array.isArray(value)) {
  46636. dependArray(value);
  46637. }
  46638. }
  46639. }
  46640. return value
  46641. },
  46642. set: function reactiveSetter (newVal) {
  46643. var value = getter ? getter.call(obj) : val;
  46644. /* eslint-disable no-self-compare */
  46645. if (newVal === value || (newVal !== newVal && value !== value)) {
  46646. return
  46647. }
  46648. /* eslint-enable no-self-compare */
  46649. if (customSetter) {
  46650. customSetter();
  46651. }
  46652. // #7981: for accessor properties without setter
  46653. if (getter && !setter) { return }
  46654. if (setter) {
  46655. setter.call(obj, newVal);
  46656. } else {
  46657. val = newVal;
  46658. }
  46659. childOb = !shallow && observe(newVal);
  46660. dep.notify();
  46661. }
  46662. });
  46663. }
  46664. /**
  46665. * Set a property on an object. Adds the new property and
  46666. * triggers change notification if the property doesn't
  46667. * already exist.
  46668. */
  46669. function set (target, key, val) {
  46670. if (isUndef(target) || isPrimitive(target)
  46671. ) {
  46672. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  46673. }
  46674. if (Array.isArray(target) && isValidArrayIndex(key)) {
  46675. target.length = Math.max(target.length, key);
  46676. target.splice(key, 1, val);
  46677. return val
  46678. }
  46679. if (key in target && !(key in Object.prototype)) {
  46680. target[key] = val;
  46681. return val
  46682. }
  46683. var ob = (target).__ob__;
  46684. if (target._isVue || (ob && ob.vmCount)) {
  46685. warn(
  46686. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  46687. 'at runtime - declare it upfront in the data option.'
  46688. );
  46689. return val
  46690. }
  46691. if (!ob) {
  46692. target[key] = val;
  46693. return val
  46694. }
  46695. defineReactive$$1(ob.value, key, val);
  46696. ob.dep.notify();
  46697. return val
  46698. }
  46699. /**
  46700. * Delete a property and trigger change if necessary.
  46701. */
  46702. function del (target, key) {
  46703. if (isUndef(target) || isPrimitive(target)
  46704. ) {
  46705. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  46706. }
  46707. if (Array.isArray(target) && isValidArrayIndex(key)) {
  46708. target.splice(key, 1);
  46709. return
  46710. }
  46711. var ob = (target).__ob__;
  46712. if (target._isVue || (ob && ob.vmCount)) {
  46713. warn(
  46714. 'Avoid deleting properties on a Vue instance or its root $data ' +
  46715. '- just set it to null.'
  46716. );
  46717. return
  46718. }
  46719. if (!hasOwn(target, key)) {
  46720. return
  46721. }
  46722. delete target[key];
  46723. if (!ob) {
  46724. return
  46725. }
  46726. ob.dep.notify();
  46727. }
  46728. /**
  46729. * Collect dependencies on array elements when the array is touched, since
  46730. * we cannot intercept array element access like property getters.
  46731. */
  46732. function dependArray (value) {
  46733. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  46734. e = value[i];
  46735. e && e.__ob__ && e.__ob__.dep.depend();
  46736. if (Array.isArray(e)) {
  46737. dependArray(e);
  46738. }
  46739. }
  46740. }
  46741. /* */
  46742. /**
  46743. * Option overwriting strategies are functions that handle
  46744. * how to merge a parent option value and a child option
  46745. * value into the final value.
  46746. */
  46747. var strats = config.optionMergeStrategies;
  46748. /**
  46749. * Options with restrictions
  46750. */
  46751. {
  46752. strats.el = strats.propsData = function (parent, child, vm, key) {
  46753. if (!vm) {
  46754. warn(
  46755. "option \"" + key + "\" can only be used during instance " +
  46756. 'creation with the `new` keyword.'
  46757. );
  46758. }
  46759. return defaultStrat(parent, child)
  46760. };
  46761. }
  46762. /**
  46763. * Helper that recursively merges two data objects together.
  46764. */
  46765. function mergeData (to, from) {
  46766. if (!from) { return to }
  46767. var key, toVal, fromVal;
  46768. var keys = hasSymbol
  46769. ? Reflect.ownKeys(from)
  46770. : Object.keys(from);
  46771. for (var i = 0; i < keys.length; i++) {
  46772. key = keys[i];
  46773. // in case the object is already observed...
  46774. if (key === '__ob__') { continue }
  46775. toVal = to[key];
  46776. fromVal = from[key];
  46777. if (!hasOwn(to, key)) {
  46778. set(to, key, fromVal);
  46779. } else if (
  46780. toVal !== fromVal &&
  46781. isPlainObject(toVal) &&
  46782. isPlainObject(fromVal)
  46783. ) {
  46784. mergeData(toVal, fromVal);
  46785. }
  46786. }
  46787. return to
  46788. }
  46789. /**
  46790. * Data
  46791. */
  46792. function mergeDataOrFn (
  46793. parentVal,
  46794. childVal,
  46795. vm
  46796. ) {
  46797. if (!vm) {
  46798. // in a Vue.extend merge, both should be functions
  46799. if (!childVal) {
  46800. return parentVal
  46801. }
  46802. if (!parentVal) {
  46803. return childVal
  46804. }
  46805. // when parentVal & childVal are both present,
  46806. // we need to return a function that returns the
  46807. // merged result of both functions... no need to
  46808. // check if parentVal is a function here because
  46809. // it has to be a function to pass previous merges.
  46810. return function mergedDataFn () {
  46811. return mergeData(
  46812. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  46813. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  46814. )
  46815. }
  46816. } else {
  46817. return function mergedInstanceDataFn () {
  46818. // instance merge
  46819. var instanceData = typeof childVal === 'function'
  46820. ? childVal.call(vm, vm)
  46821. : childVal;
  46822. var defaultData = typeof parentVal === 'function'
  46823. ? parentVal.call(vm, vm)
  46824. : parentVal;
  46825. if (instanceData) {
  46826. return mergeData(instanceData, defaultData)
  46827. } else {
  46828. return defaultData
  46829. }
  46830. }
  46831. }
  46832. }
  46833. strats.data = function (
  46834. parentVal,
  46835. childVal,
  46836. vm
  46837. ) {
  46838. if (!vm) {
  46839. if (childVal && typeof childVal !== 'function') {
  46840. warn(
  46841. 'The "data" option should be a function ' +
  46842. 'that returns a per-instance value in component ' +
  46843. 'definitions.',
  46844. vm
  46845. );
  46846. return parentVal
  46847. }
  46848. return mergeDataOrFn(parentVal, childVal)
  46849. }
  46850. return mergeDataOrFn(parentVal, childVal, vm)
  46851. };
  46852. /**
  46853. * Hooks and props are merged as arrays.
  46854. */
  46855. function mergeHook (
  46856. parentVal,
  46857. childVal
  46858. ) {
  46859. var res = childVal
  46860. ? parentVal
  46861. ? parentVal.concat(childVal)
  46862. : Array.isArray(childVal)
  46863. ? childVal
  46864. : [childVal]
  46865. : parentVal;
  46866. return res
  46867. ? dedupeHooks(res)
  46868. : res
  46869. }
  46870. function dedupeHooks (hooks) {
  46871. var res = [];
  46872. for (var i = 0; i < hooks.length; i++) {
  46873. if (res.indexOf(hooks[i]) === -1) {
  46874. res.push(hooks[i]);
  46875. }
  46876. }
  46877. return res
  46878. }
  46879. LIFECYCLE_HOOKS.forEach(function (hook) {
  46880. strats[hook] = mergeHook;
  46881. });
  46882. /**
  46883. * Assets
  46884. *
  46885. * When a vm is present (instance creation), we need to do
  46886. * a three-way merge between constructor options, instance
  46887. * options and parent options.
  46888. */
  46889. function mergeAssets (
  46890. parentVal,
  46891. childVal,
  46892. vm,
  46893. key
  46894. ) {
  46895. var res = Object.create(parentVal || null);
  46896. if (childVal) {
  46897. assertObjectType(key, childVal, vm);
  46898. return extend(res, childVal)
  46899. } else {
  46900. return res
  46901. }
  46902. }
  46903. ASSET_TYPES.forEach(function (type) {
  46904. strats[type + 's'] = mergeAssets;
  46905. });
  46906. /**
  46907. * Watchers.
  46908. *
  46909. * Watchers hashes should not overwrite one
  46910. * another, so we merge them as arrays.
  46911. */
  46912. strats.watch = function (
  46913. parentVal,
  46914. childVal,
  46915. vm,
  46916. key
  46917. ) {
  46918. // work around Firefox's Object.prototype.watch...
  46919. if (parentVal === nativeWatch) { parentVal = undefined; }
  46920. if (childVal === nativeWatch) { childVal = undefined; }
  46921. /* istanbul ignore if */
  46922. if (!childVal) { return Object.create(parentVal || null) }
  46923. {
  46924. assertObjectType(key, childVal, vm);
  46925. }
  46926. if (!parentVal) { return childVal }
  46927. var ret = {};
  46928. extend(ret, parentVal);
  46929. for (var key$1 in childVal) {
  46930. var parent = ret[key$1];
  46931. var child = childVal[key$1];
  46932. if (parent && !Array.isArray(parent)) {
  46933. parent = [parent];
  46934. }
  46935. ret[key$1] = parent
  46936. ? parent.concat(child)
  46937. : Array.isArray(child) ? child : [child];
  46938. }
  46939. return ret
  46940. };
  46941. /**
  46942. * Other object hashes.
  46943. */
  46944. strats.props =
  46945. strats.methods =
  46946. strats.inject =
  46947. strats.computed = function (
  46948. parentVal,
  46949. childVal,
  46950. vm,
  46951. key
  46952. ) {
  46953. if (childVal && "development" !== 'production') {
  46954. assertObjectType(key, childVal, vm);
  46955. }
  46956. if (!parentVal) { return childVal }
  46957. var ret = Object.create(null);
  46958. extend(ret, parentVal);
  46959. if (childVal) { extend(ret, childVal); }
  46960. return ret
  46961. };
  46962. strats.provide = mergeDataOrFn;
  46963. /**
  46964. * Default strategy.
  46965. */
  46966. var defaultStrat = function (parentVal, childVal) {
  46967. return childVal === undefined
  46968. ? parentVal
  46969. : childVal
  46970. };
  46971. /**
  46972. * Validate component names
  46973. */
  46974. function checkComponents (options) {
  46975. for (var key in options.components) {
  46976. validateComponentName(key);
  46977. }
  46978. }
  46979. function validateComponentName (name) {
  46980. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  46981. warn(
  46982. 'Invalid component name: "' + name + '". Component names ' +
  46983. 'should conform to valid custom element name in html5 specification.'
  46984. );
  46985. }
  46986. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  46987. warn(
  46988. 'Do not use built-in or reserved HTML elements as component ' +
  46989. 'id: ' + name
  46990. );
  46991. }
  46992. }
  46993. /**
  46994. * Ensure all props option syntax are normalized into the
  46995. * Object-based format.
  46996. */
  46997. function normalizeProps (options, vm) {
  46998. var props = options.props;
  46999. if (!props) { return }
  47000. var res = {};
  47001. var i, val, name;
  47002. if (Array.isArray(props)) {
  47003. i = props.length;
  47004. while (i--) {
  47005. val = props[i];
  47006. if (typeof val === 'string') {
  47007. name = camelize(val);
  47008. res[name] = { type: null };
  47009. } else {
  47010. warn('props must be strings when using array syntax.');
  47011. }
  47012. }
  47013. } else if (isPlainObject(props)) {
  47014. for (var key in props) {
  47015. val = props[key];
  47016. name = camelize(key);
  47017. res[name] = isPlainObject(val)
  47018. ? val
  47019. : { type: val };
  47020. }
  47021. } else {
  47022. warn(
  47023. "Invalid value for option \"props\": expected an Array or an Object, " +
  47024. "but got " + (toRawType(props)) + ".",
  47025. vm
  47026. );
  47027. }
  47028. options.props = res;
  47029. }
  47030. /**
  47031. * Normalize all injections into Object-based format
  47032. */
  47033. function normalizeInject (options, vm) {
  47034. var inject = options.inject;
  47035. if (!inject) { return }
  47036. var normalized = options.inject = {};
  47037. if (Array.isArray(inject)) {
  47038. for (var i = 0; i < inject.length; i++) {
  47039. normalized[inject[i]] = { from: inject[i] };
  47040. }
  47041. } else if (isPlainObject(inject)) {
  47042. for (var key in inject) {
  47043. var val = inject[key];
  47044. normalized[key] = isPlainObject(val)
  47045. ? extend({ from: key }, val)
  47046. : { from: val };
  47047. }
  47048. } else {
  47049. warn(
  47050. "Invalid value for option \"inject\": expected an Array or an Object, " +
  47051. "but got " + (toRawType(inject)) + ".",
  47052. vm
  47053. );
  47054. }
  47055. }
  47056. /**
  47057. * Normalize raw function directives into object format.
  47058. */
  47059. function normalizeDirectives (options) {
  47060. var dirs = options.directives;
  47061. if (dirs) {
  47062. for (var key in dirs) {
  47063. var def$$1 = dirs[key];
  47064. if (typeof def$$1 === 'function') {
  47065. dirs[key] = { bind: def$$1, update: def$$1 };
  47066. }
  47067. }
  47068. }
  47069. }
  47070. function assertObjectType (name, value, vm) {
  47071. if (!isPlainObject(value)) {
  47072. warn(
  47073. "Invalid value for option \"" + name + "\": expected an Object, " +
  47074. "but got " + (toRawType(value)) + ".",
  47075. vm
  47076. );
  47077. }
  47078. }
  47079. /**
  47080. * Merge two option objects into a new one.
  47081. * Core utility used in both instantiation and inheritance.
  47082. */
  47083. function mergeOptions (
  47084. parent,
  47085. child,
  47086. vm
  47087. ) {
  47088. {
  47089. checkComponents(child);
  47090. }
  47091. if (typeof child === 'function') {
  47092. child = child.options;
  47093. }
  47094. normalizeProps(child, vm);
  47095. normalizeInject(child, vm);
  47096. normalizeDirectives(child);
  47097. // Apply extends and mixins on the child options,
  47098. // but only if it is a raw options object that isn't
  47099. // the result of another mergeOptions call.
  47100. // Only merged options has the _base property.
  47101. if (!child._base) {
  47102. if (child.extends) {
  47103. parent = mergeOptions(parent, child.extends, vm);
  47104. }
  47105. if (child.mixins) {
  47106. for (var i = 0, l = child.mixins.length; i < l; i++) {
  47107. parent = mergeOptions(parent, child.mixins[i], vm);
  47108. }
  47109. }
  47110. }
  47111. var options = {};
  47112. var key;
  47113. for (key in parent) {
  47114. mergeField(key);
  47115. }
  47116. for (key in child) {
  47117. if (!hasOwn(parent, key)) {
  47118. mergeField(key);
  47119. }
  47120. }
  47121. function mergeField (key) {
  47122. var strat = strats[key] || defaultStrat;
  47123. options[key] = strat(parent[key], child[key], vm, key);
  47124. }
  47125. return options
  47126. }
  47127. /**
  47128. * Resolve an asset.
  47129. * This function is used because child instances need access
  47130. * to assets defined in its ancestor chain.
  47131. */
  47132. function resolveAsset (
  47133. options,
  47134. type,
  47135. id,
  47136. warnMissing
  47137. ) {
  47138. /* istanbul ignore if */
  47139. if (typeof id !== 'string') {
  47140. return
  47141. }
  47142. var assets = options[type];
  47143. // check local registration variations first
  47144. if (hasOwn(assets, id)) { return assets[id] }
  47145. var camelizedId = camelize(id);
  47146. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  47147. var PascalCaseId = capitalize(camelizedId);
  47148. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  47149. // fallback to prototype chain
  47150. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  47151. if (warnMissing && !res) {
  47152. warn(
  47153. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  47154. options
  47155. );
  47156. }
  47157. return res
  47158. }
  47159. /* */
  47160. function validateProp (
  47161. key,
  47162. propOptions,
  47163. propsData,
  47164. vm
  47165. ) {
  47166. var prop = propOptions[key];
  47167. var absent = !hasOwn(propsData, key);
  47168. var value = propsData[key];
  47169. // boolean casting
  47170. var booleanIndex = getTypeIndex(Boolean, prop.type);
  47171. if (booleanIndex > -1) {
  47172. if (absent && !hasOwn(prop, 'default')) {
  47173. value = false;
  47174. } else if (value === '' || value === hyphenate(key)) {
  47175. // only cast empty string / same name to boolean if
  47176. // boolean has higher priority
  47177. var stringIndex = getTypeIndex(String, prop.type);
  47178. if (stringIndex < 0 || booleanIndex < stringIndex) {
  47179. value = true;
  47180. }
  47181. }
  47182. }
  47183. // check default value
  47184. if (value === undefined) {
  47185. value = getPropDefaultValue(vm, prop, key);
  47186. // since the default value is a fresh copy,
  47187. // make sure to observe it.
  47188. var prevShouldObserve = shouldObserve;
  47189. toggleObserving(true);
  47190. observe(value);
  47191. toggleObserving(prevShouldObserve);
  47192. }
  47193. {
  47194. assertProp(prop, key, value, vm, absent);
  47195. }
  47196. return value
  47197. }
  47198. /**
  47199. * Get the default value of a prop.
  47200. */
  47201. function getPropDefaultValue (vm, prop, key) {
  47202. // no default, return undefined
  47203. if (!hasOwn(prop, 'default')) {
  47204. return undefined
  47205. }
  47206. var def = prop.default;
  47207. // warn against non-factory defaults for Object & Array
  47208. if (isObject(def)) {
  47209. warn(
  47210. 'Invalid default value for prop "' + key + '": ' +
  47211. 'Props with type Object/Array must use a factory function ' +
  47212. 'to return the default value.',
  47213. vm
  47214. );
  47215. }
  47216. // the raw prop value was also undefined from previous render,
  47217. // return previous default value to avoid unnecessary watcher trigger
  47218. if (vm && vm.$options.propsData &&
  47219. vm.$options.propsData[key] === undefined &&
  47220. vm._props[key] !== undefined
  47221. ) {
  47222. return vm._props[key]
  47223. }
  47224. // call factory function for non-Function types
  47225. // a value is Function if its prototype is function even across different execution context
  47226. return typeof def === 'function' && getType(prop.type) !== 'Function'
  47227. ? def.call(vm)
  47228. : def
  47229. }
  47230. /**
  47231. * Assert whether a prop is valid.
  47232. */
  47233. function assertProp (
  47234. prop,
  47235. name,
  47236. value,
  47237. vm,
  47238. absent
  47239. ) {
  47240. if (prop.required && absent) {
  47241. warn(
  47242. 'Missing required prop: "' + name + '"',
  47243. vm
  47244. );
  47245. return
  47246. }
  47247. if (value == null && !prop.required) {
  47248. return
  47249. }
  47250. var type = prop.type;
  47251. var valid = !type || type === true;
  47252. var expectedTypes = [];
  47253. if (type) {
  47254. if (!Array.isArray(type)) {
  47255. type = [type];
  47256. }
  47257. for (var i = 0; i < type.length && !valid; i++) {
  47258. var assertedType = assertType(value, type[i]);
  47259. expectedTypes.push(assertedType.expectedType || '');
  47260. valid = assertedType.valid;
  47261. }
  47262. }
  47263. if (!valid) {
  47264. warn(
  47265. getInvalidTypeMessage(name, value, expectedTypes),
  47266. vm
  47267. );
  47268. return
  47269. }
  47270. var validator = prop.validator;
  47271. if (validator) {
  47272. if (!validator(value)) {
  47273. warn(
  47274. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  47275. vm
  47276. );
  47277. }
  47278. }
  47279. }
  47280. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  47281. function assertType (value, type) {
  47282. var valid;
  47283. var expectedType = getType(type);
  47284. if (simpleCheckRE.test(expectedType)) {
  47285. var t = typeof value;
  47286. valid = t === expectedType.toLowerCase();
  47287. // for primitive wrapper objects
  47288. if (!valid && t === 'object') {
  47289. valid = value instanceof type;
  47290. }
  47291. } else if (expectedType === 'Object') {
  47292. valid = isPlainObject(value);
  47293. } else if (expectedType === 'Array') {
  47294. valid = Array.isArray(value);
  47295. } else {
  47296. valid = value instanceof type;
  47297. }
  47298. return {
  47299. valid: valid,
  47300. expectedType: expectedType
  47301. }
  47302. }
  47303. /**
  47304. * Use function string name to check built-in types,
  47305. * because a simple equality check will fail when running
  47306. * across different vms / iframes.
  47307. */
  47308. function getType (fn) {
  47309. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  47310. return match ? match[1] : ''
  47311. }
  47312. function isSameType (a, b) {
  47313. return getType(a) === getType(b)
  47314. }
  47315. function getTypeIndex (type, expectedTypes) {
  47316. if (!Array.isArray(expectedTypes)) {
  47317. return isSameType(expectedTypes, type) ? 0 : -1
  47318. }
  47319. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  47320. if (isSameType(expectedTypes[i], type)) {
  47321. return i
  47322. }
  47323. }
  47324. return -1
  47325. }
  47326. function getInvalidTypeMessage (name, value, expectedTypes) {
  47327. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  47328. " Expected " + (expectedTypes.map(capitalize).join(', '));
  47329. var expectedType = expectedTypes[0];
  47330. var receivedType = toRawType(value);
  47331. var expectedValue = styleValue(value, expectedType);
  47332. var receivedValue = styleValue(value, receivedType);
  47333. // check if we need to specify expected value
  47334. if (expectedTypes.length === 1 &&
  47335. isExplicable(expectedType) &&
  47336. !isBoolean(expectedType, receivedType)) {
  47337. message += " with value " + expectedValue;
  47338. }
  47339. message += ", got " + receivedType + " ";
  47340. // check if we need to specify received value
  47341. if (isExplicable(receivedType)) {
  47342. message += "with value " + receivedValue + ".";
  47343. }
  47344. return message
  47345. }
  47346. function styleValue (value, type) {
  47347. if (type === 'String') {
  47348. return ("\"" + value + "\"")
  47349. } else if (type === 'Number') {
  47350. return ("" + (Number(value)))
  47351. } else {
  47352. return ("" + value)
  47353. }
  47354. }
  47355. function isExplicable (value) {
  47356. var explicitTypes = ['string', 'number', 'boolean'];
  47357. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  47358. }
  47359. function isBoolean () {
  47360. var args = [], len = arguments.length;
  47361. while ( len-- ) args[ len ] = arguments[ len ];
  47362. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  47363. }
  47364. /* */
  47365. function handleError (err, vm, info) {
  47366. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  47367. // See: https://github.com/vuejs/vuex/issues/1505
  47368. pushTarget();
  47369. try {
  47370. if (vm) {
  47371. var cur = vm;
  47372. while ((cur = cur.$parent)) {
  47373. var hooks = cur.$options.errorCaptured;
  47374. if (hooks) {
  47375. for (var i = 0; i < hooks.length; i++) {
  47376. try {
  47377. var capture = hooks[i].call(cur, err, vm, info) === false;
  47378. if (capture) { return }
  47379. } catch (e) {
  47380. globalHandleError(e, cur, 'errorCaptured hook');
  47381. }
  47382. }
  47383. }
  47384. }
  47385. }
  47386. globalHandleError(err, vm, info);
  47387. } finally {
  47388. popTarget();
  47389. }
  47390. }
  47391. function invokeWithErrorHandling (
  47392. handler,
  47393. context,
  47394. args,
  47395. vm,
  47396. info
  47397. ) {
  47398. var res;
  47399. try {
  47400. res = args ? handler.apply(context, args) : handler.call(context);
  47401. if (res && !res._isVue && isPromise(res) && !res._handled) {
  47402. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  47403. // issue #9511
  47404. // avoid catch triggering multiple times when nested calls
  47405. res._handled = true;
  47406. }
  47407. } catch (e) {
  47408. handleError(e, vm, info);
  47409. }
  47410. return res
  47411. }
  47412. function globalHandleError (err, vm, info) {
  47413. if (config.errorHandler) {
  47414. try {
  47415. return config.errorHandler.call(null, err, vm, info)
  47416. } catch (e) {
  47417. // if the user intentionally throws the original error in the handler,
  47418. // do not log it twice
  47419. if (e !== err) {
  47420. logError(e, null, 'config.errorHandler');
  47421. }
  47422. }
  47423. }
  47424. logError(err, vm, info);
  47425. }
  47426. function logError (err, vm, info) {
  47427. {
  47428. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  47429. }
  47430. /* istanbul ignore else */
  47431. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  47432. console.error(err);
  47433. } else {
  47434. throw err
  47435. }
  47436. }
  47437. /* */
  47438. var isUsingMicroTask = false;
  47439. var callbacks = [];
  47440. var pending = false;
  47441. function flushCallbacks () {
  47442. pending = false;
  47443. var copies = callbacks.slice(0);
  47444. callbacks.length = 0;
  47445. for (var i = 0; i < copies.length; i++) {
  47446. copies[i]();
  47447. }
  47448. }
  47449. // Here we have async deferring wrappers using microtasks.
  47450. // In 2.5 we used (macro) tasks (in combination with microtasks).
  47451. // However, it has subtle problems when state is changed right before repaint
  47452. // (e.g. #6813, out-in transitions).
  47453. // Also, using (macro) tasks in event handler would cause some weird behaviors
  47454. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  47455. // So we now use microtasks everywhere, again.
  47456. // A major drawback of this tradeoff is that there are some scenarios
  47457. // where microtasks have too high a priority and fire in between supposedly
  47458. // sequential events (e.g. #4521, #6690, which have workarounds)
  47459. // or even between bubbling of the same event (#6566).
  47460. var timerFunc;
  47461. // The nextTick behavior leverages the microtask queue, which can be accessed
  47462. // via either native Promise.then or MutationObserver.
  47463. // MutationObserver has wider support, however it is seriously bugged in
  47464. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  47465. // completely stops working after triggering a few times... so, if native
  47466. // Promise is available, we will use it:
  47467. /* istanbul ignore next, $flow-disable-line */
  47468. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  47469. var p = Promise.resolve();
  47470. timerFunc = function () {
  47471. p.then(flushCallbacks);
  47472. // In problematic UIWebViews, Promise.then doesn't completely break, but
  47473. // it can get stuck in a weird state where callbacks are pushed into the
  47474. // microtask queue but the queue isn't being flushed, until the browser
  47475. // needs to do some other work, e.g. handle a timer. Therefore we can
  47476. // "force" the microtask queue to be flushed by adding an empty timer.
  47477. if (isIOS) { setTimeout(noop); }
  47478. };
  47479. isUsingMicroTask = true;
  47480. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  47481. isNative(MutationObserver) ||
  47482. // PhantomJS and iOS 7.x
  47483. MutationObserver.toString() === '[object MutationObserverConstructor]'
  47484. )) {
  47485. // Use MutationObserver where native Promise is not available,
  47486. // e.g. PhantomJS, iOS7, Android 4.4
  47487. // (#6466 MutationObserver is unreliable in IE11)
  47488. var counter = 1;
  47489. var observer = new MutationObserver(flushCallbacks);
  47490. var textNode = document.createTextNode(String(counter));
  47491. observer.observe(textNode, {
  47492. characterData: true
  47493. });
  47494. timerFunc = function () {
  47495. counter = (counter + 1) % 2;
  47496. textNode.data = String(counter);
  47497. };
  47498. isUsingMicroTask = true;
  47499. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  47500. // Fallback to setImmediate.
  47501. // Technically it leverages the (macro) task queue,
  47502. // but it is still a better choice than setTimeout.
  47503. timerFunc = function () {
  47504. setImmediate(flushCallbacks);
  47505. };
  47506. } else {
  47507. // Fallback to setTimeout.
  47508. timerFunc = function () {
  47509. setTimeout(flushCallbacks, 0);
  47510. };
  47511. }
  47512. function nextTick (cb, ctx) {
  47513. var _resolve;
  47514. callbacks.push(function () {
  47515. if (cb) {
  47516. try {
  47517. cb.call(ctx);
  47518. } catch (e) {
  47519. handleError(e, ctx, 'nextTick');
  47520. }
  47521. } else if (_resolve) {
  47522. _resolve(ctx);
  47523. }
  47524. });
  47525. if (!pending) {
  47526. pending = true;
  47527. timerFunc();
  47528. }
  47529. // $flow-disable-line
  47530. if (!cb && typeof Promise !== 'undefined') {
  47531. return new Promise(function (resolve) {
  47532. _resolve = resolve;
  47533. })
  47534. }
  47535. }
  47536. /* */
  47537. var mark;
  47538. var measure;
  47539. {
  47540. var perf = inBrowser && window.performance;
  47541. /* istanbul ignore if */
  47542. if (
  47543. perf &&
  47544. perf.mark &&
  47545. perf.measure &&
  47546. perf.clearMarks &&
  47547. perf.clearMeasures
  47548. ) {
  47549. mark = function (tag) { return perf.mark(tag); };
  47550. measure = function (name, startTag, endTag) {
  47551. perf.measure(name, startTag, endTag);
  47552. perf.clearMarks(startTag);
  47553. perf.clearMarks(endTag);
  47554. // perf.clearMeasures(name)
  47555. };
  47556. }
  47557. }
  47558. /* not type checking this file because flow doesn't play well with Proxy */
  47559. var initProxy;
  47560. {
  47561. var allowedGlobals = makeMap(
  47562. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  47563. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  47564. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  47565. 'require' // for Webpack/Browserify
  47566. );
  47567. var warnNonPresent = function (target, key) {
  47568. warn(
  47569. "Property or method \"" + key + "\" is not defined on the instance but " +
  47570. 'referenced during render. Make sure that this property is reactive, ' +
  47571. 'either in the data option, or for class-based components, by ' +
  47572. 'initializing the property. ' +
  47573. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  47574. target
  47575. );
  47576. };
  47577. var warnReservedPrefix = function (target, key) {
  47578. warn(
  47579. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  47580. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  47581. 'prevent conflicts with Vue internals. ' +
  47582. 'See: https://vuejs.org/v2/api/#data',
  47583. target
  47584. );
  47585. };
  47586. var hasProxy =
  47587. typeof Proxy !== 'undefined' && isNative(Proxy);
  47588. if (hasProxy) {
  47589. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  47590. config.keyCodes = new Proxy(config.keyCodes, {
  47591. set: function set (target, key, value) {
  47592. if (isBuiltInModifier(key)) {
  47593. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  47594. return false
  47595. } else {
  47596. target[key] = value;
  47597. return true
  47598. }
  47599. }
  47600. });
  47601. }
  47602. var hasHandler = {
  47603. has: function has (target, key) {
  47604. var has = key in target;
  47605. var isAllowed = allowedGlobals(key) ||
  47606. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  47607. if (!has && !isAllowed) {
  47608. if (key in target.$data) { warnReservedPrefix(target, key); }
  47609. else { warnNonPresent(target, key); }
  47610. }
  47611. return has || !isAllowed
  47612. }
  47613. };
  47614. var getHandler = {
  47615. get: function get (target, key) {
  47616. if (typeof key === 'string' && !(key in target)) {
  47617. if (key in target.$data) { warnReservedPrefix(target, key); }
  47618. else { warnNonPresent(target, key); }
  47619. }
  47620. return target[key]
  47621. }
  47622. };
  47623. initProxy = function initProxy (vm) {
  47624. if (hasProxy) {
  47625. // determine which proxy handler to use
  47626. var options = vm.$options;
  47627. var handlers = options.render && options.render._withStripped
  47628. ? getHandler
  47629. : hasHandler;
  47630. vm._renderProxy = new Proxy(vm, handlers);
  47631. } else {
  47632. vm._renderProxy = vm;
  47633. }
  47634. };
  47635. }
  47636. /* */
  47637. var seenObjects = new _Set();
  47638. /**
  47639. * Recursively traverse an object to evoke all converted
  47640. * getters, so that every nested property inside the object
  47641. * is collected as a "deep" dependency.
  47642. */
  47643. function traverse (val) {
  47644. _traverse(val, seenObjects);
  47645. seenObjects.clear();
  47646. }
  47647. function _traverse (val, seen) {
  47648. var i, keys;
  47649. var isA = Array.isArray(val);
  47650. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  47651. return
  47652. }
  47653. if (val.__ob__) {
  47654. var depId = val.__ob__.dep.id;
  47655. if (seen.has(depId)) {
  47656. return
  47657. }
  47658. seen.add(depId);
  47659. }
  47660. if (isA) {
  47661. i = val.length;
  47662. while (i--) { _traverse(val[i], seen); }
  47663. } else {
  47664. keys = Object.keys(val);
  47665. i = keys.length;
  47666. while (i--) { _traverse(val[keys[i]], seen); }
  47667. }
  47668. }
  47669. /* */
  47670. var normalizeEvent = cached(function (name) {
  47671. var passive = name.charAt(0) === '&';
  47672. name = passive ? name.slice(1) : name;
  47673. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  47674. name = once$$1 ? name.slice(1) : name;
  47675. var capture = name.charAt(0) === '!';
  47676. name = capture ? name.slice(1) : name;
  47677. return {
  47678. name: name,
  47679. once: once$$1,
  47680. capture: capture,
  47681. passive: passive
  47682. }
  47683. });
  47684. function createFnInvoker (fns, vm) {
  47685. function invoker () {
  47686. var arguments$1 = arguments;
  47687. var fns = invoker.fns;
  47688. if (Array.isArray(fns)) {
  47689. var cloned = fns.slice();
  47690. for (var i = 0; i < cloned.length; i++) {
  47691. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  47692. }
  47693. } else {
  47694. // return handler return value for single handlers
  47695. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  47696. }
  47697. }
  47698. invoker.fns = fns;
  47699. return invoker
  47700. }
  47701. function updateListeners (
  47702. on,
  47703. oldOn,
  47704. add,
  47705. remove$$1,
  47706. createOnceHandler,
  47707. vm
  47708. ) {
  47709. var name, def$$1, cur, old, event;
  47710. for (name in on) {
  47711. def$$1 = cur = on[name];
  47712. old = oldOn[name];
  47713. event = normalizeEvent(name);
  47714. if (isUndef(cur)) {
  47715. warn(
  47716. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  47717. vm
  47718. );
  47719. } else if (isUndef(old)) {
  47720. if (isUndef(cur.fns)) {
  47721. cur = on[name] = createFnInvoker(cur, vm);
  47722. }
  47723. if (isTrue(event.once)) {
  47724. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  47725. }
  47726. add(event.name, cur, event.capture, event.passive, event.params);
  47727. } else if (cur !== old) {
  47728. old.fns = cur;
  47729. on[name] = old;
  47730. }
  47731. }
  47732. for (name in oldOn) {
  47733. if (isUndef(on[name])) {
  47734. event = normalizeEvent(name);
  47735. remove$$1(event.name, oldOn[name], event.capture);
  47736. }
  47737. }
  47738. }
  47739. /* */
  47740. function mergeVNodeHook (def, hookKey, hook) {
  47741. if (def instanceof VNode) {
  47742. def = def.data.hook || (def.data.hook = {});
  47743. }
  47744. var invoker;
  47745. var oldHook = def[hookKey];
  47746. function wrappedHook () {
  47747. hook.apply(this, arguments);
  47748. // important: remove merged hook to ensure it's called only once
  47749. // and prevent memory leak
  47750. remove(invoker.fns, wrappedHook);
  47751. }
  47752. if (isUndef(oldHook)) {
  47753. // no existing hook
  47754. invoker = createFnInvoker([wrappedHook]);
  47755. } else {
  47756. /* istanbul ignore if */
  47757. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  47758. // already a merged invoker
  47759. invoker = oldHook;
  47760. invoker.fns.push(wrappedHook);
  47761. } else {
  47762. // existing plain hook
  47763. invoker = createFnInvoker([oldHook, wrappedHook]);
  47764. }
  47765. }
  47766. invoker.merged = true;
  47767. def[hookKey] = invoker;
  47768. }
  47769. /* */
  47770. function extractPropsFromVNodeData (
  47771. data,
  47772. Ctor,
  47773. tag
  47774. ) {
  47775. // we are only extracting raw values here.
  47776. // validation and default values are handled in the child
  47777. // component itself.
  47778. var propOptions = Ctor.options.props;
  47779. if (isUndef(propOptions)) {
  47780. return
  47781. }
  47782. var res = {};
  47783. var attrs = data.attrs;
  47784. var props = data.props;
  47785. if (isDef(attrs) || isDef(props)) {
  47786. for (var key in propOptions) {
  47787. var altKey = hyphenate(key);
  47788. {
  47789. var keyInLowerCase = key.toLowerCase();
  47790. if (
  47791. key !== keyInLowerCase &&
  47792. attrs && hasOwn(attrs, keyInLowerCase)
  47793. ) {
  47794. tip(
  47795. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  47796. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  47797. " \"" + key + "\". " +
  47798. "Note that HTML attributes are case-insensitive and camelCased " +
  47799. "props need to use their kebab-case equivalents when using in-DOM " +
  47800. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  47801. );
  47802. }
  47803. }
  47804. checkProp(res, props, key, altKey, true) ||
  47805. checkProp(res, attrs, key, altKey, false);
  47806. }
  47807. }
  47808. return res
  47809. }
  47810. function checkProp (
  47811. res,
  47812. hash,
  47813. key,
  47814. altKey,
  47815. preserve
  47816. ) {
  47817. if (isDef(hash)) {
  47818. if (hasOwn(hash, key)) {
  47819. res[key] = hash[key];
  47820. if (!preserve) {
  47821. delete hash[key];
  47822. }
  47823. return true
  47824. } else if (hasOwn(hash, altKey)) {
  47825. res[key] = hash[altKey];
  47826. if (!preserve) {
  47827. delete hash[altKey];
  47828. }
  47829. return true
  47830. }
  47831. }
  47832. return false
  47833. }
  47834. /* */
  47835. // The template compiler attempts to minimize the need for normalization by
  47836. // statically analyzing the template at compile time.
  47837. //
  47838. // For plain HTML markup, normalization can be completely skipped because the
  47839. // generated render function is guaranteed to return Array<VNode>. There are
  47840. // two cases where extra normalization is needed:
  47841. // 1. When the children contains components - because a functional component
  47842. // may return an Array instead of a single root. In this case, just a simple
  47843. // normalization is needed - if any child is an Array, we flatten the whole
  47844. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  47845. // because functional components already normalize their own children.
  47846. function simpleNormalizeChildren (children) {
  47847. for (var i = 0; i < children.length; i++) {
  47848. if (Array.isArray(children[i])) {
  47849. return Array.prototype.concat.apply([], children)
  47850. }
  47851. }
  47852. return children
  47853. }
  47854. // 2. When the children contains constructs that always generated nested Arrays,
  47855. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  47856. // with hand-written render functions / JSX. In such cases a full normalization
  47857. // is needed to cater to all possible types of children values.
  47858. function normalizeChildren (children) {
  47859. return isPrimitive(children)
  47860. ? [createTextVNode(children)]
  47861. : Array.isArray(children)
  47862. ? normalizeArrayChildren(children)
  47863. : undefined
  47864. }
  47865. function isTextNode (node) {
  47866. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  47867. }
  47868. function normalizeArrayChildren (children, nestedIndex) {
  47869. var res = [];
  47870. var i, c, lastIndex, last;
  47871. for (i = 0; i < children.length; i++) {
  47872. c = children[i];
  47873. if (isUndef(c) || typeof c === 'boolean') { continue }
  47874. lastIndex = res.length - 1;
  47875. last = res[lastIndex];
  47876. // nested
  47877. if (Array.isArray(c)) {
  47878. if (c.length > 0) {
  47879. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  47880. // merge adjacent text nodes
  47881. if (isTextNode(c[0]) && isTextNode(last)) {
  47882. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  47883. c.shift();
  47884. }
  47885. res.push.apply(res, c);
  47886. }
  47887. } else if (isPrimitive(c)) {
  47888. if (isTextNode(last)) {
  47889. // merge adjacent text nodes
  47890. // this is necessary for SSR hydration because text nodes are
  47891. // essentially merged when rendered to HTML strings
  47892. res[lastIndex] = createTextVNode(last.text + c);
  47893. } else if (c !== '') {
  47894. // convert primitive to vnode
  47895. res.push(createTextVNode(c));
  47896. }
  47897. } else {
  47898. if (isTextNode(c) && isTextNode(last)) {
  47899. // merge adjacent text nodes
  47900. res[lastIndex] = createTextVNode(last.text + c.text);
  47901. } else {
  47902. // default key for nested array children (likely generated by v-for)
  47903. if (isTrue(children._isVList) &&
  47904. isDef(c.tag) &&
  47905. isUndef(c.key) &&
  47906. isDef(nestedIndex)) {
  47907. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  47908. }
  47909. res.push(c);
  47910. }
  47911. }
  47912. }
  47913. return res
  47914. }
  47915. /* */
  47916. function initProvide (vm) {
  47917. var provide = vm.$options.provide;
  47918. if (provide) {
  47919. vm._provided = typeof provide === 'function'
  47920. ? provide.call(vm)
  47921. : provide;
  47922. }
  47923. }
  47924. function initInjections (vm) {
  47925. var result = resolveInject(vm.$options.inject, vm);
  47926. if (result) {
  47927. toggleObserving(false);
  47928. Object.keys(result).forEach(function (key) {
  47929. /* istanbul ignore else */
  47930. {
  47931. defineReactive$$1(vm, key, result[key], function () {
  47932. warn(
  47933. "Avoid mutating an injected value directly since the changes will be " +
  47934. "overwritten whenever the provided component re-renders. " +
  47935. "injection being mutated: \"" + key + "\"",
  47936. vm
  47937. );
  47938. });
  47939. }
  47940. });
  47941. toggleObserving(true);
  47942. }
  47943. }
  47944. function resolveInject (inject, vm) {
  47945. if (inject) {
  47946. // inject is :any because flow is not smart enough to figure out cached
  47947. var result = Object.create(null);
  47948. var keys = hasSymbol
  47949. ? Reflect.ownKeys(inject)
  47950. : Object.keys(inject);
  47951. for (var i = 0; i < keys.length; i++) {
  47952. var key = keys[i];
  47953. // #6574 in case the inject object is observed...
  47954. if (key === '__ob__') { continue }
  47955. var provideKey = inject[key].from;
  47956. var source = vm;
  47957. while (source) {
  47958. if (source._provided && hasOwn(source._provided, provideKey)) {
  47959. result[key] = source._provided[provideKey];
  47960. break
  47961. }
  47962. source = source.$parent;
  47963. }
  47964. if (!source) {
  47965. if ('default' in inject[key]) {
  47966. var provideDefault = inject[key].default;
  47967. result[key] = typeof provideDefault === 'function'
  47968. ? provideDefault.call(vm)
  47969. : provideDefault;
  47970. } else {
  47971. warn(("Injection \"" + key + "\" not found"), vm);
  47972. }
  47973. }
  47974. }
  47975. return result
  47976. }
  47977. }
  47978. /* */
  47979. /**
  47980. * Runtime helper for resolving raw children VNodes into a slot object.
  47981. */
  47982. function resolveSlots (
  47983. children,
  47984. context
  47985. ) {
  47986. if (!children || !children.length) {
  47987. return {}
  47988. }
  47989. var slots = {};
  47990. for (var i = 0, l = children.length; i < l; i++) {
  47991. var child = children[i];
  47992. var data = child.data;
  47993. // remove slot attribute if the node is resolved as a Vue slot node
  47994. if (data && data.attrs && data.attrs.slot) {
  47995. delete data.attrs.slot;
  47996. }
  47997. // named slots should only be respected if the vnode was rendered in the
  47998. // same context.
  47999. if ((child.context === context || child.fnContext === context) &&
  48000. data && data.slot != null
  48001. ) {
  48002. var name = data.slot;
  48003. var slot = (slots[name] || (slots[name] = []));
  48004. if (child.tag === 'template') {
  48005. slot.push.apply(slot, child.children || []);
  48006. } else {
  48007. slot.push(child);
  48008. }
  48009. } else {
  48010. (slots.default || (slots.default = [])).push(child);
  48011. }
  48012. }
  48013. // ignore slots that contains only whitespace
  48014. for (var name$1 in slots) {
  48015. if (slots[name$1].every(isWhitespace)) {
  48016. delete slots[name$1];
  48017. }
  48018. }
  48019. return slots
  48020. }
  48021. function isWhitespace (node) {
  48022. return (node.isComment && !node.asyncFactory) || node.text === ' '
  48023. }
  48024. /* */
  48025. function normalizeScopedSlots (
  48026. slots,
  48027. normalSlots,
  48028. prevSlots
  48029. ) {
  48030. var res;
  48031. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  48032. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  48033. var key = slots && slots.$key;
  48034. if (!slots) {
  48035. res = {};
  48036. } else if (slots._normalized) {
  48037. // fast path 1: child component re-render only, parent did not change
  48038. return slots._normalized
  48039. } else if (
  48040. isStable &&
  48041. prevSlots &&
  48042. prevSlots !== emptyObject &&
  48043. key === prevSlots.$key &&
  48044. !hasNormalSlots &&
  48045. !prevSlots.$hasNormal
  48046. ) {
  48047. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  48048. // only need to normalize once
  48049. return prevSlots
  48050. } else {
  48051. res = {};
  48052. for (var key$1 in slots) {
  48053. if (slots[key$1] && key$1[0] !== '$') {
  48054. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  48055. }
  48056. }
  48057. }
  48058. // expose normal slots on scopedSlots
  48059. for (var key$2 in normalSlots) {
  48060. if (!(key$2 in res)) {
  48061. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  48062. }
  48063. }
  48064. // avoriaz seems to mock a non-extensible $scopedSlots object
  48065. // and when that is passed down this would cause an error
  48066. if (slots && Object.isExtensible(slots)) {
  48067. (slots)._normalized = res;
  48068. }
  48069. def(res, '$stable', isStable);
  48070. def(res, '$key', key);
  48071. def(res, '$hasNormal', hasNormalSlots);
  48072. return res
  48073. }
  48074. function normalizeScopedSlot(normalSlots, key, fn) {
  48075. var normalized = function () {
  48076. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  48077. res = res && typeof res === 'object' && !Array.isArray(res)
  48078. ? [res] // single vnode
  48079. : normalizeChildren(res);
  48080. return res && (
  48081. res.length === 0 ||
  48082. (res.length === 1 && res[0].isComment) // #9658
  48083. ) ? undefined
  48084. : res
  48085. };
  48086. // this is a slot using the new v-slot syntax without scope. although it is
  48087. // compiled as a scoped slot, render fn users would expect it to be present
  48088. // on this.$slots because the usage is semantically a normal slot.
  48089. if (fn.proxy) {
  48090. Object.defineProperty(normalSlots, key, {
  48091. get: normalized,
  48092. enumerable: true,
  48093. configurable: true
  48094. });
  48095. }
  48096. return normalized
  48097. }
  48098. function proxyNormalSlot(slots, key) {
  48099. return function () { return slots[key]; }
  48100. }
  48101. /* */
  48102. /**
  48103. * Runtime helper for rendering v-for lists.
  48104. */
  48105. function renderList (
  48106. val,
  48107. render
  48108. ) {
  48109. var ret, i, l, keys, key;
  48110. if (Array.isArray(val) || typeof val === 'string') {
  48111. ret = new Array(val.length);
  48112. for (i = 0, l = val.length; i < l; i++) {
  48113. ret[i] = render(val[i], i);
  48114. }
  48115. } else if (typeof val === 'number') {
  48116. ret = new Array(val);
  48117. for (i = 0; i < val; i++) {
  48118. ret[i] = render(i + 1, i);
  48119. }
  48120. } else if (isObject(val)) {
  48121. if (hasSymbol && val[Symbol.iterator]) {
  48122. ret = [];
  48123. var iterator = val[Symbol.iterator]();
  48124. var result = iterator.next();
  48125. while (!result.done) {
  48126. ret.push(render(result.value, ret.length));
  48127. result = iterator.next();
  48128. }
  48129. } else {
  48130. keys = Object.keys(val);
  48131. ret = new Array(keys.length);
  48132. for (i = 0, l = keys.length; i < l; i++) {
  48133. key = keys[i];
  48134. ret[i] = render(val[key], key, i);
  48135. }
  48136. }
  48137. }
  48138. if (!isDef(ret)) {
  48139. ret = [];
  48140. }
  48141. (ret)._isVList = true;
  48142. return ret
  48143. }
  48144. /* */
  48145. /**
  48146. * Runtime helper for rendering <slot>
  48147. */
  48148. function renderSlot (
  48149. name,
  48150. fallback,
  48151. props,
  48152. bindObject
  48153. ) {
  48154. var scopedSlotFn = this.$scopedSlots[name];
  48155. var nodes;
  48156. if (scopedSlotFn) { // scoped slot
  48157. props = props || {};
  48158. if (bindObject) {
  48159. if (!isObject(bindObject)) {
  48160. warn(
  48161. 'slot v-bind without argument expects an Object',
  48162. this
  48163. );
  48164. }
  48165. props = extend(extend({}, bindObject), props);
  48166. }
  48167. nodes = scopedSlotFn(props) || fallback;
  48168. } else {
  48169. nodes = this.$slots[name] || fallback;
  48170. }
  48171. var target = props && props.slot;
  48172. if (target) {
  48173. return this.$createElement('template', { slot: target }, nodes)
  48174. } else {
  48175. return nodes
  48176. }
  48177. }
  48178. /* */
  48179. /**
  48180. * Runtime helper for resolving filters
  48181. */
  48182. function resolveFilter (id) {
  48183. return resolveAsset(this.$options, 'filters', id, true) || identity
  48184. }
  48185. /* */
  48186. function isKeyNotMatch (expect, actual) {
  48187. if (Array.isArray(expect)) {
  48188. return expect.indexOf(actual) === -1
  48189. } else {
  48190. return expect !== actual
  48191. }
  48192. }
  48193. /**
  48194. * Runtime helper for checking keyCodes from config.
  48195. * exposed as Vue.prototype._k
  48196. * passing in eventKeyName as last argument separately for backwards compat
  48197. */
  48198. function checkKeyCodes (
  48199. eventKeyCode,
  48200. key,
  48201. builtInKeyCode,
  48202. eventKeyName,
  48203. builtInKeyName
  48204. ) {
  48205. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  48206. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  48207. return isKeyNotMatch(builtInKeyName, eventKeyName)
  48208. } else if (mappedKeyCode) {
  48209. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  48210. } else if (eventKeyName) {
  48211. return hyphenate(eventKeyName) !== key
  48212. }
  48213. }
  48214. /* */
  48215. /**
  48216. * Runtime helper for merging v-bind="object" into a VNode's data.
  48217. */
  48218. function bindObjectProps (
  48219. data,
  48220. tag,
  48221. value,
  48222. asProp,
  48223. isSync
  48224. ) {
  48225. if (value) {
  48226. if (!isObject(value)) {
  48227. warn(
  48228. 'v-bind without argument expects an Object or Array value',
  48229. this
  48230. );
  48231. } else {
  48232. if (Array.isArray(value)) {
  48233. value = toObject(value);
  48234. }
  48235. var hash;
  48236. var loop = function ( key ) {
  48237. if (
  48238. key === 'class' ||
  48239. key === 'style' ||
  48240. isReservedAttribute(key)
  48241. ) {
  48242. hash = data;
  48243. } else {
  48244. var type = data.attrs && data.attrs.type;
  48245. hash = asProp || config.mustUseProp(tag, type, key)
  48246. ? data.domProps || (data.domProps = {})
  48247. : data.attrs || (data.attrs = {});
  48248. }
  48249. var camelizedKey = camelize(key);
  48250. var hyphenatedKey = hyphenate(key);
  48251. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  48252. hash[key] = value[key];
  48253. if (isSync) {
  48254. var on = data.on || (data.on = {});
  48255. on[("update:" + key)] = function ($event) {
  48256. value[key] = $event;
  48257. };
  48258. }
  48259. }
  48260. };
  48261. for (var key in value) loop( key );
  48262. }
  48263. }
  48264. return data
  48265. }
  48266. /* */
  48267. /**
  48268. * Runtime helper for rendering static trees.
  48269. */
  48270. function renderStatic (
  48271. index,
  48272. isInFor
  48273. ) {
  48274. var cached = this._staticTrees || (this._staticTrees = []);
  48275. var tree = cached[index];
  48276. // if has already-rendered static tree and not inside v-for,
  48277. // we can reuse the same tree.
  48278. if (tree && !isInFor) {
  48279. return tree
  48280. }
  48281. // otherwise, render a fresh tree.
  48282. tree = cached[index] = this.$options.staticRenderFns[index].call(
  48283. this._renderProxy,
  48284. null,
  48285. this // for render fns generated for functional component templates
  48286. );
  48287. markStatic(tree, ("__static__" + index), false);
  48288. return tree
  48289. }
  48290. /**
  48291. * Runtime helper for v-once.
  48292. * Effectively it means marking the node as static with a unique key.
  48293. */
  48294. function markOnce (
  48295. tree,
  48296. index,
  48297. key
  48298. ) {
  48299. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  48300. return tree
  48301. }
  48302. function markStatic (
  48303. tree,
  48304. key,
  48305. isOnce
  48306. ) {
  48307. if (Array.isArray(tree)) {
  48308. for (var i = 0; i < tree.length; i++) {
  48309. if (tree[i] && typeof tree[i] !== 'string') {
  48310. markStaticNode(tree[i], (key + "_" + i), isOnce);
  48311. }
  48312. }
  48313. } else {
  48314. markStaticNode(tree, key, isOnce);
  48315. }
  48316. }
  48317. function markStaticNode (node, key, isOnce) {
  48318. node.isStatic = true;
  48319. node.key = key;
  48320. node.isOnce = isOnce;
  48321. }
  48322. /* */
  48323. function bindObjectListeners (data, value) {
  48324. if (value) {
  48325. if (!isPlainObject(value)) {
  48326. warn(
  48327. 'v-on without argument expects an Object value',
  48328. this
  48329. );
  48330. } else {
  48331. var on = data.on = data.on ? extend({}, data.on) : {};
  48332. for (var key in value) {
  48333. var existing = on[key];
  48334. var ours = value[key];
  48335. on[key] = existing ? [].concat(existing, ours) : ours;
  48336. }
  48337. }
  48338. }
  48339. return data
  48340. }
  48341. /* */
  48342. function resolveScopedSlots (
  48343. fns, // see flow/vnode
  48344. res,
  48345. // the following are added in 2.6
  48346. hasDynamicKeys,
  48347. contentHashKey
  48348. ) {
  48349. res = res || { $stable: !hasDynamicKeys };
  48350. for (var i = 0; i < fns.length; i++) {
  48351. var slot = fns[i];
  48352. if (Array.isArray(slot)) {
  48353. resolveScopedSlots(slot, res, hasDynamicKeys);
  48354. } else if (slot) {
  48355. // marker for reverse proxying v-slot without scope on this.$slots
  48356. if (slot.proxy) {
  48357. slot.fn.proxy = true;
  48358. }
  48359. res[slot.key] = slot.fn;
  48360. }
  48361. }
  48362. if (contentHashKey) {
  48363. (res).$key = contentHashKey;
  48364. }
  48365. return res
  48366. }
  48367. /* */
  48368. function bindDynamicKeys (baseObj, values) {
  48369. for (var i = 0; i < values.length; i += 2) {
  48370. var key = values[i];
  48371. if (typeof key === 'string' && key) {
  48372. baseObj[values[i]] = values[i + 1];
  48373. } else if (key !== '' && key !== null) {
  48374. // null is a special value for explicitly removing a binding
  48375. warn(
  48376. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  48377. this
  48378. );
  48379. }
  48380. }
  48381. return baseObj
  48382. }
  48383. // helper to dynamically append modifier runtime markers to event names.
  48384. // ensure only append when value is already string, otherwise it will be cast
  48385. // to string and cause the type check to miss.
  48386. function prependModifier (value, symbol) {
  48387. return typeof value === 'string' ? symbol + value : value
  48388. }
  48389. /* */
  48390. function installRenderHelpers (target) {
  48391. target._o = markOnce;
  48392. target._n = toNumber;
  48393. target._s = toString;
  48394. target._l = renderList;
  48395. target._t = renderSlot;
  48396. target._q = looseEqual;
  48397. target._i = looseIndexOf;
  48398. target._m = renderStatic;
  48399. target._f = resolveFilter;
  48400. target._k = checkKeyCodes;
  48401. target._b = bindObjectProps;
  48402. target._v = createTextVNode;
  48403. target._e = createEmptyVNode;
  48404. target._u = resolveScopedSlots;
  48405. target._g = bindObjectListeners;
  48406. target._d = bindDynamicKeys;
  48407. target._p = prependModifier;
  48408. }
  48409. /* */
  48410. function FunctionalRenderContext (
  48411. data,
  48412. props,
  48413. children,
  48414. parent,
  48415. Ctor
  48416. ) {
  48417. var this$1 = this;
  48418. var options = Ctor.options;
  48419. // ensure the createElement function in functional components
  48420. // gets a unique context - this is necessary for correct named slot check
  48421. var contextVm;
  48422. if (hasOwn(parent, '_uid')) {
  48423. contextVm = Object.create(parent);
  48424. // $flow-disable-line
  48425. contextVm._original = parent;
  48426. } else {
  48427. // the context vm passed in is a functional context as well.
  48428. // in this case we want to make sure we are able to get a hold to the
  48429. // real context instance.
  48430. contextVm = parent;
  48431. // $flow-disable-line
  48432. parent = parent._original;
  48433. }
  48434. var isCompiled = isTrue(options._compiled);
  48435. var needNormalization = !isCompiled;
  48436. this.data = data;
  48437. this.props = props;
  48438. this.children = children;
  48439. this.parent = parent;
  48440. this.listeners = data.on || emptyObject;
  48441. this.injections = resolveInject(options.inject, parent);
  48442. this.slots = function () {
  48443. if (!this$1.$slots) {
  48444. normalizeScopedSlots(
  48445. data.scopedSlots,
  48446. this$1.$slots = resolveSlots(children, parent)
  48447. );
  48448. }
  48449. return this$1.$slots
  48450. };
  48451. Object.defineProperty(this, 'scopedSlots', ({
  48452. enumerable: true,
  48453. get: function get () {
  48454. return normalizeScopedSlots(data.scopedSlots, this.slots())
  48455. }
  48456. }));
  48457. // support for compiled functional template
  48458. if (isCompiled) {
  48459. // exposing $options for renderStatic()
  48460. this.$options = options;
  48461. // pre-resolve slots for renderSlot()
  48462. this.$slots = this.slots();
  48463. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  48464. }
  48465. if (options._scopeId) {
  48466. this._c = function (a, b, c, d) {
  48467. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  48468. if (vnode && !Array.isArray(vnode)) {
  48469. vnode.fnScopeId = options._scopeId;
  48470. vnode.fnContext = parent;
  48471. }
  48472. return vnode
  48473. };
  48474. } else {
  48475. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  48476. }
  48477. }
  48478. installRenderHelpers(FunctionalRenderContext.prototype);
  48479. function createFunctionalComponent (
  48480. Ctor,
  48481. propsData,
  48482. data,
  48483. contextVm,
  48484. children
  48485. ) {
  48486. var options = Ctor.options;
  48487. var props = {};
  48488. var propOptions = options.props;
  48489. if (isDef(propOptions)) {
  48490. for (var key in propOptions) {
  48491. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  48492. }
  48493. } else {
  48494. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  48495. if (isDef(data.props)) { mergeProps(props, data.props); }
  48496. }
  48497. var renderContext = new FunctionalRenderContext(
  48498. data,
  48499. props,
  48500. children,
  48501. contextVm,
  48502. Ctor
  48503. );
  48504. var vnode = options.render.call(null, renderContext._c, renderContext);
  48505. if (vnode instanceof VNode) {
  48506. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  48507. } else if (Array.isArray(vnode)) {
  48508. var vnodes = normalizeChildren(vnode) || [];
  48509. var res = new Array(vnodes.length);
  48510. for (var i = 0; i < vnodes.length; i++) {
  48511. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  48512. }
  48513. return res
  48514. }
  48515. }
  48516. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  48517. // #7817 clone node before setting fnContext, otherwise if the node is reused
  48518. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  48519. // that should not be matched to match.
  48520. var clone = cloneVNode(vnode);
  48521. clone.fnContext = contextVm;
  48522. clone.fnOptions = options;
  48523. {
  48524. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  48525. }
  48526. if (data.slot) {
  48527. (clone.data || (clone.data = {})).slot = data.slot;
  48528. }
  48529. return clone
  48530. }
  48531. function mergeProps (to, from) {
  48532. for (var key in from) {
  48533. to[camelize(key)] = from[key];
  48534. }
  48535. }
  48536. /* */
  48537. /* */
  48538. /* */
  48539. /* */
  48540. // inline hooks to be invoked on component VNodes during patch
  48541. var componentVNodeHooks = {
  48542. init: function init (vnode, hydrating) {
  48543. if (
  48544. vnode.componentInstance &&
  48545. !vnode.componentInstance._isDestroyed &&
  48546. vnode.data.keepAlive
  48547. ) {
  48548. // kept-alive components, treat as a patch
  48549. var mountedNode = vnode; // work around flow
  48550. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  48551. } else {
  48552. var child = vnode.componentInstance = createComponentInstanceForVnode(
  48553. vnode,
  48554. activeInstance
  48555. );
  48556. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  48557. }
  48558. },
  48559. prepatch: function prepatch (oldVnode, vnode) {
  48560. var options = vnode.componentOptions;
  48561. var child = vnode.componentInstance = oldVnode.componentInstance;
  48562. updateChildComponent(
  48563. child,
  48564. options.propsData, // updated props
  48565. options.listeners, // updated listeners
  48566. vnode, // new parent vnode
  48567. options.children // new children
  48568. );
  48569. },
  48570. insert: function insert (vnode) {
  48571. var context = vnode.context;
  48572. var componentInstance = vnode.componentInstance;
  48573. if (!componentInstance._isMounted) {
  48574. componentInstance._isMounted = true;
  48575. callHook(componentInstance, 'mounted');
  48576. }
  48577. if (vnode.data.keepAlive) {
  48578. if (context._isMounted) {
  48579. // vue-router#1212
  48580. // During updates, a kept-alive component's child components may
  48581. // change, so directly walking the tree here may call activated hooks
  48582. // on incorrect children. Instead we push them into a queue which will
  48583. // be processed after the whole patch process ended.
  48584. queueActivatedComponent(componentInstance);
  48585. } else {
  48586. activateChildComponent(componentInstance, true /* direct */);
  48587. }
  48588. }
  48589. },
  48590. destroy: function destroy (vnode) {
  48591. var componentInstance = vnode.componentInstance;
  48592. if (!componentInstance._isDestroyed) {
  48593. if (!vnode.data.keepAlive) {
  48594. componentInstance.$destroy();
  48595. } else {
  48596. deactivateChildComponent(componentInstance, true /* direct */);
  48597. }
  48598. }
  48599. }
  48600. };
  48601. var hooksToMerge = Object.keys(componentVNodeHooks);
  48602. function createComponent (
  48603. Ctor,
  48604. data,
  48605. context,
  48606. children,
  48607. tag
  48608. ) {
  48609. if (isUndef(Ctor)) {
  48610. return
  48611. }
  48612. var baseCtor = context.$options._base;
  48613. // plain options object: turn it into a constructor
  48614. if (isObject(Ctor)) {
  48615. Ctor = baseCtor.extend(Ctor);
  48616. }
  48617. // if at this stage it's not a constructor or an async component factory,
  48618. // reject.
  48619. if (typeof Ctor !== 'function') {
  48620. {
  48621. warn(("Invalid Component definition: " + (String(Ctor))), context);
  48622. }
  48623. return
  48624. }
  48625. // async component
  48626. var asyncFactory;
  48627. if (isUndef(Ctor.cid)) {
  48628. asyncFactory = Ctor;
  48629. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  48630. if (Ctor === undefined) {
  48631. // return a placeholder node for async component, which is rendered
  48632. // as a comment node but preserves all the raw information for the node.
  48633. // the information will be used for async server-rendering and hydration.
  48634. return createAsyncPlaceholder(
  48635. asyncFactory,
  48636. data,
  48637. context,
  48638. children,
  48639. tag
  48640. )
  48641. }
  48642. }
  48643. data = data || {};
  48644. // resolve constructor options in case global mixins are applied after
  48645. // component constructor creation
  48646. resolveConstructorOptions(Ctor);
  48647. // transform component v-model data into props & events
  48648. if (isDef(data.model)) {
  48649. transformModel(Ctor.options, data);
  48650. }
  48651. // extract props
  48652. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  48653. // functional component
  48654. if (isTrue(Ctor.options.functional)) {
  48655. return createFunctionalComponent(Ctor, propsData, data, context, children)
  48656. }
  48657. // extract listeners, since these needs to be treated as
  48658. // child component listeners instead of DOM listeners
  48659. var listeners = data.on;
  48660. // replace with listeners with .native modifier
  48661. // so it gets processed during parent component patch.
  48662. data.on = data.nativeOn;
  48663. if (isTrue(Ctor.options.abstract)) {
  48664. // abstract components do not keep anything
  48665. // other than props & listeners & slot
  48666. // work around flow
  48667. var slot = data.slot;
  48668. data = {};
  48669. if (slot) {
  48670. data.slot = slot;
  48671. }
  48672. }
  48673. // install component management hooks onto the placeholder node
  48674. installComponentHooks(data);
  48675. // return a placeholder vnode
  48676. var name = Ctor.options.name || tag;
  48677. var vnode = new VNode(
  48678. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  48679. data, undefined, undefined, undefined, context,
  48680. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  48681. asyncFactory
  48682. );
  48683. return vnode
  48684. }
  48685. function createComponentInstanceForVnode (
  48686. vnode, // we know it's MountedComponentVNode but flow doesn't
  48687. parent // activeInstance in lifecycle state
  48688. ) {
  48689. var options = {
  48690. _isComponent: true,
  48691. _parentVnode: vnode,
  48692. parent: parent
  48693. };
  48694. // check inline-template render functions
  48695. var inlineTemplate = vnode.data.inlineTemplate;
  48696. if (isDef(inlineTemplate)) {
  48697. options.render = inlineTemplate.render;
  48698. options.staticRenderFns = inlineTemplate.staticRenderFns;
  48699. }
  48700. return new vnode.componentOptions.Ctor(options)
  48701. }
  48702. function installComponentHooks (data) {
  48703. var hooks = data.hook || (data.hook = {});
  48704. for (var i = 0; i < hooksToMerge.length; i++) {
  48705. var key = hooksToMerge[i];
  48706. var existing = hooks[key];
  48707. var toMerge = componentVNodeHooks[key];
  48708. if (existing !== toMerge && !(existing && existing._merged)) {
  48709. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  48710. }
  48711. }
  48712. }
  48713. function mergeHook$1 (f1, f2) {
  48714. var merged = function (a, b) {
  48715. // flow complains about extra args which is why we use any
  48716. f1(a, b);
  48717. f2(a, b);
  48718. };
  48719. merged._merged = true;
  48720. return merged
  48721. }
  48722. // transform component v-model info (value and callback) into
  48723. // prop and event handler respectively.
  48724. function transformModel (options, data) {
  48725. var prop = (options.model && options.model.prop) || 'value';
  48726. var event = (options.model && options.model.event) || 'input'
  48727. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  48728. var on = data.on || (data.on = {});
  48729. var existing = on[event];
  48730. var callback = data.model.callback;
  48731. if (isDef(existing)) {
  48732. if (
  48733. Array.isArray(existing)
  48734. ? existing.indexOf(callback) === -1
  48735. : existing !== callback
  48736. ) {
  48737. on[event] = [callback].concat(existing);
  48738. }
  48739. } else {
  48740. on[event] = callback;
  48741. }
  48742. }
  48743. /* */
  48744. var SIMPLE_NORMALIZE = 1;
  48745. var ALWAYS_NORMALIZE = 2;
  48746. // wrapper function for providing a more flexible interface
  48747. // without getting yelled at by flow
  48748. function createElement (
  48749. context,
  48750. tag,
  48751. data,
  48752. children,
  48753. normalizationType,
  48754. alwaysNormalize
  48755. ) {
  48756. if (Array.isArray(data) || isPrimitive(data)) {
  48757. normalizationType = children;
  48758. children = data;
  48759. data = undefined;
  48760. }
  48761. if (isTrue(alwaysNormalize)) {
  48762. normalizationType = ALWAYS_NORMALIZE;
  48763. }
  48764. return _createElement(context, tag, data, children, normalizationType)
  48765. }
  48766. function _createElement (
  48767. context,
  48768. tag,
  48769. data,
  48770. children,
  48771. normalizationType
  48772. ) {
  48773. if (isDef(data) && isDef((data).__ob__)) {
  48774. warn(
  48775. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  48776. 'Always create fresh vnode data objects in each render!',
  48777. context
  48778. );
  48779. return createEmptyVNode()
  48780. }
  48781. // object syntax in v-bind
  48782. if (isDef(data) && isDef(data.is)) {
  48783. tag = data.is;
  48784. }
  48785. if (!tag) {
  48786. // in case of component :is set to falsy value
  48787. return createEmptyVNode()
  48788. }
  48789. // warn against non-primitive key
  48790. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  48791. ) {
  48792. {
  48793. warn(
  48794. 'Avoid using non-primitive value as key, ' +
  48795. 'use string/number value instead.',
  48796. context
  48797. );
  48798. }
  48799. }
  48800. // support single function children as default scoped slot
  48801. if (Array.isArray(children) &&
  48802. typeof children[0] === 'function'
  48803. ) {
  48804. data = data || {};
  48805. data.scopedSlots = { default: children[0] };
  48806. children.length = 0;
  48807. }
  48808. if (normalizationType === ALWAYS_NORMALIZE) {
  48809. children = normalizeChildren(children);
  48810. } else if (normalizationType === SIMPLE_NORMALIZE) {
  48811. children = simpleNormalizeChildren(children);
  48812. }
  48813. var vnode, ns;
  48814. if (typeof tag === 'string') {
  48815. var Ctor;
  48816. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  48817. if (config.isReservedTag(tag)) {
  48818. // platform built-in elements
  48819. if (isDef(data) && isDef(data.nativeOn)) {
  48820. warn(
  48821. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  48822. context
  48823. );
  48824. }
  48825. vnode = new VNode(
  48826. config.parsePlatformTagName(tag), data, children,
  48827. undefined, undefined, context
  48828. );
  48829. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  48830. // component
  48831. vnode = createComponent(Ctor, data, context, children, tag);
  48832. } else {
  48833. // unknown or unlisted namespaced elements
  48834. // check at runtime because it may get assigned a namespace when its
  48835. // parent normalizes children
  48836. vnode = new VNode(
  48837. tag, data, children,
  48838. undefined, undefined, context
  48839. );
  48840. }
  48841. } else {
  48842. // direct component options / constructor
  48843. vnode = createComponent(tag, data, context, children);
  48844. }
  48845. if (Array.isArray(vnode)) {
  48846. return vnode
  48847. } else if (isDef(vnode)) {
  48848. if (isDef(ns)) { applyNS(vnode, ns); }
  48849. if (isDef(data)) { registerDeepBindings(data); }
  48850. return vnode
  48851. } else {
  48852. return createEmptyVNode()
  48853. }
  48854. }
  48855. function applyNS (vnode, ns, force) {
  48856. vnode.ns = ns;
  48857. if (vnode.tag === 'foreignObject') {
  48858. // use default namespace inside foreignObject
  48859. ns = undefined;
  48860. force = true;
  48861. }
  48862. if (isDef(vnode.children)) {
  48863. for (var i = 0, l = vnode.children.length; i < l; i++) {
  48864. var child = vnode.children[i];
  48865. if (isDef(child.tag) && (
  48866. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  48867. applyNS(child, ns, force);
  48868. }
  48869. }
  48870. }
  48871. }
  48872. // ref #5318
  48873. // necessary to ensure parent re-render when deep bindings like :style and
  48874. // :class are used on slot nodes
  48875. function registerDeepBindings (data) {
  48876. if (isObject(data.style)) {
  48877. traverse(data.style);
  48878. }
  48879. if (isObject(data.class)) {
  48880. traverse(data.class);
  48881. }
  48882. }
  48883. /* */
  48884. function initRender (vm) {
  48885. vm._vnode = null; // the root of the child tree
  48886. vm._staticTrees = null; // v-once cached trees
  48887. var options = vm.$options;
  48888. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  48889. var renderContext = parentVnode && parentVnode.context;
  48890. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  48891. vm.$scopedSlots = emptyObject;
  48892. // bind the createElement fn to this instance
  48893. // so that we get proper render context inside it.
  48894. // args order: tag, data, children, normalizationType, alwaysNormalize
  48895. // internal version is used by render functions compiled from templates
  48896. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  48897. // normalization is always applied for the public version, used in
  48898. // user-written render functions.
  48899. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  48900. // $attrs & $listeners are exposed for easier HOC creation.
  48901. // they need to be reactive so that HOCs using them are always updated
  48902. var parentData = parentVnode && parentVnode.data;
  48903. /* istanbul ignore else */
  48904. {
  48905. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  48906. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  48907. }, true);
  48908. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  48909. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  48910. }, true);
  48911. }
  48912. }
  48913. var currentRenderingInstance = null;
  48914. function renderMixin (Vue) {
  48915. // install runtime convenience helpers
  48916. installRenderHelpers(Vue.prototype);
  48917. Vue.prototype.$nextTick = function (fn) {
  48918. return nextTick(fn, this)
  48919. };
  48920. Vue.prototype._render = function () {
  48921. var vm = this;
  48922. var ref = vm.$options;
  48923. var render = ref.render;
  48924. var _parentVnode = ref._parentVnode;
  48925. if (_parentVnode) {
  48926. vm.$scopedSlots = normalizeScopedSlots(
  48927. _parentVnode.data.scopedSlots,
  48928. vm.$slots,
  48929. vm.$scopedSlots
  48930. );
  48931. }
  48932. // set parent vnode. this allows render functions to have access
  48933. // to the data on the placeholder node.
  48934. vm.$vnode = _parentVnode;
  48935. // render self
  48936. var vnode;
  48937. try {
  48938. // There's no need to maintain a stack because all render fns are called
  48939. // separately from one another. Nested component's render fns are called
  48940. // when parent component is patched.
  48941. currentRenderingInstance = vm;
  48942. vnode = render.call(vm._renderProxy, vm.$createElement);
  48943. } catch (e) {
  48944. handleError(e, vm, "render");
  48945. // return error render result,
  48946. // or previous vnode to prevent render error causing blank component
  48947. /* istanbul ignore else */
  48948. if (vm.$options.renderError) {
  48949. try {
  48950. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  48951. } catch (e) {
  48952. handleError(e, vm, "renderError");
  48953. vnode = vm._vnode;
  48954. }
  48955. } else {
  48956. vnode = vm._vnode;
  48957. }
  48958. } finally {
  48959. currentRenderingInstance = null;
  48960. }
  48961. // if the returned array contains only a single node, allow it
  48962. if (Array.isArray(vnode) && vnode.length === 1) {
  48963. vnode = vnode[0];
  48964. }
  48965. // return empty vnode in case the render function errored out
  48966. if (!(vnode instanceof VNode)) {
  48967. if (Array.isArray(vnode)) {
  48968. warn(
  48969. 'Multiple root nodes returned from render function. Render function ' +
  48970. 'should return a single root node.',
  48971. vm
  48972. );
  48973. }
  48974. vnode = createEmptyVNode();
  48975. }
  48976. // set parent
  48977. vnode.parent = _parentVnode;
  48978. return vnode
  48979. };
  48980. }
  48981. /* */
  48982. function ensureCtor (comp, base) {
  48983. if (
  48984. comp.__esModule ||
  48985. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  48986. ) {
  48987. comp = comp.default;
  48988. }
  48989. return isObject(comp)
  48990. ? base.extend(comp)
  48991. : comp
  48992. }
  48993. function createAsyncPlaceholder (
  48994. factory,
  48995. data,
  48996. context,
  48997. children,
  48998. tag
  48999. ) {
  49000. var node = createEmptyVNode();
  49001. node.asyncFactory = factory;
  49002. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  49003. return node
  49004. }
  49005. function resolveAsyncComponent (
  49006. factory,
  49007. baseCtor
  49008. ) {
  49009. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  49010. return factory.errorComp
  49011. }
  49012. if (isDef(factory.resolved)) {
  49013. return factory.resolved
  49014. }
  49015. var owner = currentRenderingInstance;
  49016. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  49017. // already pending
  49018. factory.owners.push(owner);
  49019. }
  49020. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  49021. return factory.loadingComp
  49022. }
  49023. if (owner && !isDef(factory.owners)) {
  49024. var owners = factory.owners = [owner];
  49025. var sync = true;
  49026. var timerLoading = null;
  49027. var timerTimeout = null
  49028. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  49029. var forceRender = function (renderCompleted) {
  49030. for (var i = 0, l = owners.length; i < l; i++) {
  49031. (owners[i]).$forceUpdate();
  49032. }
  49033. if (renderCompleted) {
  49034. owners.length = 0;
  49035. if (timerLoading !== null) {
  49036. clearTimeout(timerLoading);
  49037. timerLoading = null;
  49038. }
  49039. if (timerTimeout !== null) {
  49040. clearTimeout(timerTimeout);
  49041. timerTimeout = null;
  49042. }
  49043. }
  49044. };
  49045. var resolve = once(function (res) {
  49046. // cache resolved
  49047. factory.resolved = ensureCtor(res, baseCtor);
  49048. // invoke callbacks only if this is not a synchronous resolve
  49049. // (async resolves are shimmed as synchronous during SSR)
  49050. if (!sync) {
  49051. forceRender(true);
  49052. } else {
  49053. owners.length = 0;
  49054. }
  49055. });
  49056. var reject = once(function (reason) {
  49057. warn(
  49058. "Failed to resolve async component: " + (String(factory)) +
  49059. (reason ? ("\nReason: " + reason) : '')
  49060. );
  49061. if (isDef(factory.errorComp)) {
  49062. factory.error = true;
  49063. forceRender(true);
  49064. }
  49065. });
  49066. var res = factory(resolve, reject);
  49067. if (isObject(res)) {
  49068. if (isPromise(res)) {
  49069. // () => Promise
  49070. if (isUndef(factory.resolved)) {
  49071. res.then(resolve, reject);
  49072. }
  49073. } else if (isPromise(res.component)) {
  49074. res.component.then(resolve, reject);
  49075. if (isDef(res.error)) {
  49076. factory.errorComp = ensureCtor(res.error, baseCtor);
  49077. }
  49078. if (isDef(res.loading)) {
  49079. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  49080. if (res.delay === 0) {
  49081. factory.loading = true;
  49082. } else {
  49083. timerLoading = setTimeout(function () {
  49084. timerLoading = null;
  49085. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  49086. factory.loading = true;
  49087. forceRender(false);
  49088. }
  49089. }, res.delay || 200);
  49090. }
  49091. }
  49092. if (isDef(res.timeout)) {
  49093. timerTimeout = setTimeout(function () {
  49094. timerTimeout = null;
  49095. if (isUndef(factory.resolved)) {
  49096. reject(
  49097. "timeout (" + (res.timeout) + "ms)"
  49098. );
  49099. }
  49100. }, res.timeout);
  49101. }
  49102. }
  49103. }
  49104. sync = false;
  49105. // return in case resolved synchronously
  49106. return factory.loading
  49107. ? factory.loadingComp
  49108. : factory.resolved
  49109. }
  49110. }
  49111. /* */
  49112. function isAsyncPlaceholder (node) {
  49113. return node.isComment && node.asyncFactory
  49114. }
  49115. /* */
  49116. function getFirstComponentChild (children) {
  49117. if (Array.isArray(children)) {
  49118. for (var i = 0; i < children.length; i++) {
  49119. var c = children[i];
  49120. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  49121. return c
  49122. }
  49123. }
  49124. }
  49125. }
  49126. /* */
  49127. /* */
  49128. function initEvents (vm) {
  49129. vm._events = Object.create(null);
  49130. vm._hasHookEvent = false;
  49131. // init parent attached events
  49132. var listeners = vm.$options._parentListeners;
  49133. if (listeners) {
  49134. updateComponentListeners(vm, listeners);
  49135. }
  49136. }
  49137. var target;
  49138. function add (event, fn) {
  49139. target.$on(event, fn);
  49140. }
  49141. function remove$1 (event, fn) {
  49142. target.$off(event, fn);
  49143. }
  49144. function createOnceHandler (event, fn) {
  49145. var _target = target;
  49146. return function onceHandler () {
  49147. var res = fn.apply(null, arguments);
  49148. if (res !== null) {
  49149. _target.$off(event, onceHandler);
  49150. }
  49151. }
  49152. }
  49153. function updateComponentListeners (
  49154. vm,
  49155. listeners,
  49156. oldListeners
  49157. ) {
  49158. target = vm;
  49159. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  49160. target = undefined;
  49161. }
  49162. function eventsMixin (Vue) {
  49163. var hookRE = /^hook:/;
  49164. Vue.prototype.$on = function (event, fn) {
  49165. var vm = this;
  49166. if (Array.isArray(event)) {
  49167. for (var i = 0, l = event.length; i < l; i++) {
  49168. vm.$on(event[i], fn);
  49169. }
  49170. } else {
  49171. (vm._events[event] || (vm._events[event] = [])).push(fn);
  49172. // optimize hook:event cost by using a boolean flag marked at registration
  49173. // instead of a hash lookup
  49174. if (hookRE.test(event)) {
  49175. vm._hasHookEvent = true;
  49176. }
  49177. }
  49178. return vm
  49179. };
  49180. Vue.prototype.$once = function (event, fn) {
  49181. var vm = this;
  49182. function on () {
  49183. vm.$off(event, on);
  49184. fn.apply(vm, arguments);
  49185. }
  49186. on.fn = fn;
  49187. vm.$on(event, on);
  49188. return vm
  49189. };
  49190. Vue.prototype.$off = function (event, fn) {
  49191. var vm = this;
  49192. // all
  49193. if (!arguments.length) {
  49194. vm._events = Object.create(null);
  49195. return vm
  49196. }
  49197. // array of events
  49198. if (Array.isArray(event)) {
  49199. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  49200. vm.$off(event[i$1], fn);
  49201. }
  49202. return vm
  49203. }
  49204. // specific event
  49205. var cbs = vm._events[event];
  49206. if (!cbs) {
  49207. return vm
  49208. }
  49209. if (!fn) {
  49210. vm._events[event] = null;
  49211. return vm
  49212. }
  49213. // specific handler
  49214. var cb;
  49215. var i = cbs.length;
  49216. while (i--) {
  49217. cb = cbs[i];
  49218. if (cb === fn || cb.fn === fn) {
  49219. cbs.splice(i, 1);
  49220. break
  49221. }
  49222. }
  49223. return vm
  49224. };
  49225. Vue.prototype.$emit = function (event) {
  49226. var vm = this;
  49227. {
  49228. var lowerCaseEvent = event.toLowerCase();
  49229. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  49230. tip(
  49231. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  49232. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  49233. "Note that HTML attributes are case-insensitive and you cannot use " +
  49234. "v-on to listen to camelCase events when using in-DOM templates. " +
  49235. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  49236. );
  49237. }
  49238. }
  49239. var cbs = vm._events[event];
  49240. if (cbs) {
  49241. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  49242. var args = toArray(arguments, 1);
  49243. var info = "event handler for \"" + event + "\"";
  49244. for (var i = 0, l = cbs.length; i < l; i++) {
  49245. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  49246. }
  49247. }
  49248. return vm
  49249. };
  49250. }
  49251. /* */
  49252. var activeInstance = null;
  49253. var isUpdatingChildComponent = false;
  49254. function setActiveInstance(vm) {
  49255. var prevActiveInstance = activeInstance;
  49256. activeInstance = vm;
  49257. return function () {
  49258. activeInstance = prevActiveInstance;
  49259. }
  49260. }
  49261. function initLifecycle (vm) {
  49262. var options = vm.$options;
  49263. // locate first non-abstract parent
  49264. var parent = options.parent;
  49265. if (parent && !options.abstract) {
  49266. while (parent.$options.abstract && parent.$parent) {
  49267. parent = parent.$parent;
  49268. }
  49269. parent.$children.push(vm);
  49270. }
  49271. vm.$parent = parent;
  49272. vm.$root = parent ? parent.$root : vm;
  49273. vm.$children = [];
  49274. vm.$refs = {};
  49275. vm._watcher = null;
  49276. vm._inactive = null;
  49277. vm._directInactive = false;
  49278. vm._isMounted = false;
  49279. vm._isDestroyed = false;
  49280. vm._isBeingDestroyed = false;
  49281. }
  49282. function lifecycleMixin (Vue) {
  49283. Vue.prototype._update = function (vnode, hydrating) {
  49284. var vm = this;
  49285. var prevEl = vm.$el;
  49286. var prevVnode = vm._vnode;
  49287. var restoreActiveInstance = setActiveInstance(vm);
  49288. vm._vnode = vnode;
  49289. // Vue.prototype.__patch__ is injected in entry points
  49290. // based on the rendering backend used.
  49291. if (!prevVnode) {
  49292. // initial render
  49293. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  49294. } else {
  49295. // updates
  49296. vm.$el = vm.__patch__(prevVnode, vnode);
  49297. }
  49298. restoreActiveInstance();
  49299. // update __vue__ reference
  49300. if (prevEl) {
  49301. prevEl.__vue__ = null;
  49302. }
  49303. if (vm.$el) {
  49304. vm.$el.__vue__ = vm;
  49305. }
  49306. // if parent is an HOC, update its $el as well
  49307. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  49308. vm.$parent.$el = vm.$el;
  49309. }
  49310. // updated hook is called by the scheduler to ensure that children are
  49311. // updated in a parent's updated hook.
  49312. };
  49313. Vue.prototype.$forceUpdate = function () {
  49314. var vm = this;
  49315. if (vm._watcher) {
  49316. vm._watcher.update();
  49317. }
  49318. };
  49319. Vue.prototype.$destroy = function () {
  49320. var vm = this;
  49321. if (vm._isBeingDestroyed) {
  49322. return
  49323. }
  49324. callHook(vm, 'beforeDestroy');
  49325. vm._isBeingDestroyed = true;
  49326. // remove self from parent
  49327. var parent = vm.$parent;
  49328. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  49329. remove(parent.$children, vm);
  49330. }
  49331. // teardown watchers
  49332. if (vm._watcher) {
  49333. vm._watcher.teardown();
  49334. }
  49335. var i = vm._watchers.length;
  49336. while (i--) {
  49337. vm._watchers[i].teardown();
  49338. }
  49339. // remove reference from data ob
  49340. // frozen object may not have observer.
  49341. if (vm._data.__ob__) {
  49342. vm._data.__ob__.vmCount--;
  49343. }
  49344. // call the last hook...
  49345. vm._isDestroyed = true;
  49346. // invoke destroy hooks on current rendered tree
  49347. vm.__patch__(vm._vnode, null);
  49348. // fire destroyed hook
  49349. callHook(vm, 'destroyed');
  49350. // turn off all instance listeners.
  49351. vm.$off();
  49352. // remove __vue__ reference
  49353. if (vm.$el) {
  49354. vm.$el.__vue__ = null;
  49355. }
  49356. // release circular reference (#6759)
  49357. if (vm.$vnode) {
  49358. vm.$vnode.parent = null;
  49359. }
  49360. };
  49361. }
  49362. function mountComponent (
  49363. vm,
  49364. el,
  49365. hydrating
  49366. ) {
  49367. vm.$el = el;
  49368. if (!vm.$options.render) {
  49369. vm.$options.render = createEmptyVNode;
  49370. {
  49371. /* istanbul ignore if */
  49372. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  49373. vm.$options.el || el) {
  49374. warn(
  49375. 'You are using the runtime-only build of Vue where the template ' +
  49376. 'compiler is not available. Either pre-compile the templates into ' +
  49377. 'render functions, or use the compiler-included build.',
  49378. vm
  49379. );
  49380. } else {
  49381. warn(
  49382. 'Failed to mount component: template or render function not defined.',
  49383. vm
  49384. );
  49385. }
  49386. }
  49387. }
  49388. callHook(vm, 'beforeMount');
  49389. var updateComponent;
  49390. /* istanbul ignore if */
  49391. if (config.performance && mark) {
  49392. updateComponent = function () {
  49393. var name = vm._name;
  49394. var id = vm._uid;
  49395. var startTag = "vue-perf-start:" + id;
  49396. var endTag = "vue-perf-end:" + id;
  49397. mark(startTag);
  49398. var vnode = vm._render();
  49399. mark(endTag);
  49400. measure(("vue " + name + " render"), startTag, endTag);
  49401. mark(startTag);
  49402. vm._update(vnode, hydrating);
  49403. mark(endTag);
  49404. measure(("vue " + name + " patch"), startTag, endTag);
  49405. };
  49406. } else {
  49407. updateComponent = function () {
  49408. vm._update(vm._render(), hydrating);
  49409. };
  49410. }
  49411. // we set this to vm._watcher inside the watcher's constructor
  49412. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  49413. // component's mounted hook), which relies on vm._watcher being already defined
  49414. new Watcher(vm, updateComponent, noop, {
  49415. before: function before () {
  49416. if (vm._isMounted && !vm._isDestroyed) {
  49417. callHook(vm, 'beforeUpdate');
  49418. }
  49419. }
  49420. }, true /* isRenderWatcher */);
  49421. hydrating = false;
  49422. // manually mounted instance, call mounted on self
  49423. // mounted is called for render-created child components in its inserted hook
  49424. if (vm.$vnode == null) {
  49425. vm._isMounted = true;
  49426. callHook(vm, 'mounted');
  49427. }
  49428. return vm
  49429. }
  49430. function updateChildComponent (
  49431. vm,
  49432. propsData,
  49433. listeners,
  49434. parentVnode,
  49435. renderChildren
  49436. ) {
  49437. {
  49438. isUpdatingChildComponent = true;
  49439. }
  49440. // determine whether component has slot children
  49441. // we need to do this before overwriting $options._renderChildren.
  49442. // check if there are dynamic scopedSlots (hand-written or compiled but with
  49443. // dynamic slot names). Static scoped slots compiled from template has the
  49444. // "$stable" marker.
  49445. var newScopedSlots = parentVnode.data.scopedSlots;
  49446. var oldScopedSlots = vm.$scopedSlots;
  49447. var hasDynamicScopedSlot = !!(
  49448. (newScopedSlots && !newScopedSlots.$stable) ||
  49449. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  49450. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  49451. );
  49452. // Any static slot children from the parent may have changed during parent's
  49453. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  49454. // update is necessary to ensure correctness.
  49455. var needsForceUpdate = !!(
  49456. renderChildren || // has new static slots
  49457. vm.$options._renderChildren || // has old static slots
  49458. hasDynamicScopedSlot
  49459. );
  49460. vm.$options._parentVnode = parentVnode;
  49461. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  49462. if (vm._vnode) { // update child tree's parent
  49463. vm._vnode.parent = parentVnode;
  49464. }
  49465. vm.$options._renderChildren = renderChildren;
  49466. // update $attrs and $listeners hash
  49467. // these are also reactive so they may trigger child update if the child
  49468. // used them during render
  49469. vm.$attrs = parentVnode.data.attrs || emptyObject;
  49470. vm.$listeners = listeners || emptyObject;
  49471. // update props
  49472. if (propsData && vm.$options.props) {
  49473. toggleObserving(false);
  49474. var props = vm._props;
  49475. var propKeys = vm.$options._propKeys || [];
  49476. for (var i = 0; i < propKeys.length; i++) {
  49477. var key = propKeys[i];
  49478. var propOptions = vm.$options.props; // wtf flow?
  49479. props[key] = validateProp(key, propOptions, propsData, vm);
  49480. }
  49481. toggleObserving(true);
  49482. // keep a copy of raw propsData
  49483. vm.$options.propsData = propsData;
  49484. }
  49485. // update listeners
  49486. listeners = listeners || emptyObject;
  49487. var oldListeners = vm.$options._parentListeners;
  49488. vm.$options._parentListeners = listeners;
  49489. updateComponentListeners(vm, listeners, oldListeners);
  49490. // resolve slots + force update if has children
  49491. if (needsForceUpdate) {
  49492. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  49493. vm.$forceUpdate();
  49494. }
  49495. {
  49496. isUpdatingChildComponent = false;
  49497. }
  49498. }
  49499. function isInInactiveTree (vm) {
  49500. while (vm && (vm = vm.$parent)) {
  49501. if (vm._inactive) { return true }
  49502. }
  49503. return false
  49504. }
  49505. function activateChildComponent (vm, direct) {
  49506. if (direct) {
  49507. vm._directInactive = false;
  49508. if (isInInactiveTree(vm)) {
  49509. return
  49510. }
  49511. } else if (vm._directInactive) {
  49512. return
  49513. }
  49514. if (vm._inactive || vm._inactive === null) {
  49515. vm._inactive = false;
  49516. for (var i = 0; i < vm.$children.length; i++) {
  49517. activateChildComponent(vm.$children[i]);
  49518. }
  49519. callHook(vm, 'activated');
  49520. }
  49521. }
  49522. function deactivateChildComponent (vm, direct) {
  49523. if (direct) {
  49524. vm._directInactive = true;
  49525. if (isInInactiveTree(vm)) {
  49526. return
  49527. }
  49528. }
  49529. if (!vm._inactive) {
  49530. vm._inactive = true;
  49531. for (var i = 0; i < vm.$children.length; i++) {
  49532. deactivateChildComponent(vm.$children[i]);
  49533. }
  49534. callHook(vm, 'deactivated');
  49535. }
  49536. }
  49537. function callHook (vm, hook) {
  49538. // #7573 disable dep collection when invoking lifecycle hooks
  49539. pushTarget();
  49540. var handlers = vm.$options[hook];
  49541. var info = hook + " hook";
  49542. if (handlers) {
  49543. for (var i = 0, j = handlers.length; i < j; i++) {
  49544. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  49545. }
  49546. }
  49547. if (vm._hasHookEvent) {
  49548. vm.$emit('hook:' + hook);
  49549. }
  49550. popTarget();
  49551. }
  49552. /* */
  49553. var MAX_UPDATE_COUNT = 100;
  49554. var queue = [];
  49555. var activatedChildren = [];
  49556. var has = {};
  49557. var circular = {};
  49558. var waiting = false;
  49559. var flushing = false;
  49560. var index = 0;
  49561. /**
  49562. * Reset the scheduler's state.
  49563. */
  49564. function resetSchedulerState () {
  49565. index = queue.length = activatedChildren.length = 0;
  49566. has = {};
  49567. {
  49568. circular = {};
  49569. }
  49570. waiting = flushing = false;
  49571. }
  49572. // Async edge case #6566 requires saving the timestamp when event listeners are
  49573. // attached. However, calling performance.now() has a perf overhead especially
  49574. // if the page has thousands of event listeners. Instead, we take a timestamp
  49575. // every time the scheduler flushes and use that for all event listeners
  49576. // attached during that flush.
  49577. var currentFlushTimestamp = 0;
  49578. // Async edge case fix requires storing an event listener's attach timestamp.
  49579. var getNow = Date.now;
  49580. // Determine what event timestamp the browser is using. Annoyingly, the
  49581. // timestamp can either be hi-res (relative to page load) or low-res
  49582. // (relative to UNIX epoch), so in order to compare time we have to use the
  49583. // same timestamp type when saving the flush timestamp.
  49584. // All IE versions use low-res event timestamps, and have problematic clock
  49585. // implementations (#9632)
  49586. if (inBrowser && !isIE) {
  49587. var performance = window.performance;
  49588. if (
  49589. performance &&
  49590. typeof performance.now === 'function' &&
  49591. getNow() > document.createEvent('Event').timeStamp
  49592. ) {
  49593. // if the event timestamp, although evaluated AFTER the Date.now(), is
  49594. // smaller than it, it means the event is using a hi-res timestamp,
  49595. // and we need to use the hi-res version for event listener timestamps as
  49596. // well.
  49597. getNow = function () { return performance.now(); };
  49598. }
  49599. }
  49600. /**
  49601. * Flush both queues and run the watchers.
  49602. */
  49603. function flushSchedulerQueue () {
  49604. currentFlushTimestamp = getNow();
  49605. flushing = true;
  49606. var watcher, id;
  49607. // Sort queue before flush.
  49608. // This ensures that:
  49609. // 1. Components are updated from parent to child. (because parent is always
  49610. // created before the child)
  49611. // 2. A component's user watchers are run before its render watcher (because
  49612. // user watchers are created before the render watcher)
  49613. // 3. If a component is destroyed during a parent component's watcher run,
  49614. // its watchers can be skipped.
  49615. queue.sort(function (a, b) { return a.id - b.id; });
  49616. // do not cache length because more watchers might be pushed
  49617. // as we run existing watchers
  49618. for (index = 0; index < queue.length; index++) {
  49619. watcher = queue[index];
  49620. if (watcher.before) {
  49621. watcher.before();
  49622. }
  49623. id = watcher.id;
  49624. has[id] = null;
  49625. watcher.run();
  49626. // in dev build, check and stop circular updates.
  49627. if (has[id] != null) {
  49628. circular[id] = (circular[id] || 0) + 1;
  49629. if (circular[id] > MAX_UPDATE_COUNT) {
  49630. warn(
  49631. 'You may have an infinite update loop ' + (
  49632. watcher.user
  49633. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  49634. : "in a component render function."
  49635. ),
  49636. watcher.vm
  49637. );
  49638. break
  49639. }
  49640. }
  49641. }
  49642. // keep copies of post queues before resetting state
  49643. var activatedQueue = activatedChildren.slice();
  49644. var updatedQueue = queue.slice();
  49645. resetSchedulerState();
  49646. // call component updated and activated hooks
  49647. callActivatedHooks(activatedQueue);
  49648. callUpdatedHooks(updatedQueue);
  49649. // devtool hook
  49650. /* istanbul ignore if */
  49651. if (devtools && config.devtools) {
  49652. devtools.emit('flush');
  49653. }
  49654. }
  49655. function callUpdatedHooks (queue) {
  49656. var i = queue.length;
  49657. while (i--) {
  49658. var watcher = queue[i];
  49659. var vm = watcher.vm;
  49660. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  49661. callHook(vm, 'updated');
  49662. }
  49663. }
  49664. }
  49665. /**
  49666. * Queue a kept-alive component that was activated during patch.
  49667. * The queue will be processed after the entire tree has been patched.
  49668. */
  49669. function queueActivatedComponent (vm) {
  49670. // setting _inactive to false here so that a render function can
  49671. // rely on checking whether it's in an inactive tree (e.g. router-view)
  49672. vm._inactive = false;
  49673. activatedChildren.push(vm);
  49674. }
  49675. function callActivatedHooks (queue) {
  49676. for (var i = 0; i < queue.length; i++) {
  49677. queue[i]._inactive = true;
  49678. activateChildComponent(queue[i], true /* true */);
  49679. }
  49680. }
  49681. /**
  49682. * Push a watcher into the watcher queue.
  49683. * Jobs with duplicate IDs will be skipped unless it's
  49684. * pushed when the queue is being flushed.
  49685. */
  49686. function queueWatcher (watcher) {
  49687. var id = watcher.id;
  49688. if (has[id] == null) {
  49689. has[id] = true;
  49690. if (!flushing) {
  49691. queue.push(watcher);
  49692. } else {
  49693. // if already flushing, splice the watcher based on its id
  49694. // if already past its id, it will be run next immediately.
  49695. var i = queue.length - 1;
  49696. while (i > index && queue[i].id > watcher.id) {
  49697. i--;
  49698. }
  49699. queue.splice(i + 1, 0, watcher);
  49700. }
  49701. // queue the flush
  49702. if (!waiting) {
  49703. waiting = true;
  49704. if (!config.async) {
  49705. flushSchedulerQueue();
  49706. return
  49707. }
  49708. nextTick(flushSchedulerQueue);
  49709. }
  49710. }
  49711. }
  49712. /* */
  49713. var uid$2 = 0;
  49714. /**
  49715. * A watcher parses an expression, collects dependencies,
  49716. * and fires callback when the expression value changes.
  49717. * This is used for both the $watch() api and directives.
  49718. */
  49719. var Watcher = function Watcher (
  49720. vm,
  49721. expOrFn,
  49722. cb,
  49723. options,
  49724. isRenderWatcher
  49725. ) {
  49726. this.vm = vm;
  49727. if (isRenderWatcher) {
  49728. vm._watcher = this;
  49729. }
  49730. vm._watchers.push(this);
  49731. // options
  49732. if (options) {
  49733. this.deep = !!options.deep;
  49734. this.user = !!options.user;
  49735. this.lazy = !!options.lazy;
  49736. this.sync = !!options.sync;
  49737. this.before = options.before;
  49738. } else {
  49739. this.deep = this.user = this.lazy = this.sync = false;
  49740. }
  49741. this.cb = cb;
  49742. this.id = ++uid$2; // uid for batching
  49743. this.active = true;
  49744. this.dirty = this.lazy; // for lazy watchers
  49745. this.deps = [];
  49746. this.newDeps = [];
  49747. this.depIds = new _Set();
  49748. this.newDepIds = new _Set();
  49749. this.expression = expOrFn.toString();
  49750. // parse expression for getter
  49751. if (typeof expOrFn === 'function') {
  49752. this.getter = expOrFn;
  49753. } else {
  49754. this.getter = parsePath(expOrFn);
  49755. if (!this.getter) {
  49756. this.getter = noop;
  49757. warn(
  49758. "Failed watching path: \"" + expOrFn + "\" " +
  49759. 'Watcher only accepts simple dot-delimited paths. ' +
  49760. 'For full control, use a function instead.',
  49761. vm
  49762. );
  49763. }
  49764. }
  49765. this.value = this.lazy
  49766. ? undefined
  49767. : this.get();
  49768. };
  49769. /**
  49770. * Evaluate the getter, and re-collect dependencies.
  49771. */
  49772. Watcher.prototype.get = function get () {
  49773. pushTarget(this);
  49774. var value;
  49775. var vm = this.vm;
  49776. try {
  49777. value = this.getter.call(vm, vm);
  49778. } catch (e) {
  49779. if (this.user) {
  49780. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  49781. } else {
  49782. throw e
  49783. }
  49784. } finally {
  49785. // "touch" every property so they are all tracked as
  49786. // dependencies for deep watching
  49787. if (this.deep) {
  49788. traverse(value);
  49789. }
  49790. popTarget();
  49791. this.cleanupDeps();
  49792. }
  49793. return value
  49794. };
  49795. /**
  49796. * Add a dependency to this directive.
  49797. */
  49798. Watcher.prototype.addDep = function addDep (dep) {
  49799. var id = dep.id;
  49800. if (!this.newDepIds.has(id)) {
  49801. this.newDepIds.add(id);
  49802. this.newDeps.push(dep);
  49803. if (!this.depIds.has(id)) {
  49804. dep.addSub(this);
  49805. }
  49806. }
  49807. };
  49808. /**
  49809. * Clean up for dependency collection.
  49810. */
  49811. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  49812. var i = this.deps.length;
  49813. while (i--) {
  49814. var dep = this.deps[i];
  49815. if (!this.newDepIds.has(dep.id)) {
  49816. dep.removeSub(this);
  49817. }
  49818. }
  49819. var tmp = this.depIds;
  49820. this.depIds = this.newDepIds;
  49821. this.newDepIds = tmp;
  49822. this.newDepIds.clear();
  49823. tmp = this.deps;
  49824. this.deps = this.newDeps;
  49825. this.newDeps = tmp;
  49826. this.newDeps.length = 0;
  49827. };
  49828. /**
  49829. * Subscriber interface.
  49830. * Will be called when a dependency changes.
  49831. */
  49832. Watcher.prototype.update = function update () {
  49833. /* istanbul ignore else */
  49834. if (this.lazy) {
  49835. this.dirty = true;
  49836. } else if (this.sync) {
  49837. this.run();
  49838. } else {
  49839. queueWatcher(this);
  49840. }
  49841. };
  49842. /**
  49843. * Scheduler job interface.
  49844. * Will be called by the scheduler.
  49845. */
  49846. Watcher.prototype.run = function run () {
  49847. if (this.active) {
  49848. var value = this.get();
  49849. if (
  49850. value !== this.value ||
  49851. // Deep watchers and watchers on Object/Arrays should fire even
  49852. // when the value is the same, because the value may
  49853. // have mutated.
  49854. isObject(value) ||
  49855. this.deep
  49856. ) {
  49857. // set new value
  49858. var oldValue = this.value;
  49859. this.value = value;
  49860. if (this.user) {
  49861. try {
  49862. this.cb.call(this.vm, value, oldValue);
  49863. } catch (e) {
  49864. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  49865. }
  49866. } else {
  49867. this.cb.call(this.vm, value, oldValue);
  49868. }
  49869. }
  49870. }
  49871. };
  49872. /**
  49873. * Evaluate the value of the watcher.
  49874. * This only gets called for lazy watchers.
  49875. */
  49876. Watcher.prototype.evaluate = function evaluate () {
  49877. this.value = this.get();
  49878. this.dirty = false;
  49879. };
  49880. /**
  49881. * Depend on all deps collected by this watcher.
  49882. */
  49883. Watcher.prototype.depend = function depend () {
  49884. var i = this.deps.length;
  49885. while (i--) {
  49886. this.deps[i].depend();
  49887. }
  49888. };
  49889. /**
  49890. * Remove self from all dependencies' subscriber list.
  49891. */
  49892. Watcher.prototype.teardown = function teardown () {
  49893. if (this.active) {
  49894. // remove self from vm's watcher list
  49895. // this is a somewhat expensive operation so we skip it
  49896. // if the vm is being destroyed.
  49897. if (!this.vm._isBeingDestroyed) {
  49898. remove(this.vm._watchers, this);
  49899. }
  49900. var i = this.deps.length;
  49901. while (i--) {
  49902. this.deps[i].removeSub(this);
  49903. }
  49904. this.active = false;
  49905. }
  49906. };
  49907. /* */
  49908. var sharedPropertyDefinition = {
  49909. enumerable: true,
  49910. configurable: true,
  49911. get: noop,
  49912. set: noop
  49913. };
  49914. function proxy (target, sourceKey, key) {
  49915. sharedPropertyDefinition.get = function proxyGetter () {
  49916. return this[sourceKey][key]
  49917. };
  49918. sharedPropertyDefinition.set = function proxySetter (val) {
  49919. this[sourceKey][key] = val;
  49920. };
  49921. Object.defineProperty(target, key, sharedPropertyDefinition);
  49922. }
  49923. function initState (vm) {
  49924. vm._watchers = [];
  49925. var opts = vm.$options;
  49926. if (opts.props) { initProps(vm, opts.props); }
  49927. if (opts.methods) { initMethods(vm, opts.methods); }
  49928. if (opts.data) {
  49929. initData(vm);
  49930. } else {
  49931. observe(vm._data = {}, true /* asRootData */);
  49932. }
  49933. if (opts.computed) { initComputed(vm, opts.computed); }
  49934. if (opts.watch && opts.watch !== nativeWatch) {
  49935. initWatch(vm, opts.watch);
  49936. }
  49937. }
  49938. function initProps (vm, propsOptions) {
  49939. var propsData = vm.$options.propsData || {};
  49940. var props = vm._props = {};
  49941. // cache prop keys so that future props updates can iterate using Array
  49942. // instead of dynamic object key enumeration.
  49943. var keys = vm.$options._propKeys = [];
  49944. var isRoot = !vm.$parent;
  49945. // root instance props should be converted
  49946. if (!isRoot) {
  49947. toggleObserving(false);
  49948. }
  49949. var loop = function ( key ) {
  49950. keys.push(key);
  49951. var value = validateProp(key, propsOptions, propsData, vm);
  49952. /* istanbul ignore else */
  49953. {
  49954. var hyphenatedKey = hyphenate(key);
  49955. if (isReservedAttribute(hyphenatedKey) ||
  49956. config.isReservedAttr(hyphenatedKey)) {
  49957. warn(
  49958. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  49959. vm
  49960. );
  49961. }
  49962. defineReactive$$1(props, key, value, function () {
  49963. if (!isRoot && !isUpdatingChildComponent) {
  49964. warn(
  49965. "Avoid mutating a prop directly since the value will be " +
  49966. "overwritten whenever the parent component re-renders. " +
  49967. "Instead, use a data or computed property based on the prop's " +
  49968. "value. Prop being mutated: \"" + key + "\"",
  49969. vm
  49970. );
  49971. }
  49972. });
  49973. }
  49974. // static props are already proxied on the component's prototype
  49975. // during Vue.extend(). We only need to proxy props defined at
  49976. // instantiation here.
  49977. if (!(key in vm)) {
  49978. proxy(vm, "_props", key);
  49979. }
  49980. };
  49981. for (var key in propsOptions) loop( key );
  49982. toggleObserving(true);
  49983. }
  49984. function initData (vm) {
  49985. var data = vm.$options.data;
  49986. data = vm._data = typeof data === 'function'
  49987. ? getData(data, vm)
  49988. : data || {};
  49989. if (!isPlainObject(data)) {
  49990. data = {};
  49991. warn(
  49992. 'data functions should return an object:\n' +
  49993. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  49994. vm
  49995. );
  49996. }
  49997. // proxy data on instance
  49998. var keys = Object.keys(data);
  49999. var props = vm.$options.props;
  50000. var methods = vm.$options.methods;
  50001. var i = keys.length;
  50002. while (i--) {
  50003. var key = keys[i];
  50004. {
  50005. if (methods && hasOwn(methods, key)) {
  50006. warn(
  50007. ("Method \"" + key + "\" has already been defined as a data property."),
  50008. vm
  50009. );
  50010. }
  50011. }
  50012. if (props && hasOwn(props, key)) {
  50013. warn(
  50014. "The data property \"" + key + "\" is already declared as a prop. " +
  50015. "Use prop default value instead.",
  50016. vm
  50017. );
  50018. } else if (!isReserved(key)) {
  50019. proxy(vm, "_data", key);
  50020. }
  50021. }
  50022. // observe data
  50023. observe(data, true /* asRootData */);
  50024. }
  50025. function getData (data, vm) {
  50026. // #7573 disable dep collection when invoking data getters
  50027. pushTarget();
  50028. try {
  50029. return data.call(vm, vm)
  50030. } catch (e) {
  50031. handleError(e, vm, "data()");
  50032. return {}
  50033. } finally {
  50034. popTarget();
  50035. }
  50036. }
  50037. var computedWatcherOptions = { lazy: true };
  50038. function initComputed (vm, computed) {
  50039. // $flow-disable-line
  50040. var watchers = vm._computedWatchers = Object.create(null);
  50041. // computed properties are just getters during SSR
  50042. var isSSR = isServerRendering();
  50043. for (var key in computed) {
  50044. var userDef = computed[key];
  50045. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  50046. if (getter == null) {
  50047. warn(
  50048. ("Getter is missing for computed property \"" + key + "\"."),
  50049. vm
  50050. );
  50051. }
  50052. if (!isSSR) {
  50053. // create internal watcher for the computed property.
  50054. watchers[key] = new Watcher(
  50055. vm,
  50056. getter || noop,
  50057. noop,
  50058. computedWatcherOptions
  50059. );
  50060. }
  50061. // component-defined computed properties are already defined on the
  50062. // component prototype. We only need to define computed properties defined
  50063. // at instantiation here.
  50064. if (!(key in vm)) {
  50065. defineComputed(vm, key, userDef);
  50066. } else {
  50067. if (key in vm.$data) {
  50068. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  50069. } else if (vm.$options.props && key in vm.$options.props) {
  50070. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  50071. }
  50072. }
  50073. }
  50074. }
  50075. function defineComputed (
  50076. target,
  50077. key,
  50078. userDef
  50079. ) {
  50080. var shouldCache = !isServerRendering();
  50081. if (typeof userDef === 'function') {
  50082. sharedPropertyDefinition.get = shouldCache
  50083. ? createComputedGetter(key)
  50084. : createGetterInvoker(userDef);
  50085. sharedPropertyDefinition.set = noop;
  50086. } else {
  50087. sharedPropertyDefinition.get = userDef.get
  50088. ? shouldCache && userDef.cache !== false
  50089. ? createComputedGetter(key)
  50090. : createGetterInvoker(userDef.get)
  50091. : noop;
  50092. sharedPropertyDefinition.set = userDef.set || noop;
  50093. }
  50094. if (sharedPropertyDefinition.set === noop) {
  50095. sharedPropertyDefinition.set = function () {
  50096. warn(
  50097. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  50098. this
  50099. );
  50100. };
  50101. }
  50102. Object.defineProperty(target, key, sharedPropertyDefinition);
  50103. }
  50104. function createComputedGetter (key) {
  50105. return function computedGetter () {
  50106. var watcher = this._computedWatchers && this._computedWatchers[key];
  50107. if (watcher) {
  50108. if (watcher.dirty) {
  50109. watcher.evaluate();
  50110. }
  50111. if (Dep.target) {
  50112. watcher.depend();
  50113. }
  50114. return watcher.value
  50115. }
  50116. }
  50117. }
  50118. function createGetterInvoker(fn) {
  50119. return function computedGetter () {
  50120. return fn.call(this, this)
  50121. }
  50122. }
  50123. function initMethods (vm, methods) {
  50124. var props = vm.$options.props;
  50125. for (var key in methods) {
  50126. {
  50127. if (typeof methods[key] !== 'function') {
  50128. warn(
  50129. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  50130. "Did you reference the function correctly?",
  50131. vm
  50132. );
  50133. }
  50134. if (props && hasOwn(props, key)) {
  50135. warn(
  50136. ("Method \"" + key + "\" has already been defined as a prop."),
  50137. vm
  50138. );
  50139. }
  50140. if ((key in vm) && isReserved(key)) {
  50141. warn(
  50142. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  50143. "Avoid defining component methods that start with _ or $."
  50144. );
  50145. }
  50146. }
  50147. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  50148. }
  50149. }
  50150. function initWatch (vm, watch) {
  50151. for (var key in watch) {
  50152. var handler = watch[key];
  50153. if (Array.isArray(handler)) {
  50154. for (var i = 0; i < handler.length; i++) {
  50155. createWatcher(vm, key, handler[i]);
  50156. }
  50157. } else {
  50158. createWatcher(vm, key, handler);
  50159. }
  50160. }
  50161. }
  50162. function createWatcher (
  50163. vm,
  50164. expOrFn,
  50165. handler,
  50166. options
  50167. ) {
  50168. if (isPlainObject(handler)) {
  50169. options = handler;
  50170. handler = handler.handler;
  50171. }
  50172. if (typeof handler === 'string') {
  50173. handler = vm[handler];
  50174. }
  50175. return vm.$watch(expOrFn, handler, options)
  50176. }
  50177. function stateMixin (Vue) {
  50178. // flow somehow has problems with directly declared definition object
  50179. // when using Object.defineProperty, so we have to procedurally build up
  50180. // the object here.
  50181. var dataDef = {};
  50182. dataDef.get = function () { return this._data };
  50183. var propsDef = {};
  50184. propsDef.get = function () { return this._props };
  50185. {
  50186. dataDef.set = function () {
  50187. warn(
  50188. 'Avoid replacing instance root $data. ' +
  50189. 'Use nested data properties instead.',
  50190. this
  50191. );
  50192. };
  50193. propsDef.set = function () {
  50194. warn("$props is readonly.", this);
  50195. };
  50196. }
  50197. Object.defineProperty(Vue.prototype, '$data', dataDef);
  50198. Object.defineProperty(Vue.prototype, '$props', propsDef);
  50199. Vue.prototype.$set = set;
  50200. Vue.prototype.$delete = del;
  50201. Vue.prototype.$watch = function (
  50202. expOrFn,
  50203. cb,
  50204. options
  50205. ) {
  50206. var vm = this;
  50207. if (isPlainObject(cb)) {
  50208. return createWatcher(vm, expOrFn, cb, options)
  50209. }
  50210. options = options || {};
  50211. options.user = true;
  50212. var watcher = new Watcher(vm, expOrFn, cb, options);
  50213. if (options.immediate) {
  50214. try {
  50215. cb.call(vm, watcher.value);
  50216. } catch (error) {
  50217. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  50218. }
  50219. }
  50220. return function unwatchFn () {
  50221. watcher.teardown();
  50222. }
  50223. };
  50224. }
  50225. /* */
  50226. var uid$3 = 0;
  50227. function initMixin (Vue) {
  50228. Vue.prototype._init = function (options) {
  50229. var vm = this;
  50230. // a uid
  50231. vm._uid = uid$3++;
  50232. var startTag, endTag;
  50233. /* istanbul ignore if */
  50234. if (config.performance && mark) {
  50235. startTag = "vue-perf-start:" + (vm._uid);
  50236. endTag = "vue-perf-end:" + (vm._uid);
  50237. mark(startTag);
  50238. }
  50239. // a flag to avoid this being observed
  50240. vm._isVue = true;
  50241. // merge options
  50242. if (options && options._isComponent) {
  50243. // optimize internal component instantiation
  50244. // since dynamic options merging is pretty slow, and none of the
  50245. // internal component options needs special treatment.
  50246. initInternalComponent(vm, options);
  50247. } else {
  50248. vm.$options = mergeOptions(
  50249. resolveConstructorOptions(vm.constructor),
  50250. options || {},
  50251. vm
  50252. );
  50253. }
  50254. /* istanbul ignore else */
  50255. {
  50256. initProxy(vm);
  50257. }
  50258. // expose real self
  50259. vm._self = vm;
  50260. initLifecycle(vm);
  50261. initEvents(vm);
  50262. initRender(vm);
  50263. callHook(vm, 'beforeCreate');
  50264. initInjections(vm); // resolve injections before data/props
  50265. initState(vm);
  50266. initProvide(vm); // resolve provide after data/props
  50267. callHook(vm, 'created');
  50268. /* istanbul ignore if */
  50269. if (config.performance && mark) {
  50270. vm._name = formatComponentName(vm, false);
  50271. mark(endTag);
  50272. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  50273. }
  50274. if (vm.$options.el) {
  50275. vm.$mount(vm.$options.el);
  50276. }
  50277. };
  50278. }
  50279. function initInternalComponent (vm, options) {
  50280. var opts = vm.$options = Object.create(vm.constructor.options);
  50281. // doing this because it's faster than dynamic enumeration.
  50282. var parentVnode = options._parentVnode;
  50283. opts.parent = options.parent;
  50284. opts._parentVnode = parentVnode;
  50285. var vnodeComponentOptions = parentVnode.componentOptions;
  50286. opts.propsData = vnodeComponentOptions.propsData;
  50287. opts._parentListeners = vnodeComponentOptions.listeners;
  50288. opts._renderChildren = vnodeComponentOptions.children;
  50289. opts._componentTag = vnodeComponentOptions.tag;
  50290. if (options.render) {
  50291. opts.render = options.render;
  50292. opts.staticRenderFns = options.staticRenderFns;
  50293. }
  50294. }
  50295. function resolveConstructorOptions (Ctor) {
  50296. var options = Ctor.options;
  50297. if (Ctor.super) {
  50298. var superOptions = resolveConstructorOptions(Ctor.super);
  50299. var cachedSuperOptions = Ctor.superOptions;
  50300. if (superOptions !== cachedSuperOptions) {
  50301. // super option changed,
  50302. // need to resolve new options.
  50303. Ctor.superOptions = superOptions;
  50304. // check if there are any late-modified/attached options (#4976)
  50305. var modifiedOptions = resolveModifiedOptions(Ctor);
  50306. // update base extend options
  50307. if (modifiedOptions) {
  50308. extend(Ctor.extendOptions, modifiedOptions);
  50309. }
  50310. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  50311. if (options.name) {
  50312. options.components[options.name] = Ctor;
  50313. }
  50314. }
  50315. }
  50316. return options
  50317. }
  50318. function resolveModifiedOptions (Ctor) {
  50319. var modified;
  50320. var latest = Ctor.options;
  50321. var sealed = Ctor.sealedOptions;
  50322. for (var key in latest) {
  50323. if (latest[key] !== sealed[key]) {
  50324. if (!modified) { modified = {}; }
  50325. modified[key] = latest[key];
  50326. }
  50327. }
  50328. return modified
  50329. }
  50330. function Vue (options) {
  50331. if (!(this instanceof Vue)
  50332. ) {
  50333. warn('Vue is a constructor and should be called with the `new` keyword');
  50334. }
  50335. this._init(options);
  50336. }
  50337. initMixin(Vue);
  50338. stateMixin(Vue);
  50339. eventsMixin(Vue);
  50340. lifecycleMixin(Vue);
  50341. renderMixin(Vue);
  50342. /* */
  50343. function initUse (Vue) {
  50344. Vue.use = function (plugin) {
  50345. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  50346. if (installedPlugins.indexOf(plugin) > -1) {
  50347. return this
  50348. }
  50349. // additional parameters
  50350. var args = toArray(arguments, 1);
  50351. args.unshift(this);
  50352. if (typeof plugin.install === 'function') {
  50353. plugin.install.apply(plugin, args);
  50354. } else if (typeof plugin === 'function') {
  50355. plugin.apply(null, args);
  50356. }
  50357. installedPlugins.push(plugin);
  50358. return this
  50359. };
  50360. }
  50361. /* */
  50362. function initMixin$1 (Vue) {
  50363. Vue.mixin = function (mixin) {
  50364. this.options = mergeOptions(this.options, mixin);
  50365. return this
  50366. };
  50367. }
  50368. /* */
  50369. function initExtend (Vue) {
  50370. /**
  50371. * Each instance constructor, including Vue, has a unique
  50372. * cid. This enables us to create wrapped "child
  50373. * constructors" for prototypal inheritance and cache them.
  50374. */
  50375. Vue.cid = 0;
  50376. var cid = 1;
  50377. /**
  50378. * Class inheritance
  50379. */
  50380. Vue.extend = function (extendOptions) {
  50381. extendOptions = extendOptions || {};
  50382. var Super = this;
  50383. var SuperId = Super.cid;
  50384. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  50385. if (cachedCtors[SuperId]) {
  50386. return cachedCtors[SuperId]
  50387. }
  50388. var name = extendOptions.name || Super.options.name;
  50389. if (name) {
  50390. validateComponentName(name);
  50391. }
  50392. var Sub = function VueComponent (options) {
  50393. this._init(options);
  50394. };
  50395. Sub.prototype = Object.create(Super.prototype);
  50396. Sub.prototype.constructor = Sub;
  50397. Sub.cid = cid++;
  50398. Sub.options = mergeOptions(
  50399. Super.options,
  50400. extendOptions
  50401. );
  50402. Sub['super'] = Super;
  50403. // For props and computed properties, we define the proxy getters on
  50404. // the Vue instances at extension time, on the extended prototype. This
  50405. // avoids Object.defineProperty calls for each instance created.
  50406. if (Sub.options.props) {
  50407. initProps$1(Sub);
  50408. }
  50409. if (Sub.options.computed) {
  50410. initComputed$1(Sub);
  50411. }
  50412. // allow further extension/mixin/plugin usage
  50413. Sub.extend = Super.extend;
  50414. Sub.mixin = Super.mixin;
  50415. Sub.use = Super.use;
  50416. // create asset registers, so extended classes
  50417. // can have their private assets too.
  50418. ASSET_TYPES.forEach(function (type) {
  50419. Sub[type] = Super[type];
  50420. });
  50421. // enable recursive self-lookup
  50422. if (name) {
  50423. Sub.options.components[name] = Sub;
  50424. }
  50425. // keep a reference to the super options at extension time.
  50426. // later at instantiation we can check if Super's options have
  50427. // been updated.
  50428. Sub.superOptions = Super.options;
  50429. Sub.extendOptions = extendOptions;
  50430. Sub.sealedOptions = extend({}, Sub.options);
  50431. // cache constructor
  50432. cachedCtors[SuperId] = Sub;
  50433. return Sub
  50434. };
  50435. }
  50436. function initProps$1 (Comp) {
  50437. var props = Comp.options.props;
  50438. for (var key in props) {
  50439. proxy(Comp.prototype, "_props", key);
  50440. }
  50441. }
  50442. function initComputed$1 (Comp) {
  50443. var computed = Comp.options.computed;
  50444. for (var key in computed) {
  50445. defineComputed(Comp.prototype, key, computed[key]);
  50446. }
  50447. }
  50448. /* */
  50449. function initAssetRegisters (Vue) {
  50450. /**
  50451. * Create asset registration methods.
  50452. */
  50453. ASSET_TYPES.forEach(function (type) {
  50454. Vue[type] = function (
  50455. id,
  50456. definition
  50457. ) {
  50458. if (!definition) {
  50459. return this.options[type + 's'][id]
  50460. } else {
  50461. /* istanbul ignore if */
  50462. if (type === 'component') {
  50463. validateComponentName(id);
  50464. }
  50465. if (type === 'component' && isPlainObject(definition)) {
  50466. definition.name = definition.name || id;
  50467. definition = this.options._base.extend(definition);
  50468. }
  50469. if (type === 'directive' && typeof definition === 'function') {
  50470. definition = { bind: definition, update: definition };
  50471. }
  50472. this.options[type + 's'][id] = definition;
  50473. return definition
  50474. }
  50475. };
  50476. });
  50477. }
  50478. /* */
  50479. function getComponentName (opts) {
  50480. return opts && (opts.Ctor.options.name || opts.tag)
  50481. }
  50482. function matches (pattern, name) {
  50483. if (Array.isArray(pattern)) {
  50484. return pattern.indexOf(name) > -1
  50485. } else if (typeof pattern === 'string') {
  50486. return pattern.split(',').indexOf(name) > -1
  50487. } else if (isRegExp(pattern)) {
  50488. return pattern.test(name)
  50489. }
  50490. /* istanbul ignore next */
  50491. return false
  50492. }
  50493. function pruneCache (keepAliveInstance, filter) {
  50494. var cache = keepAliveInstance.cache;
  50495. var keys = keepAliveInstance.keys;
  50496. var _vnode = keepAliveInstance._vnode;
  50497. for (var key in cache) {
  50498. var cachedNode = cache[key];
  50499. if (cachedNode) {
  50500. var name = getComponentName(cachedNode.componentOptions);
  50501. if (name && !filter(name)) {
  50502. pruneCacheEntry(cache, key, keys, _vnode);
  50503. }
  50504. }
  50505. }
  50506. }
  50507. function pruneCacheEntry (
  50508. cache,
  50509. key,
  50510. keys,
  50511. current
  50512. ) {
  50513. var cached$$1 = cache[key];
  50514. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  50515. cached$$1.componentInstance.$destroy();
  50516. }
  50517. cache[key] = null;
  50518. remove(keys, key);
  50519. }
  50520. var patternTypes = [String, RegExp, Array];
  50521. var KeepAlive = {
  50522. name: 'keep-alive',
  50523. abstract: true,
  50524. props: {
  50525. include: patternTypes,
  50526. exclude: patternTypes,
  50527. max: [String, Number]
  50528. },
  50529. created: function created () {
  50530. this.cache = Object.create(null);
  50531. this.keys = [];
  50532. },
  50533. destroyed: function destroyed () {
  50534. for (var key in this.cache) {
  50535. pruneCacheEntry(this.cache, key, this.keys);
  50536. }
  50537. },
  50538. mounted: function mounted () {
  50539. var this$1 = this;
  50540. this.$watch('include', function (val) {
  50541. pruneCache(this$1, function (name) { return matches(val, name); });
  50542. });
  50543. this.$watch('exclude', function (val) {
  50544. pruneCache(this$1, function (name) { return !matches(val, name); });
  50545. });
  50546. },
  50547. render: function render () {
  50548. var slot = this.$slots.default;
  50549. var vnode = getFirstComponentChild(slot);
  50550. var componentOptions = vnode && vnode.componentOptions;
  50551. if (componentOptions) {
  50552. // check pattern
  50553. var name = getComponentName(componentOptions);
  50554. var ref = this;
  50555. var include = ref.include;
  50556. var exclude = ref.exclude;
  50557. if (
  50558. // not included
  50559. (include && (!name || !matches(include, name))) ||
  50560. // excluded
  50561. (exclude && name && matches(exclude, name))
  50562. ) {
  50563. return vnode
  50564. }
  50565. var ref$1 = this;
  50566. var cache = ref$1.cache;
  50567. var keys = ref$1.keys;
  50568. var key = vnode.key == null
  50569. // same constructor may get registered as different local components
  50570. // so cid alone is not enough (#3269)
  50571. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  50572. : vnode.key;
  50573. if (cache[key]) {
  50574. vnode.componentInstance = cache[key].componentInstance;
  50575. // make current key freshest
  50576. remove(keys, key);
  50577. keys.push(key);
  50578. } else {
  50579. cache[key] = vnode;
  50580. keys.push(key);
  50581. // prune oldest entry
  50582. if (this.max && keys.length > parseInt(this.max)) {
  50583. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  50584. }
  50585. }
  50586. vnode.data.keepAlive = true;
  50587. }
  50588. return vnode || (slot && slot[0])
  50589. }
  50590. };
  50591. var builtInComponents = {
  50592. KeepAlive: KeepAlive
  50593. };
  50594. /* */
  50595. function initGlobalAPI (Vue) {
  50596. // config
  50597. var configDef = {};
  50598. configDef.get = function () { return config; };
  50599. {
  50600. configDef.set = function () {
  50601. warn(
  50602. 'Do not replace the Vue.config object, set individual fields instead.'
  50603. );
  50604. };
  50605. }
  50606. Object.defineProperty(Vue, 'config', configDef);
  50607. // exposed util methods.
  50608. // NOTE: these are not considered part of the public API - avoid relying on
  50609. // them unless you are aware of the risk.
  50610. Vue.util = {
  50611. warn: warn,
  50612. extend: extend,
  50613. mergeOptions: mergeOptions,
  50614. defineReactive: defineReactive$$1
  50615. };
  50616. Vue.set = set;
  50617. Vue.delete = del;
  50618. Vue.nextTick = nextTick;
  50619. // 2.6 explicit observable API
  50620. Vue.observable = function (obj) {
  50621. observe(obj);
  50622. return obj
  50623. };
  50624. Vue.options = Object.create(null);
  50625. ASSET_TYPES.forEach(function (type) {
  50626. Vue.options[type + 's'] = Object.create(null);
  50627. });
  50628. // this is used to identify the "base" constructor to extend all plain-object
  50629. // components with in Weex's multi-instance scenarios.
  50630. Vue.options._base = Vue;
  50631. extend(Vue.options.components, builtInComponents);
  50632. initUse(Vue);
  50633. initMixin$1(Vue);
  50634. initExtend(Vue);
  50635. initAssetRegisters(Vue);
  50636. }
  50637. initGlobalAPI(Vue);
  50638. Object.defineProperty(Vue.prototype, '$isServer', {
  50639. get: isServerRendering
  50640. });
  50641. Object.defineProperty(Vue.prototype, '$ssrContext', {
  50642. get: function get () {
  50643. /* istanbul ignore next */
  50644. return this.$vnode && this.$vnode.ssrContext
  50645. }
  50646. });
  50647. // expose FunctionalRenderContext for ssr runtime helper installation
  50648. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  50649. value: FunctionalRenderContext
  50650. });
  50651. Vue.version = '2.6.11';
  50652. /* */
  50653. // these are reserved for web because they are directly compiled away
  50654. // during template compilation
  50655. var isReservedAttr = makeMap('style,class');
  50656. // attributes that should be using props for binding
  50657. var acceptValue = makeMap('input,textarea,option,select,progress');
  50658. var mustUseProp = function (tag, type, attr) {
  50659. return (
  50660. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  50661. (attr === 'selected' && tag === 'option') ||
  50662. (attr === 'checked' && tag === 'input') ||
  50663. (attr === 'muted' && tag === 'video')
  50664. )
  50665. };
  50666. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  50667. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  50668. var convertEnumeratedValue = function (key, value) {
  50669. return isFalsyAttrValue(value) || value === 'false'
  50670. ? 'false'
  50671. // allow arbitrary string value for contenteditable
  50672. : key === 'contenteditable' && isValidContentEditableValue(value)
  50673. ? value
  50674. : 'true'
  50675. };
  50676. var isBooleanAttr = makeMap(
  50677. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  50678. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  50679. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  50680. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  50681. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  50682. 'truespeed,typemustmatch,visible'
  50683. );
  50684. var xlinkNS = 'http://www.w3.org/1999/xlink';
  50685. var isXlink = function (name) {
  50686. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  50687. };
  50688. var getXlinkProp = function (name) {
  50689. return isXlink(name) ? name.slice(6, name.length) : ''
  50690. };
  50691. var isFalsyAttrValue = function (val) {
  50692. return val == null || val === false
  50693. };
  50694. /* */
  50695. function genClassForVnode (vnode) {
  50696. var data = vnode.data;
  50697. var parentNode = vnode;
  50698. var childNode = vnode;
  50699. while (isDef(childNode.componentInstance)) {
  50700. childNode = childNode.componentInstance._vnode;
  50701. if (childNode && childNode.data) {
  50702. data = mergeClassData(childNode.data, data);
  50703. }
  50704. }
  50705. while (isDef(parentNode = parentNode.parent)) {
  50706. if (parentNode && parentNode.data) {
  50707. data = mergeClassData(data, parentNode.data);
  50708. }
  50709. }
  50710. return renderClass(data.staticClass, data.class)
  50711. }
  50712. function mergeClassData (child, parent) {
  50713. return {
  50714. staticClass: concat(child.staticClass, parent.staticClass),
  50715. class: isDef(child.class)
  50716. ? [child.class, parent.class]
  50717. : parent.class
  50718. }
  50719. }
  50720. function renderClass (
  50721. staticClass,
  50722. dynamicClass
  50723. ) {
  50724. if (isDef(staticClass) || isDef(dynamicClass)) {
  50725. return concat(staticClass, stringifyClass(dynamicClass))
  50726. }
  50727. /* istanbul ignore next */
  50728. return ''
  50729. }
  50730. function concat (a, b) {
  50731. return a ? b ? (a + ' ' + b) : a : (b || '')
  50732. }
  50733. function stringifyClass (value) {
  50734. if (Array.isArray(value)) {
  50735. return stringifyArray(value)
  50736. }
  50737. if (isObject(value)) {
  50738. return stringifyObject(value)
  50739. }
  50740. if (typeof value === 'string') {
  50741. return value
  50742. }
  50743. /* istanbul ignore next */
  50744. return ''
  50745. }
  50746. function stringifyArray (value) {
  50747. var res = '';
  50748. var stringified;
  50749. for (var i = 0, l = value.length; i < l; i++) {
  50750. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  50751. if (res) { res += ' '; }
  50752. res += stringified;
  50753. }
  50754. }
  50755. return res
  50756. }
  50757. function stringifyObject (value) {
  50758. var res = '';
  50759. for (var key in value) {
  50760. if (value[key]) {
  50761. if (res) { res += ' '; }
  50762. res += key;
  50763. }
  50764. }
  50765. return res
  50766. }
  50767. /* */
  50768. var namespaceMap = {
  50769. svg: 'http://www.w3.org/2000/svg',
  50770. math: 'http://www.w3.org/1998/Math/MathML'
  50771. };
  50772. var isHTMLTag = makeMap(
  50773. 'html,body,base,head,link,meta,style,title,' +
  50774. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  50775. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  50776. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  50777. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  50778. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  50779. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  50780. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  50781. 'output,progress,select,textarea,' +
  50782. 'details,dialog,menu,menuitem,summary,' +
  50783. 'content,element,shadow,template,blockquote,iframe,tfoot'
  50784. );
  50785. // this map is intentionally selective, only covering SVG elements that may
  50786. // contain child elements.
  50787. var isSVG = makeMap(
  50788. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  50789. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  50790. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  50791. true
  50792. );
  50793. var isPreTag = function (tag) { return tag === 'pre'; };
  50794. var isReservedTag = function (tag) {
  50795. return isHTMLTag(tag) || isSVG(tag)
  50796. };
  50797. function getTagNamespace (tag) {
  50798. if (isSVG(tag)) {
  50799. return 'svg'
  50800. }
  50801. // basic support for MathML
  50802. // note it doesn't support other MathML elements being component roots
  50803. if (tag === 'math') {
  50804. return 'math'
  50805. }
  50806. }
  50807. var unknownElementCache = Object.create(null);
  50808. function isUnknownElement (tag) {
  50809. /* istanbul ignore if */
  50810. if (!inBrowser) {
  50811. return true
  50812. }
  50813. if (isReservedTag(tag)) {
  50814. return false
  50815. }
  50816. tag = tag.toLowerCase();
  50817. /* istanbul ignore if */
  50818. if (unknownElementCache[tag] != null) {
  50819. return unknownElementCache[tag]
  50820. }
  50821. var el = document.createElement(tag);
  50822. if (tag.indexOf('-') > -1) {
  50823. // http://stackoverflow.com/a/28210364/1070244
  50824. return (unknownElementCache[tag] = (
  50825. el.constructor === window.HTMLUnknownElement ||
  50826. el.constructor === window.HTMLElement
  50827. ))
  50828. } else {
  50829. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  50830. }
  50831. }
  50832. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  50833. /* */
  50834. /**
  50835. * Query an element selector if it's not an element already.
  50836. */
  50837. function query (el) {
  50838. if (typeof el === 'string') {
  50839. var selected = document.querySelector(el);
  50840. if (!selected) {
  50841. warn(
  50842. 'Cannot find element: ' + el
  50843. );
  50844. return document.createElement('div')
  50845. }
  50846. return selected
  50847. } else {
  50848. return el
  50849. }
  50850. }
  50851. /* */
  50852. function createElement$1 (tagName, vnode) {
  50853. var elm = document.createElement(tagName);
  50854. if (tagName !== 'select') {
  50855. return elm
  50856. }
  50857. // false or null will remove the attribute but undefined will not
  50858. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  50859. elm.setAttribute('multiple', 'multiple');
  50860. }
  50861. return elm
  50862. }
  50863. function createElementNS (namespace, tagName) {
  50864. return document.createElementNS(namespaceMap[namespace], tagName)
  50865. }
  50866. function createTextNode (text) {
  50867. return document.createTextNode(text)
  50868. }
  50869. function createComment (text) {
  50870. return document.createComment(text)
  50871. }
  50872. function insertBefore (parentNode, newNode, referenceNode) {
  50873. parentNode.insertBefore(newNode, referenceNode);
  50874. }
  50875. function removeChild (node, child) {
  50876. node.removeChild(child);
  50877. }
  50878. function appendChild (node, child) {
  50879. node.appendChild(child);
  50880. }
  50881. function parentNode (node) {
  50882. return node.parentNode
  50883. }
  50884. function nextSibling (node) {
  50885. return node.nextSibling
  50886. }
  50887. function tagName (node) {
  50888. return node.tagName
  50889. }
  50890. function setTextContent (node, text) {
  50891. node.textContent = text;
  50892. }
  50893. function setStyleScope (node, scopeId) {
  50894. node.setAttribute(scopeId, '');
  50895. }
  50896. var nodeOps = /*#__PURE__*/Object.freeze({
  50897. createElement: createElement$1,
  50898. createElementNS: createElementNS,
  50899. createTextNode: createTextNode,
  50900. createComment: createComment,
  50901. insertBefore: insertBefore,
  50902. removeChild: removeChild,
  50903. appendChild: appendChild,
  50904. parentNode: parentNode,
  50905. nextSibling: nextSibling,
  50906. tagName: tagName,
  50907. setTextContent: setTextContent,
  50908. setStyleScope: setStyleScope
  50909. });
  50910. /* */
  50911. var ref = {
  50912. create: function create (_, vnode) {
  50913. registerRef(vnode);
  50914. },
  50915. update: function update (oldVnode, vnode) {
  50916. if (oldVnode.data.ref !== vnode.data.ref) {
  50917. registerRef(oldVnode, true);
  50918. registerRef(vnode);
  50919. }
  50920. },
  50921. destroy: function destroy (vnode) {
  50922. registerRef(vnode, true);
  50923. }
  50924. };
  50925. function registerRef (vnode, isRemoval) {
  50926. var key = vnode.data.ref;
  50927. if (!isDef(key)) { return }
  50928. var vm = vnode.context;
  50929. var ref = vnode.componentInstance || vnode.elm;
  50930. var refs = vm.$refs;
  50931. if (isRemoval) {
  50932. if (Array.isArray(refs[key])) {
  50933. remove(refs[key], ref);
  50934. } else if (refs[key] === ref) {
  50935. refs[key] = undefined;
  50936. }
  50937. } else {
  50938. if (vnode.data.refInFor) {
  50939. if (!Array.isArray(refs[key])) {
  50940. refs[key] = [ref];
  50941. } else if (refs[key].indexOf(ref) < 0) {
  50942. // $flow-disable-line
  50943. refs[key].push(ref);
  50944. }
  50945. } else {
  50946. refs[key] = ref;
  50947. }
  50948. }
  50949. }
  50950. /**
  50951. * Virtual DOM patching algorithm based on Snabbdom by
  50952. * Simon Friis Vindum (@paldepind)
  50953. * Licensed under the MIT License
  50954. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  50955. *
  50956. * modified by Evan You (@yyx990803)
  50957. *
  50958. * Not type-checking this because this file is perf-critical and the cost
  50959. * of making flow understand it is not worth it.
  50960. */
  50961. var emptyNode = new VNode('', {}, []);
  50962. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  50963. function sameVnode (a, b) {
  50964. return (
  50965. a.key === b.key && (
  50966. (
  50967. a.tag === b.tag &&
  50968. a.isComment === b.isComment &&
  50969. isDef(a.data) === isDef(b.data) &&
  50970. sameInputType(a, b)
  50971. ) || (
  50972. isTrue(a.isAsyncPlaceholder) &&
  50973. a.asyncFactory === b.asyncFactory &&
  50974. isUndef(b.asyncFactory.error)
  50975. )
  50976. )
  50977. )
  50978. }
  50979. function sameInputType (a, b) {
  50980. if (a.tag !== 'input') { return true }
  50981. var i;
  50982. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  50983. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  50984. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  50985. }
  50986. function createKeyToOldIdx (children, beginIdx, endIdx) {
  50987. var i, key;
  50988. var map = {};
  50989. for (i = beginIdx; i <= endIdx; ++i) {
  50990. key = children[i].key;
  50991. if (isDef(key)) { map[key] = i; }
  50992. }
  50993. return map
  50994. }
  50995. function createPatchFunction (backend) {
  50996. var i, j;
  50997. var cbs = {};
  50998. var modules = backend.modules;
  50999. var nodeOps = backend.nodeOps;
  51000. for (i = 0; i < hooks.length; ++i) {
  51001. cbs[hooks[i]] = [];
  51002. for (j = 0; j < modules.length; ++j) {
  51003. if (isDef(modules[j][hooks[i]])) {
  51004. cbs[hooks[i]].push(modules[j][hooks[i]]);
  51005. }
  51006. }
  51007. }
  51008. function emptyNodeAt (elm) {
  51009. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  51010. }
  51011. function createRmCb (childElm, listeners) {
  51012. function remove$$1 () {
  51013. if (--remove$$1.listeners === 0) {
  51014. removeNode(childElm);
  51015. }
  51016. }
  51017. remove$$1.listeners = listeners;
  51018. return remove$$1
  51019. }
  51020. function removeNode (el) {
  51021. var parent = nodeOps.parentNode(el);
  51022. // element may have already been removed due to v-html / v-text
  51023. if (isDef(parent)) {
  51024. nodeOps.removeChild(parent, el);
  51025. }
  51026. }
  51027. function isUnknownElement$$1 (vnode, inVPre) {
  51028. return (
  51029. !inVPre &&
  51030. !vnode.ns &&
  51031. !(
  51032. config.ignoredElements.length &&
  51033. config.ignoredElements.some(function (ignore) {
  51034. return isRegExp(ignore)
  51035. ? ignore.test(vnode.tag)
  51036. : ignore === vnode.tag
  51037. })
  51038. ) &&
  51039. config.isUnknownElement(vnode.tag)
  51040. )
  51041. }
  51042. var creatingElmInVPre = 0;
  51043. function createElm (
  51044. vnode,
  51045. insertedVnodeQueue,
  51046. parentElm,
  51047. refElm,
  51048. nested,
  51049. ownerArray,
  51050. index
  51051. ) {
  51052. if (isDef(vnode.elm) && isDef(ownerArray)) {
  51053. // This vnode was used in a previous render!
  51054. // now it's used as a new node, overwriting its elm would cause
  51055. // potential patch errors down the road when it's used as an insertion
  51056. // reference node. Instead, we clone the node on-demand before creating
  51057. // associated DOM element for it.
  51058. vnode = ownerArray[index] = cloneVNode(vnode);
  51059. }
  51060. vnode.isRootInsert = !nested; // for transition enter check
  51061. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  51062. return
  51063. }
  51064. var data = vnode.data;
  51065. var children = vnode.children;
  51066. var tag = vnode.tag;
  51067. if (isDef(tag)) {
  51068. {
  51069. if (data && data.pre) {
  51070. creatingElmInVPre++;
  51071. }
  51072. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  51073. warn(
  51074. 'Unknown custom element: <' + tag + '> - did you ' +
  51075. 'register the component correctly? For recursive components, ' +
  51076. 'make sure to provide the "name" option.',
  51077. vnode.context
  51078. );
  51079. }
  51080. }
  51081. vnode.elm = vnode.ns
  51082. ? nodeOps.createElementNS(vnode.ns, tag)
  51083. : nodeOps.createElement(tag, vnode);
  51084. setScope(vnode);
  51085. /* istanbul ignore if */
  51086. {
  51087. createChildren(vnode, children, insertedVnodeQueue);
  51088. if (isDef(data)) {
  51089. invokeCreateHooks(vnode, insertedVnodeQueue);
  51090. }
  51091. insert(parentElm, vnode.elm, refElm);
  51092. }
  51093. if (data && data.pre) {
  51094. creatingElmInVPre--;
  51095. }
  51096. } else if (isTrue(vnode.isComment)) {
  51097. vnode.elm = nodeOps.createComment(vnode.text);
  51098. insert(parentElm, vnode.elm, refElm);
  51099. } else {
  51100. vnode.elm = nodeOps.createTextNode(vnode.text);
  51101. insert(parentElm, vnode.elm, refElm);
  51102. }
  51103. }
  51104. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  51105. var i = vnode.data;
  51106. if (isDef(i)) {
  51107. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  51108. if (isDef(i = i.hook) && isDef(i = i.init)) {
  51109. i(vnode, false /* hydrating */);
  51110. }
  51111. // after calling the init hook, if the vnode is a child component
  51112. // it should've created a child instance and mounted it. the child
  51113. // component also has set the placeholder vnode's elm.
  51114. // in that case we can just return the element and be done.
  51115. if (isDef(vnode.componentInstance)) {
  51116. initComponent(vnode, insertedVnodeQueue);
  51117. insert(parentElm, vnode.elm, refElm);
  51118. if (isTrue(isReactivated)) {
  51119. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  51120. }
  51121. return true
  51122. }
  51123. }
  51124. }
  51125. function initComponent (vnode, insertedVnodeQueue) {
  51126. if (isDef(vnode.data.pendingInsert)) {
  51127. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  51128. vnode.data.pendingInsert = null;
  51129. }
  51130. vnode.elm = vnode.componentInstance.$el;
  51131. if (isPatchable(vnode)) {
  51132. invokeCreateHooks(vnode, insertedVnodeQueue);
  51133. setScope(vnode);
  51134. } else {
  51135. // empty component root.
  51136. // skip all element-related modules except for ref (#3455)
  51137. registerRef(vnode);
  51138. // make sure to invoke the insert hook
  51139. insertedVnodeQueue.push(vnode);
  51140. }
  51141. }
  51142. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  51143. var i;
  51144. // hack for #4339: a reactivated component with inner transition
  51145. // does not trigger because the inner node's created hooks are not called
  51146. // again. It's not ideal to involve module-specific logic in here but
  51147. // there doesn't seem to be a better way to do it.
  51148. var innerNode = vnode;
  51149. while (innerNode.componentInstance) {
  51150. innerNode = innerNode.componentInstance._vnode;
  51151. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  51152. for (i = 0; i < cbs.activate.length; ++i) {
  51153. cbs.activate[i](emptyNode, innerNode);
  51154. }
  51155. insertedVnodeQueue.push(innerNode);
  51156. break
  51157. }
  51158. }
  51159. // unlike a newly created component,
  51160. // a reactivated keep-alive component doesn't insert itself
  51161. insert(parentElm, vnode.elm, refElm);
  51162. }
  51163. function insert (parent, elm, ref$$1) {
  51164. if (isDef(parent)) {
  51165. if (isDef(ref$$1)) {
  51166. if (nodeOps.parentNode(ref$$1) === parent) {
  51167. nodeOps.insertBefore(parent, elm, ref$$1);
  51168. }
  51169. } else {
  51170. nodeOps.appendChild(parent, elm);
  51171. }
  51172. }
  51173. }
  51174. function createChildren (vnode, children, insertedVnodeQueue) {
  51175. if (Array.isArray(children)) {
  51176. {
  51177. checkDuplicateKeys(children);
  51178. }
  51179. for (var i = 0; i < children.length; ++i) {
  51180. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  51181. }
  51182. } else if (isPrimitive(vnode.text)) {
  51183. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  51184. }
  51185. }
  51186. function isPatchable (vnode) {
  51187. while (vnode.componentInstance) {
  51188. vnode = vnode.componentInstance._vnode;
  51189. }
  51190. return isDef(vnode.tag)
  51191. }
  51192. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  51193. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  51194. cbs.create[i$1](emptyNode, vnode);
  51195. }
  51196. i = vnode.data.hook; // Reuse variable
  51197. if (isDef(i)) {
  51198. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  51199. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  51200. }
  51201. }
  51202. // set scope id attribute for scoped CSS.
  51203. // this is implemented as a special case to avoid the overhead
  51204. // of going through the normal attribute patching process.
  51205. function setScope (vnode) {
  51206. var i;
  51207. if (isDef(i = vnode.fnScopeId)) {
  51208. nodeOps.setStyleScope(vnode.elm, i);
  51209. } else {
  51210. var ancestor = vnode;
  51211. while (ancestor) {
  51212. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  51213. nodeOps.setStyleScope(vnode.elm, i);
  51214. }
  51215. ancestor = ancestor.parent;
  51216. }
  51217. }
  51218. // for slot content they should also get the scopeId from the host instance.
  51219. if (isDef(i = activeInstance) &&
  51220. i !== vnode.context &&
  51221. i !== vnode.fnContext &&
  51222. isDef(i = i.$options._scopeId)
  51223. ) {
  51224. nodeOps.setStyleScope(vnode.elm, i);
  51225. }
  51226. }
  51227. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  51228. for (; startIdx <= endIdx; ++startIdx) {
  51229. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  51230. }
  51231. }
  51232. function invokeDestroyHook (vnode) {
  51233. var i, j;
  51234. var data = vnode.data;
  51235. if (isDef(data)) {
  51236. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  51237. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  51238. }
  51239. if (isDef(i = vnode.children)) {
  51240. for (j = 0; j < vnode.children.length; ++j) {
  51241. invokeDestroyHook(vnode.children[j]);
  51242. }
  51243. }
  51244. }
  51245. function removeVnodes (vnodes, startIdx, endIdx) {
  51246. for (; startIdx <= endIdx; ++startIdx) {
  51247. var ch = vnodes[startIdx];
  51248. if (isDef(ch)) {
  51249. if (isDef(ch.tag)) {
  51250. removeAndInvokeRemoveHook(ch);
  51251. invokeDestroyHook(ch);
  51252. } else { // Text node
  51253. removeNode(ch.elm);
  51254. }
  51255. }
  51256. }
  51257. }
  51258. function removeAndInvokeRemoveHook (vnode, rm) {
  51259. if (isDef(rm) || isDef(vnode.data)) {
  51260. var i;
  51261. var listeners = cbs.remove.length + 1;
  51262. if (isDef(rm)) {
  51263. // we have a recursively passed down rm callback
  51264. // increase the listeners count
  51265. rm.listeners += listeners;
  51266. } else {
  51267. // directly removing
  51268. rm = createRmCb(vnode.elm, listeners);
  51269. }
  51270. // recursively invoke hooks on child component root node
  51271. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  51272. removeAndInvokeRemoveHook(i, rm);
  51273. }
  51274. for (i = 0; i < cbs.remove.length; ++i) {
  51275. cbs.remove[i](vnode, rm);
  51276. }
  51277. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  51278. i(vnode, rm);
  51279. } else {
  51280. rm();
  51281. }
  51282. } else {
  51283. removeNode(vnode.elm);
  51284. }
  51285. }
  51286. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  51287. var oldStartIdx = 0;
  51288. var newStartIdx = 0;
  51289. var oldEndIdx = oldCh.length - 1;
  51290. var oldStartVnode = oldCh[0];
  51291. var oldEndVnode = oldCh[oldEndIdx];
  51292. var newEndIdx = newCh.length - 1;
  51293. var newStartVnode = newCh[0];
  51294. var newEndVnode = newCh[newEndIdx];
  51295. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  51296. // removeOnly is a special flag used only by <transition-group>
  51297. // to ensure removed elements stay in correct relative positions
  51298. // during leaving transitions
  51299. var canMove = !removeOnly;
  51300. {
  51301. checkDuplicateKeys(newCh);
  51302. }
  51303. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  51304. if (isUndef(oldStartVnode)) {
  51305. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  51306. } else if (isUndef(oldEndVnode)) {
  51307. oldEndVnode = oldCh[--oldEndIdx];
  51308. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  51309. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  51310. oldStartVnode = oldCh[++oldStartIdx];
  51311. newStartVnode = newCh[++newStartIdx];
  51312. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  51313. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  51314. oldEndVnode = oldCh[--oldEndIdx];
  51315. newEndVnode = newCh[--newEndIdx];
  51316. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  51317. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  51318. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  51319. oldStartVnode = oldCh[++oldStartIdx];
  51320. newEndVnode = newCh[--newEndIdx];
  51321. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  51322. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  51323. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  51324. oldEndVnode = oldCh[--oldEndIdx];
  51325. newStartVnode = newCh[++newStartIdx];
  51326. } else {
  51327. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  51328. idxInOld = isDef(newStartVnode.key)
  51329. ? oldKeyToIdx[newStartVnode.key]
  51330. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  51331. if (isUndef(idxInOld)) { // New element
  51332. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  51333. } else {
  51334. vnodeToMove = oldCh[idxInOld];
  51335. if (sameVnode(vnodeToMove, newStartVnode)) {
  51336. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  51337. oldCh[idxInOld] = undefined;
  51338. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  51339. } else {
  51340. // same key but different element. treat as new element
  51341. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  51342. }
  51343. }
  51344. newStartVnode = newCh[++newStartIdx];
  51345. }
  51346. }
  51347. if (oldStartIdx > oldEndIdx) {
  51348. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  51349. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  51350. } else if (newStartIdx > newEndIdx) {
  51351. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  51352. }
  51353. }
  51354. function checkDuplicateKeys (children) {
  51355. var seenKeys = {};
  51356. for (var i = 0; i < children.length; i++) {
  51357. var vnode = children[i];
  51358. var key = vnode.key;
  51359. if (isDef(key)) {
  51360. if (seenKeys[key]) {
  51361. warn(
  51362. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  51363. vnode.context
  51364. );
  51365. } else {
  51366. seenKeys[key] = true;
  51367. }
  51368. }
  51369. }
  51370. }
  51371. function findIdxInOld (node, oldCh, start, end) {
  51372. for (var i = start; i < end; i++) {
  51373. var c = oldCh[i];
  51374. if (isDef(c) && sameVnode(node, c)) { return i }
  51375. }
  51376. }
  51377. function patchVnode (
  51378. oldVnode,
  51379. vnode,
  51380. insertedVnodeQueue,
  51381. ownerArray,
  51382. index,
  51383. removeOnly
  51384. ) {
  51385. if (oldVnode === vnode) {
  51386. return
  51387. }
  51388. if (isDef(vnode.elm) && isDef(ownerArray)) {
  51389. // clone reused vnode
  51390. vnode = ownerArray[index] = cloneVNode(vnode);
  51391. }
  51392. var elm = vnode.elm = oldVnode.elm;
  51393. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  51394. if (isDef(vnode.asyncFactory.resolved)) {
  51395. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  51396. } else {
  51397. vnode.isAsyncPlaceholder = true;
  51398. }
  51399. return
  51400. }
  51401. // reuse element for static trees.
  51402. // note we only do this if the vnode is cloned -
  51403. // if the new node is not cloned it means the render functions have been
  51404. // reset by the hot-reload-api and we need to do a proper re-render.
  51405. if (isTrue(vnode.isStatic) &&
  51406. isTrue(oldVnode.isStatic) &&
  51407. vnode.key === oldVnode.key &&
  51408. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  51409. ) {
  51410. vnode.componentInstance = oldVnode.componentInstance;
  51411. return
  51412. }
  51413. var i;
  51414. var data = vnode.data;
  51415. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  51416. i(oldVnode, vnode);
  51417. }
  51418. var oldCh = oldVnode.children;
  51419. var ch = vnode.children;
  51420. if (isDef(data) && isPatchable(vnode)) {
  51421. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  51422. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  51423. }
  51424. if (isUndef(vnode.text)) {
  51425. if (isDef(oldCh) && isDef(ch)) {
  51426. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  51427. } else if (isDef(ch)) {
  51428. {
  51429. checkDuplicateKeys(ch);
  51430. }
  51431. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  51432. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  51433. } else if (isDef(oldCh)) {
  51434. removeVnodes(oldCh, 0, oldCh.length - 1);
  51435. } else if (isDef(oldVnode.text)) {
  51436. nodeOps.setTextContent(elm, '');
  51437. }
  51438. } else if (oldVnode.text !== vnode.text) {
  51439. nodeOps.setTextContent(elm, vnode.text);
  51440. }
  51441. if (isDef(data)) {
  51442. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  51443. }
  51444. }
  51445. function invokeInsertHook (vnode, queue, initial) {
  51446. // delay insert hooks for component root nodes, invoke them after the
  51447. // element is really inserted
  51448. if (isTrue(initial) && isDef(vnode.parent)) {
  51449. vnode.parent.data.pendingInsert = queue;
  51450. } else {
  51451. for (var i = 0; i < queue.length; ++i) {
  51452. queue[i].data.hook.insert(queue[i]);
  51453. }
  51454. }
  51455. }
  51456. var hydrationBailed = false;
  51457. // list of modules that can skip create hook during hydration because they
  51458. // are already rendered on the client or has no need for initialization
  51459. // Note: style is excluded because it relies on initial clone for future
  51460. // deep updates (#7063).
  51461. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  51462. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  51463. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  51464. var i;
  51465. var tag = vnode.tag;
  51466. var data = vnode.data;
  51467. var children = vnode.children;
  51468. inVPre = inVPre || (data && data.pre);
  51469. vnode.elm = elm;
  51470. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  51471. vnode.isAsyncPlaceholder = true;
  51472. return true
  51473. }
  51474. // assert node match
  51475. {
  51476. if (!assertNodeMatch(elm, vnode, inVPre)) {
  51477. return false
  51478. }
  51479. }
  51480. if (isDef(data)) {
  51481. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  51482. if (isDef(i = vnode.componentInstance)) {
  51483. // child component. it should have hydrated its own tree.
  51484. initComponent(vnode, insertedVnodeQueue);
  51485. return true
  51486. }
  51487. }
  51488. if (isDef(tag)) {
  51489. if (isDef(children)) {
  51490. // empty element, allow client to pick up and populate children
  51491. if (!elm.hasChildNodes()) {
  51492. createChildren(vnode, children, insertedVnodeQueue);
  51493. } else {
  51494. // v-html and domProps: innerHTML
  51495. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  51496. if (i !== elm.innerHTML) {
  51497. /* istanbul ignore if */
  51498. if (typeof console !== 'undefined' &&
  51499. !hydrationBailed
  51500. ) {
  51501. hydrationBailed = true;
  51502. console.warn('Parent: ', elm);
  51503. console.warn('server innerHTML: ', i);
  51504. console.warn('client innerHTML: ', elm.innerHTML);
  51505. }
  51506. return false
  51507. }
  51508. } else {
  51509. // iterate and compare children lists
  51510. var childrenMatch = true;
  51511. var childNode = elm.firstChild;
  51512. for (var i$1 = 0; i$1 < children.length; i$1++) {
  51513. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  51514. childrenMatch = false;
  51515. break
  51516. }
  51517. childNode = childNode.nextSibling;
  51518. }
  51519. // if childNode is not null, it means the actual childNodes list is
  51520. // longer than the virtual children list.
  51521. if (!childrenMatch || childNode) {
  51522. /* istanbul ignore if */
  51523. if (typeof console !== 'undefined' &&
  51524. !hydrationBailed
  51525. ) {
  51526. hydrationBailed = true;
  51527. console.warn('Parent: ', elm);
  51528. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  51529. }
  51530. return false
  51531. }
  51532. }
  51533. }
  51534. }
  51535. if (isDef(data)) {
  51536. var fullInvoke = false;
  51537. for (var key in data) {
  51538. if (!isRenderedModule(key)) {
  51539. fullInvoke = true;
  51540. invokeCreateHooks(vnode, insertedVnodeQueue);
  51541. break
  51542. }
  51543. }
  51544. if (!fullInvoke && data['class']) {
  51545. // ensure collecting deps for deep class bindings for future updates
  51546. traverse(data['class']);
  51547. }
  51548. }
  51549. } else if (elm.data !== vnode.text) {
  51550. elm.data = vnode.text;
  51551. }
  51552. return true
  51553. }
  51554. function assertNodeMatch (node, vnode, inVPre) {
  51555. if (isDef(vnode.tag)) {
  51556. return vnode.tag.indexOf('vue-component') === 0 || (
  51557. !isUnknownElement$$1(vnode, inVPre) &&
  51558. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  51559. )
  51560. } else {
  51561. return node.nodeType === (vnode.isComment ? 8 : 3)
  51562. }
  51563. }
  51564. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  51565. if (isUndef(vnode)) {
  51566. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  51567. return
  51568. }
  51569. var isInitialPatch = false;
  51570. var insertedVnodeQueue = [];
  51571. if (isUndef(oldVnode)) {
  51572. // empty mount (likely as component), create new root element
  51573. isInitialPatch = true;
  51574. createElm(vnode, insertedVnodeQueue);
  51575. } else {
  51576. var isRealElement = isDef(oldVnode.nodeType);
  51577. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  51578. // patch existing root node
  51579. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  51580. } else {
  51581. if (isRealElement) {
  51582. // mounting to a real element
  51583. // check if this is server-rendered content and if we can perform
  51584. // a successful hydration.
  51585. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  51586. oldVnode.removeAttribute(SSR_ATTR);
  51587. hydrating = true;
  51588. }
  51589. if (isTrue(hydrating)) {
  51590. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  51591. invokeInsertHook(vnode, insertedVnodeQueue, true);
  51592. return oldVnode
  51593. } else {
  51594. warn(
  51595. 'The client-side rendered virtual DOM tree is not matching ' +
  51596. 'server-rendered content. This is likely caused by incorrect ' +
  51597. 'HTML markup, for example nesting block-level elements inside ' +
  51598. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  51599. 'full client-side render.'
  51600. );
  51601. }
  51602. }
  51603. // either not server-rendered, or hydration failed.
  51604. // create an empty node and replace it
  51605. oldVnode = emptyNodeAt(oldVnode);
  51606. }
  51607. // replacing existing element
  51608. var oldElm = oldVnode.elm;
  51609. var parentElm = nodeOps.parentNode(oldElm);
  51610. // create new node
  51611. createElm(
  51612. vnode,
  51613. insertedVnodeQueue,
  51614. // extremely rare edge case: do not insert if old element is in a
  51615. // leaving transition. Only happens when combining transition +
  51616. // keep-alive + HOCs. (#4590)
  51617. oldElm._leaveCb ? null : parentElm,
  51618. nodeOps.nextSibling(oldElm)
  51619. );
  51620. // update parent placeholder node element, recursively
  51621. if (isDef(vnode.parent)) {
  51622. var ancestor = vnode.parent;
  51623. var patchable = isPatchable(vnode);
  51624. while (ancestor) {
  51625. for (var i = 0; i < cbs.destroy.length; ++i) {
  51626. cbs.destroy[i](ancestor);
  51627. }
  51628. ancestor.elm = vnode.elm;
  51629. if (patchable) {
  51630. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  51631. cbs.create[i$1](emptyNode, ancestor);
  51632. }
  51633. // #6513
  51634. // invoke insert hooks that may have been merged by create hooks.
  51635. // e.g. for directives that uses the "inserted" hook.
  51636. var insert = ancestor.data.hook.insert;
  51637. if (insert.merged) {
  51638. // start at index 1 to avoid re-invoking component mounted hook
  51639. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  51640. insert.fns[i$2]();
  51641. }
  51642. }
  51643. } else {
  51644. registerRef(ancestor);
  51645. }
  51646. ancestor = ancestor.parent;
  51647. }
  51648. }
  51649. // destroy old node
  51650. if (isDef(parentElm)) {
  51651. removeVnodes([oldVnode], 0, 0);
  51652. } else if (isDef(oldVnode.tag)) {
  51653. invokeDestroyHook(oldVnode);
  51654. }
  51655. }
  51656. }
  51657. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  51658. return vnode.elm
  51659. }
  51660. }
  51661. /* */
  51662. var directives = {
  51663. create: updateDirectives,
  51664. update: updateDirectives,
  51665. destroy: function unbindDirectives (vnode) {
  51666. updateDirectives(vnode, emptyNode);
  51667. }
  51668. };
  51669. function updateDirectives (oldVnode, vnode) {
  51670. if (oldVnode.data.directives || vnode.data.directives) {
  51671. _update(oldVnode, vnode);
  51672. }
  51673. }
  51674. function _update (oldVnode, vnode) {
  51675. var isCreate = oldVnode === emptyNode;
  51676. var isDestroy = vnode === emptyNode;
  51677. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  51678. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  51679. var dirsWithInsert = [];
  51680. var dirsWithPostpatch = [];
  51681. var key, oldDir, dir;
  51682. for (key in newDirs) {
  51683. oldDir = oldDirs[key];
  51684. dir = newDirs[key];
  51685. if (!oldDir) {
  51686. // new directive, bind
  51687. callHook$1(dir, 'bind', vnode, oldVnode);
  51688. if (dir.def && dir.def.inserted) {
  51689. dirsWithInsert.push(dir);
  51690. }
  51691. } else {
  51692. // existing directive, update
  51693. dir.oldValue = oldDir.value;
  51694. dir.oldArg = oldDir.arg;
  51695. callHook$1(dir, 'update', vnode, oldVnode);
  51696. if (dir.def && dir.def.componentUpdated) {
  51697. dirsWithPostpatch.push(dir);
  51698. }
  51699. }
  51700. }
  51701. if (dirsWithInsert.length) {
  51702. var callInsert = function () {
  51703. for (var i = 0; i < dirsWithInsert.length; i++) {
  51704. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  51705. }
  51706. };
  51707. if (isCreate) {
  51708. mergeVNodeHook(vnode, 'insert', callInsert);
  51709. } else {
  51710. callInsert();
  51711. }
  51712. }
  51713. if (dirsWithPostpatch.length) {
  51714. mergeVNodeHook(vnode, 'postpatch', function () {
  51715. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  51716. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  51717. }
  51718. });
  51719. }
  51720. if (!isCreate) {
  51721. for (key in oldDirs) {
  51722. if (!newDirs[key]) {
  51723. // no longer present, unbind
  51724. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  51725. }
  51726. }
  51727. }
  51728. }
  51729. var emptyModifiers = Object.create(null);
  51730. function normalizeDirectives$1 (
  51731. dirs,
  51732. vm
  51733. ) {
  51734. var res = Object.create(null);
  51735. if (!dirs) {
  51736. // $flow-disable-line
  51737. return res
  51738. }
  51739. var i, dir;
  51740. for (i = 0; i < dirs.length; i++) {
  51741. dir = dirs[i];
  51742. if (!dir.modifiers) {
  51743. // $flow-disable-line
  51744. dir.modifiers = emptyModifiers;
  51745. }
  51746. res[getRawDirName(dir)] = dir;
  51747. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  51748. }
  51749. // $flow-disable-line
  51750. return res
  51751. }
  51752. function getRawDirName (dir) {
  51753. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  51754. }
  51755. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  51756. var fn = dir.def && dir.def[hook];
  51757. if (fn) {
  51758. try {
  51759. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  51760. } catch (e) {
  51761. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  51762. }
  51763. }
  51764. }
  51765. var baseModules = [
  51766. ref,
  51767. directives
  51768. ];
  51769. /* */
  51770. function updateAttrs (oldVnode, vnode) {
  51771. var opts = vnode.componentOptions;
  51772. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  51773. return
  51774. }
  51775. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  51776. return
  51777. }
  51778. var key, cur, old;
  51779. var elm = vnode.elm;
  51780. var oldAttrs = oldVnode.data.attrs || {};
  51781. var attrs = vnode.data.attrs || {};
  51782. // clone observed objects, as the user probably wants to mutate it
  51783. if (isDef(attrs.__ob__)) {
  51784. attrs = vnode.data.attrs = extend({}, attrs);
  51785. }
  51786. for (key in attrs) {
  51787. cur = attrs[key];
  51788. old = oldAttrs[key];
  51789. if (old !== cur) {
  51790. setAttr(elm, key, cur);
  51791. }
  51792. }
  51793. // #4391: in IE9, setting type can reset value for input[type=radio]
  51794. // #6666: IE/Edge forces progress value down to 1 before setting a max
  51795. /* istanbul ignore if */
  51796. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  51797. setAttr(elm, 'value', attrs.value);
  51798. }
  51799. for (key in oldAttrs) {
  51800. if (isUndef(attrs[key])) {
  51801. if (isXlink(key)) {
  51802. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  51803. } else if (!isEnumeratedAttr(key)) {
  51804. elm.removeAttribute(key);
  51805. }
  51806. }
  51807. }
  51808. }
  51809. function setAttr (el, key, value) {
  51810. if (el.tagName.indexOf('-') > -1) {
  51811. baseSetAttr(el, key, value);
  51812. } else if (isBooleanAttr(key)) {
  51813. // set attribute for blank value
  51814. // e.g. <option disabled>Select one</option>
  51815. if (isFalsyAttrValue(value)) {
  51816. el.removeAttribute(key);
  51817. } else {
  51818. // technically allowfullscreen is a boolean attribute for <iframe>,
  51819. // but Flash expects a value of "true" when used on <embed> tag
  51820. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  51821. ? 'true'
  51822. : key;
  51823. el.setAttribute(key, value);
  51824. }
  51825. } else if (isEnumeratedAttr(key)) {
  51826. el.setAttribute(key, convertEnumeratedValue(key, value));
  51827. } else if (isXlink(key)) {
  51828. if (isFalsyAttrValue(value)) {
  51829. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  51830. } else {
  51831. el.setAttributeNS(xlinkNS, key, value);
  51832. }
  51833. } else {
  51834. baseSetAttr(el, key, value);
  51835. }
  51836. }
  51837. function baseSetAttr (el, key, value) {
  51838. if (isFalsyAttrValue(value)) {
  51839. el.removeAttribute(key);
  51840. } else {
  51841. // #7138: IE10 & 11 fires input event when setting placeholder on
  51842. // <textarea>... block the first input event and remove the blocker
  51843. // immediately.
  51844. /* istanbul ignore if */
  51845. if (
  51846. isIE && !isIE9 &&
  51847. el.tagName === 'TEXTAREA' &&
  51848. key === 'placeholder' && value !== '' && !el.__ieph
  51849. ) {
  51850. var blocker = function (e) {
  51851. e.stopImmediatePropagation();
  51852. el.removeEventListener('input', blocker);
  51853. };
  51854. el.addEventListener('input', blocker);
  51855. // $flow-disable-line
  51856. el.__ieph = true; /* IE placeholder patched */
  51857. }
  51858. el.setAttribute(key, value);
  51859. }
  51860. }
  51861. var attrs = {
  51862. create: updateAttrs,
  51863. update: updateAttrs
  51864. };
  51865. /* */
  51866. function updateClass (oldVnode, vnode) {
  51867. var el = vnode.elm;
  51868. var data = vnode.data;
  51869. var oldData = oldVnode.data;
  51870. if (
  51871. isUndef(data.staticClass) &&
  51872. isUndef(data.class) && (
  51873. isUndef(oldData) || (
  51874. isUndef(oldData.staticClass) &&
  51875. isUndef(oldData.class)
  51876. )
  51877. )
  51878. ) {
  51879. return
  51880. }
  51881. var cls = genClassForVnode(vnode);
  51882. // handle transition classes
  51883. var transitionClass = el._transitionClasses;
  51884. if (isDef(transitionClass)) {
  51885. cls = concat(cls, stringifyClass(transitionClass));
  51886. }
  51887. // set the class
  51888. if (cls !== el._prevClass) {
  51889. el.setAttribute('class', cls);
  51890. el._prevClass = cls;
  51891. }
  51892. }
  51893. var klass = {
  51894. create: updateClass,
  51895. update: updateClass
  51896. };
  51897. /* */
  51898. var validDivisionCharRE = /[\w).+\-_$\]]/;
  51899. function parseFilters (exp) {
  51900. var inSingle = false;
  51901. var inDouble = false;
  51902. var inTemplateString = false;
  51903. var inRegex = false;
  51904. var curly = 0;
  51905. var square = 0;
  51906. var paren = 0;
  51907. var lastFilterIndex = 0;
  51908. var c, prev, i, expression, filters;
  51909. for (i = 0; i < exp.length; i++) {
  51910. prev = c;
  51911. c = exp.charCodeAt(i);
  51912. if (inSingle) {
  51913. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  51914. } else if (inDouble) {
  51915. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  51916. } else if (inTemplateString) {
  51917. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  51918. } else if (inRegex) {
  51919. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  51920. } else if (
  51921. c === 0x7C && // pipe
  51922. exp.charCodeAt(i + 1) !== 0x7C &&
  51923. exp.charCodeAt(i - 1) !== 0x7C &&
  51924. !curly && !square && !paren
  51925. ) {
  51926. if (expression === undefined) {
  51927. // first filter, end of expression
  51928. lastFilterIndex = i + 1;
  51929. expression = exp.slice(0, i).trim();
  51930. } else {
  51931. pushFilter();
  51932. }
  51933. } else {
  51934. switch (c) {
  51935. case 0x22: inDouble = true; break // "
  51936. case 0x27: inSingle = true; break // '
  51937. case 0x60: inTemplateString = true; break // `
  51938. case 0x28: paren++; break // (
  51939. case 0x29: paren--; break // )
  51940. case 0x5B: square++; break // [
  51941. case 0x5D: square--; break // ]
  51942. case 0x7B: curly++; break // {
  51943. case 0x7D: curly--; break // }
  51944. }
  51945. if (c === 0x2f) { // /
  51946. var j = i - 1;
  51947. var p = (void 0);
  51948. // find first non-whitespace prev char
  51949. for (; j >= 0; j--) {
  51950. p = exp.charAt(j);
  51951. if (p !== ' ') { break }
  51952. }
  51953. if (!p || !validDivisionCharRE.test(p)) {
  51954. inRegex = true;
  51955. }
  51956. }
  51957. }
  51958. }
  51959. if (expression === undefined) {
  51960. expression = exp.slice(0, i).trim();
  51961. } else if (lastFilterIndex !== 0) {
  51962. pushFilter();
  51963. }
  51964. function pushFilter () {
  51965. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  51966. lastFilterIndex = i + 1;
  51967. }
  51968. if (filters) {
  51969. for (i = 0; i < filters.length; i++) {
  51970. expression = wrapFilter(expression, filters[i]);
  51971. }
  51972. }
  51973. return expression
  51974. }
  51975. function wrapFilter (exp, filter) {
  51976. var i = filter.indexOf('(');
  51977. if (i < 0) {
  51978. // _f: resolveFilter
  51979. return ("_f(\"" + filter + "\")(" + exp + ")")
  51980. } else {
  51981. var name = filter.slice(0, i);
  51982. var args = filter.slice(i + 1);
  51983. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  51984. }
  51985. }
  51986. /* */
  51987. /* eslint-disable no-unused-vars */
  51988. function baseWarn (msg, range) {
  51989. console.error(("[Vue compiler]: " + msg));
  51990. }
  51991. /* eslint-enable no-unused-vars */
  51992. function pluckModuleFunction (
  51993. modules,
  51994. key
  51995. ) {
  51996. return modules
  51997. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  51998. : []
  51999. }
  52000. function addProp (el, name, value, range, dynamic) {
  52001. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  52002. el.plain = false;
  52003. }
  52004. function addAttr (el, name, value, range, dynamic) {
  52005. var attrs = dynamic
  52006. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  52007. : (el.attrs || (el.attrs = []));
  52008. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  52009. el.plain = false;
  52010. }
  52011. // add a raw attr (use this in preTransforms)
  52012. function addRawAttr (el, name, value, range) {
  52013. el.attrsMap[name] = value;
  52014. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  52015. }
  52016. function addDirective (
  52017. el,
  52018. name,
  52019. rawName,
  52020. value,
  52021. arg,
  52022. isDynamicArg,
  52023. modifiers,
  52024. range
  52025. ) {
  52026. (el.directives || (el.directives = [])).push(rangeSetItem({
  52027. name: name,
  52028. rawName: rawName,
  52029. value: value,
  52030. arg: arg,
  52031. isDynamicArg: isDynamicArg,
  52032. modifiers: modifiers
  52033. }, range));
  52034. el.plain = false;
  52035. }
  52036. function prependModifierMarker (symbol, name, dynamic) {
  52037. return dynamic
  52038. ? ("_p(" + name + ",\"" + symbol + "\")")
  52039. : symbol + name // mark the event as captured
  52040. }
  52041. function addHandler (
  52042. el,
  52043. name,
  52044. value,
  52045. modifiers,
  52046. important,
  52047. warn,
  52048. range,
  52049. dynamic
  52050. ) {
  52051. modifiers = modifiers || emptyObject;
  52052. // warn prevent and passive modifier
  52053. /* istanbul ignore if */
  52054. if (
  52055. warn &&
  52056. modifiers.prevent && modifiers.passive
  52057. ) {
  52058. warn(
  52059. 'passive and prevent can\'t be used together. ' +
  52060. 'Passive handler can\'t prevent default event.',
  52061. range
  52062. );
  52063. }
  52064. // normalize click.right and click.middle since they don't actually fire
  52065. // this is technically browser-specific, but at least for now browsers are
  52066. // the only target envs that have right/middle clicks.
  52067. if (modifiers.right) {
  52068. if (dynamic) {
  52069. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  52070. } else if (name === 'click') {
  52071. name = 'contextmenu';
  52072. delete modifiers.right;
  52073. }
  52074. } else if (modifiers.middle) {
  52075. if (dynamic) {
  52076. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  52077. } else if (name === 'click') {
  52078. name = 'mouseup';
  52079. }
  52080. }
  52081. // check capture modifier
  52082. if (modifiers.capture) {
  52083. delete modifiers.capture;
  52084. name = prependModifierMarker('!', name, dynamic);
  52085. }
  52086. if (modifiers.once) {
  52087. delete modifiers.once;
  52088. name = prependModifierMarker('~', name, dynamic);
  52089. }
  52090. /* istanbul ignore if */
  52091. if (modifiers.passive) {
  52092. delete modifiers.passive;
  52093. name = prependModifierMarker('&', name, dynamic);
  52094. }
  52095. var events;
  52096. if (modifiers.native) {
  52097. delete modifiers.native;
  52098. events = el.nativeEvents || (el.nativeEvents = {});
  52099. } else {
  52100. events = el.events || (el.events = {});
  52101. }
  52102. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  52103. if (modifiers !== emptyObject) {
  52104. newHandler.modifiers = modifiers;
  52105. }
  52106. var handlers = events[name];
  52107. /* istanbul ignore if */
  52108. if (Array.isArray(handlers)) {
  52109. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  52110. } else if (handlers) {
  52111. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  52112. } else {
  52113. events[name] = newHandler;
  52114. }
  52115. el.plain = false;
  52116. }
  52117. function getRawBindingAttr (
  52118. el,
  52119. name
  52120. ) {
  52121. return el.rawAttrsMap[':' + name] ||
  52122. el.rawAttrsMap['v-bind:' + name] ||
  52123. el.rawAttrsMap[name]
  52124. }
  52125. function getBindingAttr (
  52126. el,
  52127. name,
  52128. getStatic
  52129. ) {
  52130. var dynamicValue =
  52131. getAndRemoveAttr(el, ':' + name) ||
  52132. getAndRemoveAttr(el, 'v-bind:' + name);
  52133. if (dynamicValue != null) {
  52134. return parseFilters(dynamicValue)
  52135. } else if (getStatic !== false) {
  52136. var staticValue = getAndRemoveAttr(el, name);
  52137. if (staticValue != null) {
  52138. return JSON.stringify(staticValue)
  52139. }
  52140. }
  52141. }
  52142. // note: this only removes the attr from the Array (attrsList) so that it
  52143. // doesn't get processed by processAttrs.
  52144. // By default it does NOT remove it from the map (attrsMap) because the map is
  52145. // needed during codegen.
  52146. function getAndRemoveAttr (
  52147. el,
  52148. name,
  52149. removeFromMap
  52150. ) {
  52151. var val;
  52152. if ((val = el.attrsMap[name]) != null) {
  52153. var list = el.attrsList;
  52154. for (var i = 0, l = list.length; i < l; i++) {
  52155. if (list[i].name === name) {
  52156. list.splice(i, 1);
  52157. break
  52158. }
  52159. }
  52160. }
  52161. if (removeFromMap) {
  52162. delete el.attrsMap[name];
  52163. }
  52164. return val
  52165. }
  52166. function getAndRemoveAttrByRegex (
  52167. el,
  52168. name
  52169. ) {
  52170. var list = el.attrsList;
  52171. for (var i = 0, l = list.length; i < l; i++) {
  52172. var attr = list[i];
  52173. if (name.test(attr.name)) {
  52174. list.splice(i, 1);
  52175. return attr
  52176. }
  52177. }
  52178. }
  52179. function rangeSetItem (
  52180. item,
  52181. range
  52182. ) {
  52183. if (range) {
  52184. if (range.start != null) {
  52185. item.start = range.start;
  52186. }
  52187. if (range.end != null) {
  52188. item.end = range.end;
  52189. }
  52190. }
  52191. return item
  52192. }
  52193. /* */
  52194. /**
  52195. * Cross-platform code generation for component v-model
  52196. */
  52197. function genComponentModel (
  52198. el,
  52199. value,
  52200. modifiers
  52201. ) {
  52202. var ref = modifiers || {};
  52203. var number = ref.number;
  52204. var trim = ref.trim;
  52205. var baseValueExpression = '$$v';
  52206. var valueExpression = baseValueExpression;
  52207. if (trim) {
  52208. valueExpression =
  52209. "(typeof " + baseValueExpression + " === 'string'" +
  52210. "? " + baseValueExpression + ".trim()" +
  52211. ": " + baseValueExpression + ")";
  52212. }
  52213. if (number) {
  52214. valueExpression = "_n(" + valueExpression + ")";
  52215. }
  52216. var assignment = genAssignmentCode(value, valueExpression);
  52217. el.model = {
  52218. value: ("(" + value + ")"),
  52219. expression: JSON.stringify(value),
  52220. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  52221. };
  52222. }
  52223. /**
  52224. * Cross-platform codegen helper for generating v-model value assignment code.
  52225. */
  52226. function genAssignmentCode (
  52227. value,
  52228. assignment
  52229. ) {
  52230. var res = parseModel(value);
  52231. if (res.key === null) {
  52232. return (value + "=" + assignment)
  52233. } else {
  52234. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  52235. }
  52236. }
  52237. /**
  52238. * Parse a v-model expression into a base path and a final key segment.
  52239. * Handles both dot-path and possible square brackets.
  52240. *
  52241. * Possible cases:
  52242. *
  52243. * - test
  52244. * - test[key]
  52245. * - test[test1[key]]
  52246. * - test["a"][key]
  52247. * - xxx.test[a[a].test1[key]]
  52248. * - test.xxx.a["asa"][test1[key]]
  52249. *
  52250. */
  52251. var len, str, chr, index$1, expressionPos, expressionEndPos;
  52252. function parseModel (val) {
  52253. // Fix https://github.com/vuejs/vue/pull/7730
  52254. // allow v-model="obj.val " (trailing whitespace)
  52255. val = val.trim();
  52256. len = val.length;
  52257. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  52258. index$1 = val.lastIndexOf('.');
  52259. if (index$1 > -1) {
  52260. return {
  52261. exp: val.slice(0, index$1),
  52262. key: '"' + val.slice(index$1 + 1) + '"'
  52263. }
  52264. } else {
  52265. return {
  52266. exp: val,
  52267. key: null
  52268. }
  52269. }
  52270. }
  52271. str = val;
  52272. index$1 = expressionPos = expressionEndPos = 0;
  52273. while (!eof()) {
  52274. chr = next();
  52275. /* istanbul ignore if */
  52276. if (isStringStart(chr)) {
  52277. parseString(chr);
  52278. } else if (chr === 0x5B) {
  52279. parseBracket(chr);
  52280. }
  52281. }
  52282. return {
  52283. exp: val.slice(0, expressionPos),
  52284. key: val.slice(expressionPos + 1, expressionEndPos)
  52285. }
  52286. }
  52287. function next () {
  52288. return str.charCodeAt(++index$1)
  52289. }
  52290. function eof () {
  52291. return index$1 >= len
  52292. }
  52293. function isStringStart (chr) {
  52294. return chr === 0x22 || chr === 0x27
  52295. }
  52296. function parseBracket (chr) {
  52297. var inBracket = 1;
  52298. expressionPos = index$1;
  52299. while (!eof()) {
  52300. chr = next();
  52301. if (isStringStart(chr)) {
  52302. parseString(chr);
  52303. continue
  52304. }
  52305. if (chr === 0x5B) { inBracket++; }
  52306. if (chr === 0x5D) { inBracket--; }
  52307. if (inBracket === 0) {
  52308. expressionEndPos = index$1;
  52309. break
  52310. }
  52311. }
  52312. }
  52313. function parseString (chr) {
  52314. var stringQuote = chr;
  52315. while (!eof()) {
  52316. chr = next();
  52317. if (chr === stringQuote) {
  52318. break
  52319. }
  52320. }
  52321. }
  52322. /* */
  52323. var warn$1;
  52324. // in some cases, the event used has to be determined at runtime
  52325. // so we used some reserved tokens during compile.
  52326. var RANGE_TOKEN = '__r';
  52327. var CHECKBOX_RADIO_TOKEN = '__c';
  52328. function model (
  52329. el,
  52330. dir,
  52331. _warn
  52332. ) {
  52333. warn$1 = _warn;
  52334. var value = dir.value;
  52335. var modifiers = dir.modifiers;
  52336. var tag = el.tag;
  52337. var type = el.attrsMap.type;
  52338. {
  52339. // inputs with type="file" are read only and setting the input's
  52340. // value will throw an error.
  52341. if (tag === 'input' && type === 'file') {
  52342. warn$1(
  52343. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  52344. "File inputs are read only. Use a v-on:change listener instead.",
  52345. el.rawAttrsMap['v-model']
  52346. );
  52347. }
  52348. }
  52349. if (el.component) {
  52350. genComponentModel(el, value, modifiers);
  52351. // component v-model doesn't need extra runtime
  52352. return false
  52353. } else if (tag === 'select') {
  52354. genSelect(el, value, modifiers);
  52355. } else if (tag === 'input' && type === 'checkbox') {
  52356. genCheckboxModel(el, value, modifiers);
  52357. } else if (tag === 'input' && type === 'radio') {
  52358. genRadioModel(el, value, modifiers);
  52359. } else if (tag === 'input' || tag === 'textarea') {
  52360. genDefaultModel(el, value, modifiers);
  52361. } else if (!config.isReservedTag(tag)) {
  52362. genComponentModel(el, value, modifiers);
  52363. // component v-model doesn't need extra runtime
  52364. return false
  52365. } else {
  52366. warn$1(
  52367. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  52368. "v-model is not supported on this element type. " +
  52369. 'If you are working with contenteditable, it\'s recommended to ' +
  52370. 'wrap a library dedicated for that purpose inside a custom component.',
  52371. el.rawAttrsMap['v-model']
  52372. );
  52373. }
  52374. // ensure runtime directive metadata
  52375. return true
  52376. }
  52377. function genCheckboxModel (
  52378. el,
  52379. value,
  52380. modifiers
  52381. ) {
  52382. var number = modifiers && modifiers.number;
  52383. var valueBinding = getBindingAttr(el, 'value') || 'null';
  52384. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  52385. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  52386. addProp(el, 'checked',
  52387. "Array.isArray(" + value + ")" +
  52388. "?_i(" + value + "," + valueBinding + ")>-1" + (
  52389. trueValueBinding === 'true'
  52390. ? (":(" + value + ")")
  52391. : (":_q(" + value + "," + trueValueBinding + ")")
  52392. )
  52393. );
  52394. addHandler(el, 'change',
  52395. "var $$a=" + value + "," +
  52396. '$$el=$event.target,' +
  52397. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  52398. 'if(Array.isArray($$a)){' +
  52399. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  52400. '$$i=_i($$a,$$v);' +
  52401. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  52402. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  52403. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  52404. null, true
  52405. );
  52406. }
  52407. function genRadioModel (
  52408. el,
  52409. value,
  52410. modifiers
  52411. ) {
  52412. var number = modifiers && modifiers.number;
  52413. var valueBinding = getBindingAttr(el, 'value') || 'null';
  52414. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  52415. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  52416. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  52417. }
  52418. function genSelect (
  52419. el,
  52420. value,
  52421. modifiers
  52422. ) {
  52423. var number = modifiers && modifiers.number;
  52424. var selectedVal = "Array.prototype.filter" +
  52425. ".call($event.target.options,function(o){return o.selected})" +
  52426. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  52427. "return " + (number ? '_n(val)' : 'val') + "})";
  52428. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  52429. var code = "var $$selectedVal = " + selectedVal + ";";
  52430. code = code + " " + (genAssignmentCode(value, assignment));
  52431. addHandler(el, 'change', code, null, true);
  52432. }
  52433. function genDefaultModel (
  52434. el,
  52435. value,
  52436. modifiers
  52437. ) {
  52438. var type = el.attrsMap.type;
  52439. // warn if v-bind:value conflicts with v-model
  52440. // except for inputs with v-bind:type
  52441. {
  52442. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  52443. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  52444. if (value$1 && !typeBinding) {
  52445. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  52446. warn$1(
  52447. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  52448. 'because the latter already expands to a value binding internally',
  52449. el.rawAttrsMap[binding]
  52450. );
  52451. }
  52452. }
  52453. var ref = modifiers || {};
  52454. var lazy = ref.lazy;
  52455. var number = ref.number;
  52456. var trim = ref.trim;
  52457. var needCompositionGuard = !lazy && type !== 'range';
  52458. var event = lazy
  52459. ? 'change'
  52460. : type === 'range'
  52461. ? RANGE_TOKEN
  52462. : 'input';
  52463. var valueExpression = '$event.target.value';
  52464. if (trim) {
  52465. valueExpression = "$event.target.value.trim()";
  52466. }
  52467. if (number) {
  52468. valueExpression = "_n(" + valueExpression + ")";
  52469. }
  52470. var code = genAssignmentCode(value, valueExpression);
  52471. if (needCompositionGuard) {
  52472. code = "if($event.target.composing)return;" + code;
  52473. }
  52474. addProp(el, 'value', ("(" + value + ")"));
  52475. addHandler(el, event, code, null, true);
  52476. if (trim || number) {
  52477. addHandler(el, 'blur', '$forceUpdate()');
  52478. }
  52479. }
  52480. /* */
  52481. // normalize v-model event tokens that can only be determined at runtime.
  52482. // it's important to place the event as the first in the array because
  52483. // the whole point is ensuring the v-model callback gets called before
  52484. // user-attached handlers.
  52485. function normalizeEvents (on) {
  52486. /* istanbul ignore if */
  52487. if (isDef(on[RANGE_TOKEN])) {
  52488. // IE input[type=range] only supports `change` event
  52489. var event = isIE ? 'change' : 'input';
  52490. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  52491. delete on[RANGE_TOKEN];
  52492. }
  52493. // This was originally intended to fix #4521 but no longer necessary
  52494. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  52495. /* istanbul ignore if */
  52496. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  52497. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  52498. delete on[CHECKBOX_RADIO_TOKEN];
  52499. }
  52500. }
  52501. var target$1;
  52502. function createOnceHandler$1 (event, handler, capture) {
  52503. var _target = target$1; // save current target element in closure
  52504. return function onceHandler () {
  52505. var res = handler.apply(null, arguments);
  52506. if (res !== null) {
  52507. remove$2(event, onceHandler, capture, _target);
  52508. }
  52509. }
  52510. }
  52511. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  52512. // implementation and does not fire microtasks in between event propagation, so
  52513. // safe to exclude.
  52514. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  52515. function add$1 (
  52516. name,
  52517. handler,
  52518. capture,
  52519. passive
  52520. ) {
  52521. // async edge case #6566: inner click event triggers patch, event handler
  52522. // attached to outer element during patch, and triggered again. This
  52523. // happens because browsers fire microtask ticks between event propagation.
  52524. // the solution is simple: we save the timestamp when a handler is attached,
  52525. // and the handler would only fire if the event passed to it was fired
  52526. // AFTER it was attached.
  52527. if (useMicrotaskFix) {
  52528. var attachedTimestamp = currentFlushTimestamp;
  52529. var original = handler;
  52530. handler = original._wrapper = function (e) {
  52531. if (
  52532. // no bubbling, should always fire.
  52533. // this is just a safety net in case event.timeStamp is unreliable in
  52534. // certain weird environments...
  52535. e.target === e.currentTarget ||
  52536. // event is fired after handler attachment
  52537. e.timeStamp >= attachedTimestamp ||
  52538. // bail for environments that have buggy event.timeStamp implementations
  52539. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  52540. // #9681 QtWebEngine event.timeStamp is negative value
  52541. e.timeStamp <= 0 ||
  52542. // #9448 bail if event is fired in another document in a multi-page
  52543. // electron/nw.js app, since event.timeStamp will be using a different
  52544. // starting reference
  52545. e.target.ownerDocument !== document
  52546. ) {
  52547. return original.apply(this, arguments)
  52548. }
  52549. };
  52550. }
  52551. target$1.addEventListener(
  52552. name,
  52553. handler,
  52554. supportsPassive
  52555. ? { capture: capture, passive: passive }
  52556. : capture
  52557. );
  52558. }
  52559. function remove$2 (
  52560. name,
  52561. handler,
  52562. capture,
  52563. _target
  52564. ) {
  52565. (_target || target$1).removeEventListener(
  52566. name,
  52567. handler._wrapper || handler,
  52568. capture
  52569. );
  52570. }
  52571. function updateDOMListeners (oldVnode, vnode) {
  52572. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  52573. return
  52574. }
  52575. var on = vnode.data.on || {};
  52576. var oldOn = oldVnode.data.on || {};
  52577. target$1 = vnode.elm;
  52578. normalizeEvents(on);
  52579. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  52580. target$1 = undefined;
  52581. }
  52582. var events = {
  52583. create: updateDOMListeners,
  52584. update: updateDOMListeners
  52585. };
  52586. /* */
  52587. var svgContainer;
  52588. function updateDOMProps (oldVnode, vnode) {
  52589. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  52590. return
  52591. }
  52592. var key, cur;
  52593. var elm = vnode.elm;
  52594. var oldProps = oldVnode.data.domProps || {};
  52595. var props = vnode.data.domProps || {};
  52596. // clone observed objects, as the user probably wants to mutate it
  52597. if (isDef(props.__ob__)) {
  52598. props = vnode.data.domProps = extend({}, props);
  52599. }
  52600. for (key in oldProps) {
  52601. if (!(key in props)) {
  52602. elm[key] = '';
  52603. }
  52604. }
  52605. for (key in props) {
  52606. cur = props[key];
  52607. // ignore children if the node has textContent or innerHTML,
  52608. // as these will throw away existing DOM nodes and cause removal errors
  52609. // on subsequent patches (#3360)
  52610. if (key === 'textContent' || key === 'innerHTML') {
  52611. if (vnode.children) { vnode.children.length = 0; }
  52612. if (cur === oldProps[key]) { continue }
  52613. // #6601 work around Chrome version <= 55 bug where single textNode
  52614. // replaced by innerHTML/textContent retains its parentNode property
  52615. if (elm.childNodes.length === 1) {
  52616. elm.removeChild(elm.childNodes[0]);
  52617. }
  52618. }
  52619. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  52620. // store value as _value as well since
  52621. // non-string values will be stringified
  52622. elm._value = cur;
  52623. // avoid resetting cursor position when value is the same
  52624. var strCur = isUndef(cur) ? '' : String(cur);
  52625. if (shouldUpdateValue(elm, strCur)) {
  52626. elm.value = strCur;
  52627. }
  52628. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  52629. // IE doesn't support innerHTML for SVG elements
  52630. svgContainer = svgContainer || document.createElement('div');
  52631. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  52632. var svg = svgContainer.firstChild;
  52633. while (elm.firstChild) {
  52634. elm.removeChild(elm.firstChild);
  52635. }
  52636. while (svg.firstChild) {
  52637. elm.appendChild(svg.firstChild);
  52638. }
  52639. } else if (
  52640. // skip the update if old and new VDOM state is the same.
  52641. // `value` is handled separately because the DOM value may be temporarily
  52642. // out of sync with VDOM state due to focus, composition and modifiers.
  52643. // This #4521 by skipping the unnecesarry `checked` update.
  52644. cur !== oldProps[key]
  52645. ) {
  52646. // some property updates can throw
  52647. // e.g. `value` on <progress> w/ non-finite value
  52648. try {
  52649. elm[key] = cur;
  52650. } catch (e) {}
  52651. }
  52652. }
  52653. }
  52654. // check platforms/web/util/attrs.js acceptValue
  52655. function shouldUpdateValue (elm, checkVal) {
  52656. return (!elm.composing && (
  52657. elm.tagName === 'OPTION' ||
  52658. isNotInFocusAndDirty(elm, checkVal) ||
  52659. isDirtyWithModifiers(elm, checkVal)
  52660. ))
  52661. }
  52662. function isNotInFocusAndDirty (elm, checkVal) {
  52663. // return true when textbox (.number and .trim) loses focus and its value is
  52664. // not equal to the updated value
  52665. var notInFocus = true;
  52666. // #6157
  52667. // work around IE bug when accessing document.activeElement in an iframe
  52668. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  52669. return notInFocus && elm.value !== checkVal
  52670. }
  52671. function isDirtyWithModifiers (elm, newVal) {
  52672. var value = elm.value;
  52673. var modifiers = elm._vModifiers; // injected by v-model runtime
  52674. if (isDef(modifiers)) {
  52675. if (modifiers.number) {
  52676. return toNumber(value) !== toNumber(newVal)
  52677. }
  52678. if (modifiers.trim) {
  52679. return value.trim() !== newVal.trim()
  52680. }
  52681. }
  52682. return value !== newVal
  52683. }
  52684. var domProps = {
  52685. create: updateDOMProps,
  52686. update: updateDOMProps
  52687. };
  52688. /* */
  52689. var parseStyleText = cached(function (cssText) {
  52690. var res = {};
  52691. var listDelimiter = /;(?![^(]*\))/g;
  52692. var propertyDelimiter = /:(.+)/;
  52693. cssText.split(listDelimiter).forEach(function (item) {
  52694. if (item) {
  52695. var tmp = item.split(propertyDelimiter);
  52696. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  52697. }
  52698. });
  52699. return res
  52700. });
  52701. // merge static and dynamic style data on the same vnode
  52702. function normalizeStyleData (data) {
  52703. var style = normalizeStyleBinding(data.style);
  52704. // static style is pre-processed into an object during compilation
  52705. // and is always a fresh object, so it's safe to merge into it
  52706. return data.staticStyle
  52707. ? extend(data.staticStyle, style)
  52708. : style
  52709. }
  52710. // normalize possible array / string values into Object
  52711. function normalizeStyleBinding (bindingStyle) {
  52712. if (Array.isArray(bindingStyle)) {
  52713. return toObject(bindingStyle)
  52714. }
  52715. if (typeof bindingStyle === 'string') {
  52716. return parseStyleText(bindingStyle)
  52717. }
  52718. return bindingStyle
  52719. }
  52720. /**
  52721. * parent component style should be after child's
  52722. * so that parent component's style could override it
  52723. */
  52724. function getStyle (vnode, checkChild) {
  52725. var res = {};
  52726. var styleData;
  52727. if (checkChild) {
  52728. var childNode = vnode;
  52729. while (childNode.componentInstance) {
  52730. childNode = childNode.componentInstance._vnode;
  52731. if (
  52732. childNode && childNode.data &&
  52733. (styleData = normalizeStyleData(childNode.data))
  52734. ) {
  52735. extend(res, styleData);
  52736. }
  52737. }
  52738. }
  52739. if ((styleData = normalizeStyleData(vnode.data))) {
  52740. extend(res, styleData);
  52741. }
  52742. var parentNode = vnode;
  52743. while ((parentNode = parentNode.parent)) {
  52744. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  52745. extend(res, styleData);
  52746. }
  52747. }
  52748. return res
  52749. }
  52750. /* */
  52751. var cssVarRE = /^--/;
  52752. var importantRE = /\s*!important$/;
  52753. var setProp = function (el, name, val) {
  52754. /* istanbul ignore if */
  52755. if (cssVarRE.test(name)) {
  52756. el.style.setProperty(name, val);
  52757. } else if (importantRE.test(val)) {
  52758. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  52759. } else {
  52760. var normalizedName = normalize(name);
  52761. if (Array.isArray(val)) {
  52762. // Support values array created by autoprefixer, e.g.
  52763. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  52764. // Set them one by one, and the browser will only set those it can recognize
  52765. for (var i = 0, len = val.length; i < len; i++) {
  52766. el.style[normalizedName] = val[i];
  52767. }
  52768. } else {
  52769. el.style[normalizedName] = val;
  52770. }
  52771. }
  52772. };
  52773. var vendorNames = ['Webkit', 'Moz', 'ms'];
  52774. var emptyStyle;
  52775. var normalize = cached(function (prop) {
  52776. emptyStyle = emptyStyle || document.createElement('div').style;
  52777. prop = camelize(prop);
  52778. if (prop !== 'filter' && (prop in emptyStyle)) {
  52779. return prop
  52780. }
  52781. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  52782. for (var i = 0; i < vendorNames.length; i++) {
  52783. var name = vendorNames[i] + capName;
  52784. if (name in emptyStyle) {
  52785. return name
  52786. }
  52787. }
  52788. });
  52789. function updateStyle (oldVnode, vnode) {
  52790. var data = vnode.data;
  52791. var oldData = oldVnode.data;
  52792. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  52793. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  52794. ) {
  52795. return
  52796. }
  52797. var cur, name;
  52798. var el = vnode.elm;
  52799. var oldStaticStyle = oldData.staticStyle;
  52800. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  52801. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  52802. var oldStyle = oldStaticStyle || oldStyleBinding;
  52803. var style = normalizeStyleBinding(vnode.data.style) || {};
  52804. // store normalized style under a different key for next diff
  52805. // make sure to clone it if it's reactive, since the user likely wants
  52806. // to mutate it.
  52807. vnode.data.normalizedStyle = isDef(style.__ob__)
  52808. ? extend({}, style)
  52809. : style;
  52810. var newStyle = getStyle(vnode, true);
  52811. for (name in oldStyle) {
  52812. if (isUndef(newStyle[name])) {
  52813. setProp(el, name, '');
  52814. }
  52815. }
  52816. for (name in newStyle) {
  52817. cur = newStyle[name];
  52818. if (cur !== oldStyle[name]) {
  52819. // ie9 setting to null has no effect, must use empty string
  52820. setProp(el, name, cur == null ? '' : cur);
  52821. }
  52822. }
  52823. }
  52824. var style = {
  52825. create: updateStyle,
  52826. update: updateStyle
  52827. };
  52828. /* */
  52829. var whitespaceRE = /\s+/;
  52830. /**
  52831. * Add class with compatibility for SVG since classList is not supported on
  52832. * SVG elements in IE
  52833. */
  52834. function addClass (el, cls) {
  52835. /* istanbul ignore if */
  52836. if (!cls || !(cls = cls.trim())) {
  52837. return
  52838. }
  52839. /* istanbul ignore else */
  52840. if (el.classList) {
  52841. if (cls.indexOf(' ') > -1) {
  52842. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  52843. } else {
  52844. el.classList.add(cls);
  52845. }
  52846. } else {
  52847. var cur = " " + (el.getAttribute('class') || '') + " ";
  52848. if (cur.indexOf(' ' + cls + ' ') < 0) {
  52849. el.setAttribute('class', (cur + cls).trim());
  52850. }
  52851. }
  52852. }
  52853. /**
  52854. * Remove class with compatibility for SVG since classList is not supported on
  52855. * SVG elements in IE
  52856. */
  52857. function removeClass (el, cls) {
  52858. /* istanbul ignore if */
  52859. if (!cls || !(cls = cls.trim())) {
  52860. return
  52861. }
  52862. /* istanbul ignore else */
  52863. if (el.classList) {
  52864. if (cls.indexOf(' ') > -1) {
  52865. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  52866. } else {
  52867. el.classList.remove(cls);
  52868. }
  52869. if (!el.classList.length) {
  52870. el.removeAttribute('class');
  52871. }
  52872. } else {
  52873. var cur = " " + (el.getAttribute('class') || '') + " ";
  52874. var tar = ' ' + cls + ' ';
  52875. while (cur.indexOf(tar) >= 0) {
  52876. cur = cur.replace(tar, ' ');
  52877. }
  52878. cur = cur.trim();
  52879. if (cur) {
  52880. el.setAttribute('class', cur);
  52881. } else {
  52882. el.removeAttribute('class');
  52883. }
  52884. }
  52885. }
  52886. /* */
  52887. function resolveTransition (def$$1) {
  52888. if (!def$$1) {
  52889. return
  52890. }
  52891. /* istanbul ignore else */
  52892. if (typeof def$$1 === 'object') {
  52893. var res = {};
  52894. if (def$$1.css !== false) {
  52895. extend(res, autoCssTransition(def$$1.name || 'v'));
  52896. }
  52897. extend(res, def$$1);
  52898. return res
  52899. } else if (typeof def$$1 === 'string') {
  52900. return autoCssTransition(def$$1)
  52901. }
  52902. }
  52903. var autoCssTransition = cached(function (name) {
  52904. return {
  52905. enterClass: (name + "-enter"),
  52906. enterToClass: (name + "-enter-to"),
  52907. enterActiveClass: (name + "-enter-active"),
  52908. leaveClass: (name + "-leave"),
  52909. leaveToClass: (name + "-leave-to"),
  52910. leaveActiveClass: (name + "-leave-active")
  52911. }
  52912. });
  52913. var hasTransition = inBrowser && !isIE9;
  52914. var TRANSITION = 'transition';
  52915. var ANIMATION = 'animation';
  52916. // Transition property/event sniffing
  52917. var transitionProp = 'transition';
  52918. var transitionEndEvent = 'transitionend';
  52919. var animationProp = 'animation';
  52920. var animationEndEvent = 'animationend';
  52921. if (hasTransition) {
  52922. /* istanbul ignore if */
  52923. if (window.ontransitionend === undefined &&
  52924. window.onwebkittransitionend !== undefined
  52925. ) {
  52926. transitionProp = 'WebkitTransition';
  52927. transitionEndEvent = 'webkitTransitionEnd';
  52928. }
  52929. if (window.onanimationend === undefined &&
  52930. window.onwebkitanimationend !== undefined
  52931. ) {
  52932. animationProp = 'WebkitAnimation';
  52933. animationEndEvent = 'webkitAnimationEnd';
  52934. }
  52935. }
  52936. // binding to window is necessary to make hot reload work in IE in strict mode
  52937. var raf = inBrowser
  52938. ? window.requestAnimationFrame
  52939. ? window.requestAnimationFrame.bind(window)
  52940. : setTimeout
  52941. : /* istanbul ignore next */ function (fn) { return fn(); };
  52942. function nextFrame (fn) {
  52943. raf(function () {
  52944. raf(fn);
  52945. });
  52946. }
  52947. function addTransitionClass (el, cls) {
  52948. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  52949. if (transitionClasses.indexOf(cls) < 0) {
  52950. transitionClasses.push(cls);
  52951. addClass(el, cls);
  52952. }
  52953. }
  52954. function removeTransitionClass (el, cls) {
  52955. if (el._transitionClasses) {
  52956. remove(el._transitionClasses, cls);
  52957. }
  52958. removeClass(el, cls);
  52959. }
  52960. function whenTransitionEnds (
  52961. el,
  52962. expectedType,
  52963. cb
  52964. ) {
  52965. var ref = getTransitionInfo(el, expectedType);
  52966. var type = ref.type;
  52967. var timeout = ref.timeout;
  52968. var propCount = ref.propCount;
  52969. if (!type) { return cb() }
  52970. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  52971. var ended = 0;
  52972. var end = function () {
  52973. el.removeEventListener(event, onEnd);
  52974. cb();
  52975. };
  52976. var onEnd = function (e) {
  52977. if (e.target === el) {
  52978. if (++ended >= propCount) {
  52979. end();
  52980. }
  52981. }
  52982. };
  52983. setTimeout(function () {
  52984. if (ended < propCount) {
  52985. end();
  52986. }
  52987. }, timeout + 1);
  52988. el.addEventListener(event, onEnd);
  52989. }
  52990. var transformRE = /\b(transform|all)(,|$)/;
  52991. function getTransitionInfo (el, expectedType) {
  52992. var styles = window.getComputedStyle(el);
  52993. // JSDOM may return undefined for transition properties
  52994. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  52995. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  52996. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  52997. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  52998. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  52999. var animationTimeout = getTimeout(animationDelays, animationDurations);
  53000. var type;
  53001. var timeout = 0;
  53002. var propCount = 0;
  53003. /* istanbul ignore if */
  53004. if (expectedType === TRANSITION) {
  53005. if (transitionTimeout > 0) {
  53006. type = TRANSITION;
  53007. timeout = transitionTimeout;
  53008. propCount = transitionDurations.length;
  53009. }
  53010. } else if (expectedType === ANIMATION) {
  53011. if (animationTimeout > 0) {
  53012. type = ANIMATION;
  53013. timeout = animationTimeout;
  53014. propCount = animationDurations.length;
  53015. }
  53016. } else {
  53017. timeout = Math.max(transitionTimeout, animationTimeout);
  53018. type = timeout > 0
  53019. ? transitionTimeout > animationTimeout
  53020. ? TRANSITION
  53021. : ANIMATION
  53022. : null;
  53023. propCount = type
  53024. ? type === TRANSITION
  53025. ? transitionDurations.length
  53026. : animationDurations.length
  53027. : 0;
  53028. }
  53029. var hasTransform =
  53030. type === TRANSITION &&
  53031. transformRE.test(styles[transitionProp + 'Property']);
  53032. return {
  53033. type: type,
  53034. timeout: timeout,
  53035. propCount: propCount,
  53036. hasTransform: hasTransform
  53037. }
  53038. }
  53039. function getTimeout (delays, durations) {
  53040. /* istanbul ignore next */
  53041. while (delays.length < durations.length) {
  53042. delays = delays.concat(delays);
  53043. }
  53044. return Math.max.apply(null, durations.map(function (d, i) {
  53045. return toMs(d) + toMs(delays[i])
  53046. }))
  53047. }
  53048. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  53049. // in a locale-dependent way, using a comma instead of a dot.
  53050. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  53051. // as a floor function) causing unexpected behaviors
  53052. function toMs (s) {
  53053. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  53054. }
  53055. /* */
  53056. function enter (vnode, toggleDisplay) {
  53057. var el = vnode.elm;
  53058. // call leave callback now
  53059. if (isDef(el._leaveCb)) {
  53060. el._leaveCb.cancelled = true;
  53061. el._leaveCb();
  53062. }
  53063. var data = resolveTransition(vnode.data.transition);
  53064. if (isUndef(data)) {
  53065. return
  53066. }
  53067. /* istanbul ignore if */
  53068. if (isDef(el._enterCb) || el.nodeType !== 1) {
  53069. return
  53070. }
  53071. var css = data.css;
  53072. var type = data.type;
  53073. var enterClass = data.enterClass;
  53074. var enterToClass = data.enterToClass;
  53075. var enterActiveClass = data.enterActiveClass;
  53076. var appearClass = data.appearClass;
  53077. var appearToClass = data.appearToClass;
  53078. var appearActiveClass = data.appearActiveClass;
  53079. var beforeEnter = data.beforeEnter;
  53080. var enter = data.enter;
  53081. var afterEnter = data.afterEnter;
  53082. var enterCancelled = data.enterCancelled;
  53083. var beforeAppear = data.beforeAppear;
  53084. var appear = data.appear;
  53085. var afterAppear = data.afterAppear;
  53086. var appearCancelled = data.appearCancelled;
  53087. var duration = data.duration;
  53088. // activeInstance will always be the <transition> component managing this
  53089. // transition. One edge case to check is when the <transition> is placed
  53090. // as the root node of a child component. In that case we need to check
  53091. // <transition>'s parent for appear check.
  53092. var context = activeInstance;
  53093. var transitionNode = activeInstance.$vnode;
  53094. while (transitionNode && transitionNode.parent) {
  53095. context = transitionNode.context;
  53096. transitionNode = transitionNode.parent;
  53097. }
  53098. var isAppear = !context._isMounted || !vnode.isRootInsert;
  53099. if (isAppear && !appear && appear !== '') {
  53100. return
  53101. }
  53102. var startClass = isAppear && appearClass
  53103. ? appearClass
  53104. : enterClass;
  53105. var activeClass = isAppear && appearActiveClass
  53106. ? appearActiveClass
  53107. : enterActiveClass;
  53108. var toClass = isAppear && appearToClass
  53109. ? appearToClass
  53110. : enterToClass;
  53111. var beforeEnterHook = isAppear
  53112. ? (beforeAppear || beforeEnter)
  53113. : beforeEnter;
  53114. var enterHook = isAppear
  53115. ? (typeof appear === 'function' ? appear : enter)
  53116. : enter;
  53117. var afterEnterHook = isAppear
  53118. ? (afterAppear || afterEnter)
  53119. : afterEnter;
  53120. var enterCancelledHook = isAppear
  53121. ? (appearCancelled || enterCancelled)
  53122. : enterCancelled;
  53123. var explicitEnterDuration = toNumber(
  53124. isObject(duration)
  53125. ? duration.enter
  53126. : duration
  53127. );
  53128. if (explicitEnterDuration != null) {
  53129. checkDuration(explicitEnterDuration, 'enter', vnode);
  53130. }
  53131. var expectsCSS = css !== false && !isIE9;
  53132. var userWantsControl = getHookArgumentsLength(enterHook);
  53133. var cb = el._enterCb = once(function () {
  53134. if (expectsCSS) {
  53135. removeTransitionClass(el, toClass);
  53136. removeTransitionClass(el, activeClass);
  53137. }
  53138. if (cb.cancelled) {
  53139. if (expectsCSS) {
  53140. removeTransitionClass(el, startClass);
  53141. }
  53142. enterCancelledHook && enterCancelledHook(el);
  53143. } else {
  53144. afterEnterHook && afterEnterHook(el);
  53145. }
  53146. el._enterCb = null;
  53147. });
  53148. if (!vnode.data.show) {
  53149. // remove pending leave element on enter by injecting an insert hook
  53150. mergeVNodeHook(vnode, 'insert', function () {
  53151. var parent = el.parentNode;
  53152. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  53153. if (pendingNode &&
  53154. pendingNode.tag === vnode.tag &&
  53155. pendingNode.elm._leaveCb
  53156. ) {
  53157. pendingNode.elm._leaveCb();
  53158. }
  53159. enterHook && enterHook(el, cb);
  53160. });
  53161. }
  53162. // start enter transition
  53163. beforeEnterHook && beforeEnterHook(el);
  53164. if (expectsCSS) {
  53165. addTransitionClass(el, startClass);
  53166. addTransitionClass(el, activeClass);
  53167. nextFrame(function () {
  53168. removeTransitionClass(el, startClass);
  53169. if (!cb.cancelled) {
  53170. addTransitionClass(el, toClass);
  53171. if (!userWantsControl) {
  53172. if (isValidDuration(explicitEnterDuration)) {
  53173. setTimeout(cb, explicitEnterDuration);
  53174. } else {
  53175. whenTransitionEnds(el, type, cb);
  53176. }
  53177. }
  53178. }
  53179. });
  53180. }
  53181. if (vnode.data.show) {
  53182. toggleDisplay && toggleDisplay();
  53183. enterHook && enterHook(el, cb);
  53184. }
  53185. if (!expectsCSS && !userWantsControl) {
  53186. cb();
  53187. }
  53188. }
  53189. function leave (vnode, rm) {
  53190. var el = vnode.elm;
  53191. // call enter callback now
  53192. if (isDef(el._enterCb)) {
  53193. el._enterCb.cancelled = true;
  53194. el._enterCb();
  53195. }
  53196. var data = resolveTransition(vnode.data.transition);
  53197. if (isUndef(data) || el.nodeType !== 1) {
  53198. return rm()
  53199. }
  53200. /* istanbul ignore if */
  53201. if (isDef(el._leaveCb)) {
  53202. return
  53203. }
  53204. var css = data.css;
  53205. var type = data.type;
  53206. var leaveClass = data.leaveClass;
  53207. var leaveToClass = data.leaveToClass;
  53208. var leaveActiveClass = data.leaveActiveClass;
  53209. var beforeLeave = data.beforeLeave;
  53210. var leave = data.leave;
  53211. var afterLeave = data.afterLeave;
  53212. var leaveCancelled = data.leaveCancelled;
  53213. var delayLeave = data.delayLeave;
  53214. var duration = data.duration;
  53215. var expectsCSS = css !== false && !isIE9;
  53216. var userWantsControl = getHookArgumentsLength(leave);
  53217. var explicitLeaveDuration = toNumber(
  53218. isObject(duration)
  53219. ? duration.leave
  53220. : duration
  53221. );
  53222. if (isDef(explicitLeaveDuration)) {
  53223. checkDuration(explicitLeaveDuration, 'leave', vnode);
  53224. }
  53225. var cb = el._leaveCb = once(function () {
  53226. if (el.parentNode && el.parentNode._pending) {
  53227. el.parentNode._pending[vnode.key] = null;
  53228. }
  53229. if (expectsCSS) {
  53230. removeTransitionClass(el, leaveToClass);
  53231. removeTransitionClass(el, leaveActiveClass);
  53232. }
  53233. if (cb.cancelled) {
  53234. if (expectsCSS) {
  53235. removeTransitionClass(el, leaveClass);
  53236. }
  53237. leaveCancelled && leaveCancelled(el);
  53238. } else {
  53239. rm();
  53240. afterLeave && afterLeave(el);
  53241. }
  53242. el._leaveCb = null;
  53243. });
  53244. if (delayLeave) {
  53245. delayLeave(performLeave);
  53246. } else {
  53247. performLeave();
  53248. }
  53249. function performLeave () {
  53250. // the delayed leave may have already been cancelled
  53251. if (cb.cancelled) {
  53252. return
  53253. }
  53254. // record leaving element
  53255. if (!vnode.data.show && el.parentNode) {
  53256. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  53257. }
  53258. beforeLeave && beforeLeave(el);
  53259. if (expectsCSS) {
  53260. addTransitionClass(el, leaveClass);
  53261. addTransitionClass(el, leaveActiveClass);
  53262. nextFrame(function () {
  53263. removeTransitionClass(el, leaveClass);
  53264. if (!cb.cancelled) {
  53265. addTransitionClass(el, leaveToClass);
  53266. if (!userWantsControl) {
  53267. if (isValidDuration(explicitLeaveDuration)) {
  53268. setTimeout(cb, explicitLeaveDuration);
  53269. } else {
  53270. whenTransitionEnds(el, type, cb);
  53271. }
  53272. }
  53273. }
  53274. });
  53275. }
  53276. leave && leave(el, cb);
  53277. if (!expectsCSS && !userWantsControl) {
  53278. cb();
  53279. }
  53280. }
  53281. }
  53282. // only used in dev mode
  53283. function checkDuration (val, name, vnode) {
  53284. if (typeof val !== 'number') {
  53285. warn(
  53286. "<transition> explicit " + name + " duration is not a valid number - " +
  53287. "got " + (JSON.stringify(val)) + ".",
  53288. vnode.context
  53289. );
  53290. } else if (isNaN(val)) {
  53291. warn(
  53292. "<transition> explicit " + name + " duration is NaN - " +
  53293. 'the duration expression might be incorrect.',
  53294. vnode.context
  53295. );
  53296. }
  53297. }
  53298. function isValidDuration (val) {
  53299. return typeof val === 'number' && !isNaN(val)
  53300. }
  53301. /**
  53302. * Normalize a transition hook's argument length. The hook may be:
  53303. * - a merged hook (invoker) with the original in .fns
  53304. * - a wrapped component method (check ._length)
  53305. * - a plain function (.length)
  53306. */
  53307. function getHookArgumentsLength (fn) {
  53308. if (isUndef(fn)) {
  53309. return false
  53310. }
  53311. var invokerFns = fn.fns;
  53312. if (isDef(invokerFns)) {
  53313. // invoker
  53314. return getHookArgumentsLength(
  53315. Array.isArray(invokerFns)
  53316. ? invokerFns[0]
  53317. : invokerFns
  53318. )
  53319. } else {
  53320. return (fn._length || fn.length) > 1
  53321. }
  53322. }
  53323. function _enter (_, vnode) {
  53324. if (vnode.data.show !== true) {
  53325. enter(vnode);
  53326. }
  53327. }
  53328. var transition = inBrowser ? {
  53329. create: _enter,
  53330. activate: _enter,
  53331. remove: function remove$$1 (vnode, rm) {
  53332. /* istanbul ignore else */
  53333. if (vnode.data.show !== true) {
  53334. leave(vnode, rm);
  53335. } else {
  53336. rm();
  53337. }
  53338. }
  53339. } : {};
  53340. var platformModules = [
  53341. attrs,
  53342. klass,
  53343. events,
  53344. domProps,
  53345. style,
  53346. transition
  53347. ];
  53348. /* */
  53349. // the directive module should be applied last, after all
  53350. // built-in modules have been applied.
  53351. var modules = platformModules.concat(baseModules);
  53352. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  53353. /**
  53354. * Not type checking this file because flow doesn't like attaching
  53355. * properties to Elements.
  53356. */
  53357. /* istanbul ignore if */
  53358. if (isIE9) {
  53359. // http://www.matts411.com/post/internet-explorer-9-oninput/
  53360. document.addEventListener('selectionchange', function () {
  53361. var el = document.activeElement;
  53362. if (el && el.vmodel) {
  53363. trigger(el, 'input');
  53364. }
  53365. });
  53366. }
  53367. var directive = {
  53368. inserted: function inserted (el, binding, vnode, oldVnode) {
  53369. if (vnode.tag === 'select') {
  53370. // #6903
  53371. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  53372. mergeVNodeHook(vnode, 'postpatch', function () {
  53373. directive.componentUpdated(el, binding, vnode);
  53374. });
  53375. } else {
  53376. setSelected(el, binding, vnode.context);
  53377. }
  53378. el._vOptions = [].map.call(el.options, getValue);
  53379. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  53380. el._vModifiers = binding.modifiers;
  53381. if (!binding.modifiers.lazy) {
  53382. el.addEventListener('compositionstart', onCompositionStart);
  53383. el.addEventListener('compositionend', onCompositionEnd);
  53384. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  53385. // switching focus before confirming composition choice
  53386. // this also fixes the issue where some browsers e.g. iOS Chrome
  53387. // fires "change" instead of "input" on autocomplete.
  53388. el.addEventListener('change', onCompositionEnd);
  53389. /* istanbul ignore if */
  53390. if (isIE9) {
  53391. el.vmodel = true;
  53392. }
  53393. }
  53394. }
  53395. },
  53396. componentUpdated: function componentUpdated (el, binding, vnode) {
  53397. if (vnode.tag === 'select') {
  53398. setSelected(el, binding, vnode.context);
  53399. // in case the options rendered by v-for have changed,
  53400. // it's possible that the value is out-of-sync with the rendered options.
  53401. // detect such cases and filter out values that no longer has a matching
  53402. // option in the DOM.
  53403. var prevOptions = el._vOptions;
  53404. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  53405. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  53406. // trigger change event if
  53407. // no matching option found for at least one value
  53408. var needReset = el.multiple
  53409. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  53410. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  53411. if (needReset) {
  53412. trigger(el, 'change');
  53413. }
  53414. }
  53415. }
  53416. }
  53417. };
  53418. function setSelected (el, binding, vm) {
  53419. actuallySetSelected(el, binding, vm);
  53420. /* istanbul ignore if */
  53421. if (isIE || isEdge) {
  53422. setTimeout(function () {
  53423. actuallySetSelected(el, binding, vm);
  53424. }, 0);
  53425. }
  53426. }
  53427. function actuallySetSelected (el, binding, vm) {
  53428. var value = binding.value;
  53429. var isMultiple = el.multiple;
  53430. if (isMultiple && !Array.isArray(value)) {
  53431. warn(
  53432. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  53433. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  53434. vm
  53435. );
  53436. return
  53437. }
  53438. var selected, option;
  53439. for (var i = 0, l = el.options.length; i < l; i++) {
  53440. option = el.options[i];
  53441. if (isMultiple) {
  53442. selected = looseIndexOf(value, getValue(option)) > -1;
  53443. if (option.selected !== selected) {
  53444. option.selected = selected;
  53445. }
  53446. } else {
  53447. if (looseEqual(getValue(option), value)) {
  53448. if (el.selectedIndex !== i) {
  53449. el.selectedIndex = i;
  53450. }
  53451. return
  53452. }
  53453. }
  53454. }
  53455. if (!isMultiple) {
  53456. el.selectedIndex = -1;
  53457. }
  53458. }
  53459. function hasNoMatchingOption (value, options) {
  53460. return options.every(function (o) { return !looseEqual(o, value); })
  53461. }
  53462. function getValue (option) {
  53463. return '_value' in option
  53464. ? option._value
  53465. : option.value
  53466. }
  53467. function onCompositionStart (e) {
  53468. e.target.composing = true;
  53469. }
  53470. function onCompositionEnd (e) {
  53471. // prevent triggering an input event for no reason
  53472. if (!e.target.composing) { return }
  53473. e.target.composing = false;
  53474. trigger(e.target, 'input');
  53475. }
  53476. function trigger (el, type) {
  53477. var e = document.createEvent('HTMLEvents');
  53478. e.initEvent(type, true, true);
  53479. el.dispatchEvent(e);
  53480. }
  53481. /* */
  53482. // recursively search for possible transition defined inside the component root
  53483. function locateNode (vnode) {
  53484. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  53485. ? locateNode(vnode.componentInstance._vnode)
  53486. : vnode
  53487. }
  53488. var show = {
  53489. bind: function bind (el, ref, vnode) {
  53490. var value = ref.value;
  53491. vnode = locateNode(vnode);
  53492. var transition$$1 = vnode.data && vnode.data.transition;
  53493. var originalDisplay = el.__vOriginalDisplay =
  53494. el.style.display === 'none' ? '' : el.style.display;
  53495. if (value && transition$$1) {
  53496. vnode.data.show = true;
  53497. enter(vnode, function () {
  53498. el.style.display = originalDisplay;
  53499. });
  53500. } else {
  53501. el.style.display = value ? originalDisplay : 'none';
  53502. }
  53503. },
  53504. update: function update (el, ref, vnode) {
  53505. var value = ref.value;
  53506. var oldValue = ref.oldValue;
  53507. /* istanbul ignore if */
  53508. if (!value === !oldValue) { return }
  53509. vnode = locateNode(vnode);
  53510. var transition$$1 = vnode.data && vnode.data.transition;
  53511. if (transition$$1) {
  53512. vnode.data.show = true;
  53513. if (value) {
  53514. enter(vnode, function () {
  53515. el.style.display = el.__vOriginalDisplay;
  53516. });
  53517. } else {
  53518. leave(vnode, function () {
  53519. el.style.display = 'none';
  53520. });
  53521. }
  53522. } else {
  53523. el.style.display = value ? el.__vOriginalDisplay : 'none';
  53524. }
  53525. },
  53526. unbind: function unbind (
  53527. el,
  53528. binding,
  53529. vnode,
  53530. oldVnode,
  53531. isDestroy
  53532. ) {
  53533. if (!isDestroy) {
  53534. el.style.display = el.__vOriginalDisplay;
  53535. }
  53536. }
  53537. };
  53538. var platformDirectives = {
  53539. model: directive,
  53540. show: show
  53541. };
  53542. /* */
  53543. var transitionProps = {
  53544. name: String,
  53545. appear: Boolean,
  53546. css: Boolean,
  53547. mode: String,
  53548. type: String,
  53549. enterClass: String,
  53550. leaveClass: String,
  53551. enterToClass: String,
  53552. leaveToClass: String,
  53553. enterActiveClass: String,
  53554. leaveActiveClass: String,
  53555. appearClass: String,
  53556. appearActiveClass: String,
  53557. appearToClass: String,
  53558. duration: [Number, String, Object]
  53559. };
  53560. // in case the child is also an abstract component, e.g. <keep-alive>
  53561. // we want to recursively retrieve the real component to be rendered
  53562. function getRealChild (vnode) {
  53563. var compOptions = vnode && vnode.componentOptions;
  53564. if (compOptions && compOptions.Ctor.options.abstract) {
  53565. return getRealChild(getFirstComponentChild(compOptions.children))
  53566. } else {
  53567. return vnode
  53568. }
  53569. }
  53570. function extractTransitionData (comp) {
  53571. var data = {};
  53572. var options = comp.$options;
  53573. // props
  53574. for (var key in options.propsData) {
  53575. data[key] = comp[key];
  53576. }
  53577. // events.
  53578. // extract listeners and pass them directly to the transition methods
  53579. var listeners = options._parentListeners;
  53580. for (var key$1 in listeners) {
  53581. data[camelize(key$1)] = listeners[key$1];
  53582. }
  53583. return data
  53584. }
  53585. function placeholder (h, rawChild) {
  53586. if (/\d-keep-alive$/.test(rawChild.tag)) {
  53587. return h('keep-alive', {
  53588. props: rawChild.componentOptions.propsData
  53589. })
  53590. }
  53591. }
  53592. function hasParentTransition (vnode) {
  53593. while ((vnode = vnode.parent)) {
  53594. if (vnode.data.transition) {
  53595. return true
  53596. }
  53597. }
  53598. }
  53599. function isSameChild (child, oldChild) {
  53600. return oldChild.key === child.key && oldChild.tag === child.tag
  53601. }
  53602. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  53603. var isVShowDirective = function (d) { return d.name === 'show'; };
  53604. var Transition = {
  53605. name: 'transition',
  53606. props: transitionProps,
  53607. abstract: true,
  53608. render: function render (h) {
  53609. var this$1 = this;
  53610. var children = this.$slots.default;
  53611. if (!children) {
  53612. return
  53613. }
  53614. // filter out text nodes (possible whitespaces)
  53615. children = children.filter(isNotTextNode);
  53616. /* istanbul ignore if */
  53617. if (!children.length) {
  53618. return
  53619. }
  53620. // warn multiple elements
  53621. if (children.length > 1) {
  53622. warn(
  53623. '<transition> can only be used on a single element. Use ' +
  53624. '<transition-group> for lists.',
  53625. this.$parent
  53626. );
  53627. }
  53628. var mode = this.mode;
  53629. // warn invalid mode
  53630. if (mode && mode !== 'in-out' && mode !== 'out-in'
  53631. ) {
  53632. warn(
  53633. 'invalid <transition> mode: ' + mode,
  53634. this.$parent
  53635. );
  53636. }
  53637. var rawChild = children[0];
  53638. // if this is a component root node and the component's
  53639. // parent container node also has transition, skip.
  53640. if (hasParentTransition(this.$vnode)) {
  53641. return rawChild
  53642. }
  53643. // apply transition data to child
  53644. // use getRealChild() to ignore abstract components e.g. keep-alive
  53645. var child = getRealChild(rawChild);
  53646. /* istanbul ignore if */
  53647. if (!child) {
  53648. return rawChild
  53649. }
  53650. if (this._leaving) {
  53651. return placeholder(h, rawChild)
  53652. }
  53653. // ensure a key that is unique to the vnode type and to this transition
  53654. // component instance. This key will be used to remove pending leaving nodes
  53655. // during entering.
  53656. var id = "__transition-" + (this._uid) + "-";
  53657. child.key = child.key == null
  53658. ? child.isComment
  53659. ? id + 'comment'
  53660. : id + child.tag
  53661. : isPrimitive(child.key)
  53662. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  53663. : child.key;
  53664. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  53665. var oldRawChild = this._vnode;
  53666. var oldChild = getRealChild(oldRawChild);
  53667. // mark v-show
  53668. // so that the transition module can hand over the control to the directive
  53669. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  53670. child.data.show = true;
  53671. }
  53672. if (
  53673. oldChild &&
  53674. oldChild.data &&
  53675. !isSameChild(child, oldChild) &&
  53676. !isAsyncPlaceholder(oldChild) &&
  53677. // #6687 component root is a comment node
  53678. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  53679. ) {
  53680. // replace old child transition data with fresh one
  53681. // important for dynamic transitions!
  53682. var oldData = oldChild.data.transition = extend({}, data);
  53683. // handle transition mode
  53684. if (mode === 'out-in') {
  53685. // return placeholder node and queue update when leave finishes
  53686. this._leaving = true;
  53687. mergeVNodeHook(oldData, 'afterLeave', function () {
  53688. this$1._leaving = false;
  53689. this$1.$forceUpdate();
  53690. });
  53691. return placeholder(h, rawChild)
  53692. } else if (mode === 'in-out') {
  53693. if (isAsyncPlaceholder(child)) {
  53694. return oldRawChild
  53695. }
  53696. var delayedLeave;
  53697. var performLeave = function () { delayedLeave(); };
  53698. mergeVNodeHook(data, 'afterEnter', performLeave);
  53699. mergeVNodeHook(data, 'enterCancelled', performLeave);
  53700. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  53701. }
  53702. }
  53703. return rawChild
  53704. }
  53705. };
  53706. /* */
  53707. var props = extend({
  53708. tag: String,
  53709. moveClass: String
  53710. }, transitionProps);
  53711. delete props.mode;
  53712. var TransitionGroup = {
  53713. props: props,
  53714. beforeMount: function beforeMount () {
  53715. var this$1 = this;
  53716. var update = this._update;
  53717. this._update = function (vnode, hydrating) {
  53718. var restoreActiveInstance = setActiveInstance(this$1);
  53719. // force removing pass
  53720. this$1.__patch__(
  53721. this$1._vnode,
  53722. this$1.kept,
  53723. false, // hydrating
  53724. true // removeOnly (!important, avoids unnecessary moves)
  53725. );
  53726. this$1._vnode = this$1.kept;
  53727. restoreActiveInstance();
  53728. update.call(this$1, vnode, hydrating);
  53729. };
  53730. },
  53731. render: function render (h) {
  53732. var tag = this.tag || this.$vnode.data.tag || 'span';
  53733. var map = Object.create(null);
  53734. var prevChildren = this.prevChildren = this.children;
  53735. var rawChildren = this.$slots.default || [];
  53736. var children = this.children = [];
  53737. var transitionData = extractTransitionData(this);
  53738. for (var i = 0; i < rawChildren.length; i++) {
  53739. var c = rawChildren[i];
  53740. if (c.tag) {
  53741. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  53742. children.push(c);
  53743. map[c.key] = c
  53744. ;(c.data || (c.data = {})).transition = transitionData;
  53745. } else {
  53746. var opts = c.componentOptions;
  53747. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  53748. warn(("<transition-group> children must be keyed: <" + name + ">"));
  53749. }
  53750. }
  53751. }
  53752. if (prevChildren) {
  53753. var kept = [];
  53754. var removed = [];
  53755. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  53756. var c$1 = prevChildren[i$1];
  53757. c$1.data.transition = transitionData;
  53758. c$1.data.pos = c$1.elm.getBoundingClientRect();
  53759. if (map[c$1.key]) {
  53760. kept.push(c$1);
  53761. } else {
  53762. removed.push(c$1);
  53763. }
  53764. }
  53765. this.kept = h(tag, null, kept);
  53766. this.removed = removed;
  53767. }
  53768. return h(tag, null, children)
  53769. },
  53770. updated: function updated () {
  53771. var children = this.prevChildren;
  53772. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  53773. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  53774. return
  53775. }
  53776. // we divide the work into three loops to avoid mixing DOM reads and writes
  53777. // in each iteration - which helps prevent layout thrashing.
  53778. children.forEach(callPendingCbs);
  53779. children.forEach(recordPosition);
  53780. children.forEach(applyTranslation);
  53781. // force reflow to put everything in position
  53782. // assign to this to avoid being removed in tree-shaking
  53783. // $flow-disable-line
  53784. this._reflow = document.body.offsetHeight;
  53785. children.forEach(function (c) {
  53786. if (c.data.moved) {
  53787. var el = c.elm;
  53788. var s = el.style;
  53789. addTransitionClass(el, moveClass);
  53790. s.transform = s.WebkitTransform = s.transitionDuration = '';
  53791. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  53792. if (e && e.target !== el) {
  53793. return
  53794. }
  53795. if (!e || /transform$/.test(e.propertyName)) {
  53796. el.removeEventListener(transitionEndEvent, cb);
  53797. el._moveCb = null;
  53798. removeTransitionClass(el, moveClass);
  53799. }
  53800. });
  53801. }
  53802. });
  53803. },
  53804. methods: {
  53805. hasMove: function hasMove (el, moveClass) {
  53806. /* istanbul ignore if */
  53807. if (!hasTransition) {
  53808. return false
  53809. }
  53810. /* istanbul ignore if */
  53811. if (this._hasMove) {
  53812. return this._hasMove
  53813. }
  53814. // Detect whether an element with the move class applied has
  53815. // CSS transitions. Since the element may be inside an entering
  53816. // transition at this very moment, we make a clone of it and remove
  53817. // all other transition classes applied to ensure only the move class
  53818. // is applied.
  53819. var clone = el.cloneNode();
  53820. if (el._transitionClasses) {
  53821. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  53822. }
  53823. addClass(clone, moveClass);
  53824. clone.style.display = 'none';
  53825. this.$el.appendChild(clone);
  53826. var info = getTransitionInfo(clone);
  53827. this.$el.removeChild(clone);
  53828. return (this._hasMove = info.hasTransform)
  53829. }
  53830. }
  53831. };
  53832. function callPendingCbs (c) {
  53833. /* istanbul ignore if */
  53834. if (c.elm._moveCb) {
  53835. c.elm._moveCb();
  53836. }
  53837. /* istanbul ignore if */
  53838. if (c.elm._enterCb) {
  53839. c.elm._enterCb();
  53840. }
  53841. }
  53842. function recordPosition (c) {
  53843. c.data.newPos = c.elm.getBoundingClientRect();
  53844. }
  53845. function applyTranslation (c) {
  53846. var oldPos = c.data.pos;
  53847. var newPos = c.data.newPos;
  53848. var dx = oldPos.left - newPos.left;
  53849. var dy = oldPos.top - newPos.top;
  53850. if (dx || dy) {
  53851. c.data.moved = true;
  53852. var s = c.elm.style;
  53853. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  53854. s.transitionDuration = '0s';
  53855. }
  53856. }
  53857. var platformComponents = {
  53858. Transition: Transition,
  53859. TransitionGroup: TransitionGroup
  53860. };
  53861. /* */
  53862. // install platform specific utils
  53863. Vue.config.mustUseProp = mustUseProp;
  53864. Vue.config.isReservedTag = isReservedTag;
  53865. Vue.config.isReservedAttr = isReservedAttr;
  53866. Vue.config.getTagNamespace = getTagNamespace;
  53867. Vue.config.isUnknownElement = isUnknownElement;
  53868. // install platform runtime directives & components
  53869. extend(Vue.options.directives, platformDirectives);
  53870. extend(Vue.options.components, platformComponents);
  53871. // install platform patch function
  53872. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  53873. // public mount method
  53874. Vue.prototype.$mount = function (
  53875. el,
  53876. hydrating
  53877. ) {
  53878. el = el && inBrowser ? query(el) : undefined;
  53879. return mountComponent(this, el, hydrating)
  53880. };
  53881. // devtools global hook
  53882. /* istanbul ignore next */
  53883. if (inBrowser) {
  53884. setTimeout(function () {
  53885. if (config.devtools) {
  53886. if (devtools) {
  53887. devtools.emit('init', Vue);
  53888. } else {
  53889. console[console.info ? 'info' : 'log'](
  53890. 'Download the Vue Devtools extension for a better development experience:\n' +
  53891. 'https://github.com/vuejs/vue-devtools'
  53892. );
  53893. }
  53894. }
  53895. if (config.productionTip !== false &&
  53896. typeof console !== 'undefined'
  53897. ) {
  53898. console[console.info ? 'info' : 'log'](
  53899. "You are running Vue in development mode.\n" +
  53900. "Make sure to turn on production mode when deploying for production.\n" +
  53901. "See more tips at https://vuejs.org/guide/deployment.html"
  53902. );
  53903. }
  53904. }, 0);
  53905. }
  53906. /* */
  53907. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  53908. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  53909. var buildRegex = cached(function (delimiters) {
  53910. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  53911. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  53912. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  53913. });
  53914. function parseText (
  53915. text,
  53916. delimiters
  53917. ) {
  53918. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  53919. if (!tagRE.test(text)) {
  53920. return
  53921. }
  53922. var tokens = [];
  53923. var rawTokens = [];
  53924. var lastIndex = tagRE.lastIndex = 0;
  53925. var match, index, tokenValue;
  53926. while ((match = tagRE.exec(text))) {
  53927. index = match.index;
  53928. // push text token
  53929. if (index > lastIndex) {
  53930. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  53931. tokens.push(JSON.stringify(tokenValue));
  53932. }
  53933. // tag token
  53934. var exp = parseFilters(match[1].trim());
  53935. tokens.push(("_s(" + exp + ")"));
  53936. rawTokens.push({ '@binding': exp });
  53937. lastIndex = index + match[0].length;
  53938. }
  53939. if (lastIndex < text.length) {
  53940. rawTokens.push(tokenValue = text.slice(lastIndex));
  53941. tokens.push(JSON.stringify(tokenValue));
  53942. }
  53943. return {
  53944. expression: tokens.join('+'),
  53945. tokens: rawTokens
  53946. }
  53947. }
  53948. /* */
  53949. function transformNode (el, options) {
  53950. var warn = options.warn || baseWarn;
  53951. var staticClass = getAndRemoveAttr(el, 'class');
  53952. if (staticClass) {
  53953. var res = parseText(staticClass, options.delimiters);
  53954. if (res) {
  53955. warn(
  53956. "class=\"" + staticClass + "\": " +
  53957. 'Interpolation inside attributes has been removed. ' +
  53958. 'Use v-bind or the colon shorthand instead. For example, ' +
  53959. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  53960. el.rawAttrsMap['class']
  53961. );
  53962. }
  53963. }
  53964. if (staticClass) {
  53965. el.staticClass = JSON.stringify(staticClass);
  53966. }
  53967. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  53968. if (classBinding) {
  53969. el.classBinding = classBinding;
  53970. }
  53971. }
  53972. function genData (el) {
  53973. var data = '';
  53974. if (el.staticClass) {
  53975. data += "staticClass:" + (el.staticClass) + ",";
  53976. }
  53977. if (el.classBinding) {
  53978. data += "class:" + (el.classBinding) + ",";
  53979. }
  53980. return data
  53981. }
  53982. var klass$1 = {
  53983. staticKeys: ['staticClass'],
  53984. transformNode: transformNode,
  53985. genData: genData
  53986. };
  53987. /* */
  53988. function transformNode$1 (el, options) {
  53989. var warn = options.warn || baseWarn;
  53990. var staticStyle = getAndRemoveAttr(el, 'style');
  53991. if (staticStyle) {
  53992. /* istanbul ignore if */
  53993. {
  53994. var res = parseText(staticStyle, options.delimiters);
  53995. if (res) {
  53996. warn(
  53997. "style=\"" + staticStyle + "\": " +
  53998. 'Interpolation inside attributes has been removed. ' +
  53999. 'Use v-bind or the colon shorthand instead. For example, ' +
  54000. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  54001. el.rawAttrsMap['style']
  54002. );
  54003. }
  54004. }
  54005. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  54006. }
  54007. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  54008. if (styleBinding) {
  54009. el.styleBinding = styleBinding;
  54010. }
  54011. }
  54012. function genData$1 (el) {
  54013. var data = '';
  54014. if (el.staticStyle) {
  54015. data += "staticStyle:" + (el.staticStyle) + ",";
  54016. }
  54017. if (el.styleBinding) {
  54018. data += "style:(" + (el.styleBinding) + "),";
  54019. }
  54020. return data
  54021. }
  54022. var style$1 = {
  54023. staticKeys: ['staticStyle'],
  54024. transformNode: transformNode$1,
  54025. genData: genData$1
  54026. };
  54027. /* */
  54028. var decoder;
  54029. var he = {
  54030. decode: function decode (html) {
  54031. decoder = decoder || document.createElement('div');
  54032. decoder.innerHTML = html;
  54033. return decoder.textContent
  54034. }
  54035. };
  54036. /* */
  54037. var isUnaryTag = makeMap(
  54038. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  54039. 'link,meta,param,source,track,wbr'
  54040. );
  54041. // Elements that you can, intentionally, leave open
  54042. // (and which close themselves)
  54043. var canBeLeftOpenTag = makeMap(
  54044. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  54045. );
  54046. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  54047. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  54048. var isNonPhrasingTag = makeMap(
  54049. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  54050. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  54051. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  54052. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  54053. 'title,tr,track'
  54054. );
  54055. /**
  54056. * Not type-checking this file because it's mostly vendor code.
  54057. */
  54058. // Regular Expressions for parsing tags and attributes
  54059. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  54060. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  54061. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  54062. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  54063. var startTagOpen = new RegExp(("^<" + qnameCapture));
  54064. var startTagClose = /^\s*(\/?)>/;
  54065. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  54066. var doctype = /^<!DOCTYPE [^>]+>/i;
  54067. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  54068. var comment = /^<!\--/;
  54069. var conditionalComment = /^<!\[/;
  54070. // Special Elements (can contain anything)
  54071. var isPlainTextElement = makeMap('script,style,textarea', true);
  54072. var reCache = {};
  54073. var decodingMap = {
  54074. '&lt;': '<',
  54075. '&gt;': '>',
  54076. '&quot;': '"',
  54077. '&amp;': '&',
  54078. '&#10;': '\n',
  54079. '&#9;': '\t',
  54080. '&#39;': "'"
  54081. };
  54082. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  54083. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  54084. // #5992
  54085. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  54086. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  54087. function decodeAttr (value, shouldDecodeNewlines) {
  54088. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  54089. return value.replace(re, function (match) { return decodingMap[match]; })
  54090. }
  54091. function parseHTML (html, options) {
  54092. var stack = [];
  54093. var expectHTML = options.expectHTML;
  54094. var isUnaryTag$$1 = options.isUnaryTag || no;
  54095. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  54096. var index = 0;
  54097. var last, lastTag;
  54098. while (html) {
  54099. last = html;
  54100. // Make sure we're not in a plaintext content element like script/style
  54101. if (!lastTag || !isPlainTextElement(lastTag)) {
  54102. var textEnd = html.indexOf('<');
  54103. if (textEnd === 0) {
  54104. // Comment:
  54105. if (comment.test(html)) {
  54106. var commentEnd = html.indexOf('-->');
  54107. if (commentEnd >= 0) {
  54108. if (options.shouldKeepComment) {
  54109. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  54110. }
  54111. advance(commentEnd + 3);
  54112. continue
  54113. }
  54114. }
  54115. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  54116. if (conditionalComment.test(html)) {
  54117. var conditionalEnd = html.indexOf(']>');
  54118. if (conditionalEnd >= 0) {
  54119. advance(conditionalEnd + 2);
  54120. continue
  54121. }
  54122. }
  54123. // Doctype:
  54124. var doctypeMatch = html.match(doctype);
  54125. if (doctypeMatch) {
  54126. advance(doctypeMatch[0].length);
  54127. continue
  54128. }
  54129. // End tag:
  54130. var endTagMatch = html.match(endTag);
  54131. if (endTagMatch) {
  54132. var curIndex = index;
  54133. advance(endTagMatch[0].length);
  54134. parseEndTag(endTagMatch[1], curIndex, index);
  54135. continue
  54136. }
  54137. // Start tag:
  54138. var startTagMatch = parseStartTag();
  54139. if (startTagMatch) {
  54140. handleStartTag(startTagMatch);
  54141. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  54142. advance(1);
  54143. }
  54144. continue
  54145. }
  54146. }
  54147. var text = (void 0), rest = (void 0), next = (void 0);
  54148. if (textEnd >= 0) {
  54149. rest = html.slice(textEnd);
  54150. while (
  54151. !endTag.test(rest) &&
  54152. !startTagOpen.test(rest) &&
  54153. !comment.test(rest) &&
  54154. !conditionalComment.test(rest)
  54155. ) {
  54156. // < in plain text, be forgiving and treat it as text
  54157. next = rest.indexOf('<', 1);
  54158. if (next < 0) { break }
  54159. textEnd += next;
  54160. rest = html.slice(textEnd);
  54161. }
  54162. text = html.substring(0, textEnd);
  54163. }
  54164. if (textEnd < 0) {
  54165. text = html;
  54166. }
  54167. if (text) {
  54168. advance(text.length);
  54169. }
  54170. if (options.chars && text) {
  54171. options.chars(text, index - text.length, index);
  54172. }
  54173. } else {
  54174. var endTagLength = 0;
  54175. var stackedTag = lastTag.toLowerCase();
  54176. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  54177. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  54178. endTagLength = endTag.length;
  54179. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  54180. text = text
  54181. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  54182. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  54183. }
  54184. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  54185. text = text.slice(1);
  54186. }
  54187. if (options.chars) {
  54188. options.chars(text);
  54189. }
  54190. return ''
  54191. });
  54192. index += html.length - rest$1.length;
  54193. html = rest$1;
  54194. parseEndTag(stackedTag, index - endTagLength, index);
  54195. }
  54196. if (html === last) {
  54197. options.chars && options.chars(html);
  54198. if (!stack.length && options.warn) {
  54199. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  54200. }
  54201. break
  54202. }
  54203. }
  54204. // Clean up any remaining tags
  54205. parseEndTag();
  54206. function advance (n) {
  54207. index += n;
  54208. html = html.substring(n);
  54209. }
  54210. function parseStartTag () {
  54211. var start = html.match(startTagOpen);
  54212. if (start) {
  54213. var match = {
  54214. tagName: start[1],
  54215. attrs: [],
  54216. start: index
  54217. };
  54218. advance(start[0].length);
  54219. var end, attr;
  54220. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  54221. attr.start = index;
  54222. advance(attr[0].length);
  54223. attr.end = index;
  54224. match.attrs.push(attr);
  54225. }
  54226. if (end) {
  54227. match.unarySlash = end[1];
  54228. advance(end[0].length);
  54229. match.end = index;
  54230. return match
  54231. }
  54232. }
  54233. }
  54234. function handleStartTag (match) {
  54235. var tagName = match.tagName;
  54236. var unarySlash = match.unarySlash;
  54237. if (expectHTML) {
  54238. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  54239. parseEndTag(lastTag);
  54240. }
  54241. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  54242. parseEndTag(tagName);
  54243. }
  54244. }
  54245. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  54246. var l = match.attrs.length;
  54247. var attrs = new Array(l);
  54248. for (var i = 0; i < l; i++) {
  54249. var args = match.attrs[i];
  54250. var value = args[3] || args[4] || args[5] || '';
  54251. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  54252. ? options.shouldDecodeNewlinesForHref
  54253. : options.shouldDecodeNewlines;
  54254. attrs[i] = {
  54255. name: args[1],
  54256. value: decodeAttr(value, shouldDecodeNewlines)
  54257. };
  54258. if (options.outputSourceRange) {
  54259. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  54260. attrs[i].end = args.end;
  54261. }
  54262. }
  54263. if (!unary) {
  54264. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  54265. lastTag = tagName;
  54266. }
  54267. if (options.start) {
  54268. options.start(tagName, attrs, unary, match.start, match.end);
  54269. }
  54270. }
  54271. function parseEndTag (tagName, start, end) {
  54272. var pos, lowerCasedTagName;
  54273. if (start == null) { start = index; }
  54274. if (end == null) { end = index; }
  54275. // Find the closest opened tag of the same type
  54276. if (tagName) {
  54277. lowerCasedTagName = tagName.toLowerCase();
  54278. for (pos = stack.length - 1; pos >= 0; pos--) {
  54279. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  54280. break
  54281. }
  54282. }
  54283. } else {
  54284. // If no tag name is provided, clean shop
  54285. pos = 0;
  54286. }
  54287. if (pos >= 0) {
  54288. // Close all the open elements, up the stack
  54289. for (var i = stack.length - 1; i >= pos; i--) {
  54290. if (i > pos || !tagName &&
  54291. options.warn
  54292. ) {
  54293. options.warn(
  54294. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  54295. { start: stack[i].start, end: stack[i].end }
  54296. );
  54297. }
  54298. if (options.end) {
  54299. options.end(stack[i].tag, start, end);
  54300. }
  54301. }
  54302. // Remove the open elements from the stack
  54303. stack.length = pos;
  54304. lastTag = pos && stack[pos - 1].tag;
  54305. } else if (lowerCasedTagName === 'br') {
  54306. if (options.start) {
  54307. options.start(tagName, [], true, start, end);
  54308. }
  54309. } else if (lowerCasedTagName === 'p') {
  54310. if (options.start) {
  54311. options.start(tagName, [], false, start, end);
  54312. }
  54313. if (options.end) {
  54314. options.end(tagName, start, end);
  54315. }
  54316. }
  54317. }
  54318. }
  54319. /* */
  54320. var onRE = /^@|^v-on:/;
  54321. var dirRE = /^v-|^@|^:|^#/;
  54322. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  54323. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  54324. var stripParensRE = /^\(|\)$/g;
  54325. var dynamicArgRE = /^\[.*\]$/;
  54326. var argRE = /:(.*)$/;
  54327. var bindRE = /^:|^\.|^v-bind:/;
  54328. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  54329. var slotRE = /^v-slot(:|$)|^#/;
  54330. var lineBreakRE = /[\r\n]/;
  54331. var whitespaceRE$1 = /\s+/g;
  54332. var invalidAttributeRE = /[\s"'<>\/=]/;
  54333. var decodeHTMLCached = cached(he.decode);
  54334. var emptySlotScopeToken = "_empty_";
  54335. // configurable state
  54336. var warn$2;
  54337. var delimiters;
  54338. var transforms;
  54339. var preTransforms;
  54340. var postTransforms;
  54341. var platformIsPreTag;
  54342. var platformMustUseProp;
  54343. var platformGetTagNamespace;
  54344. var maybeComponent;
  54345. function createASTElement (
  54346. tag,
  54347. attrs,
  54348. parent
  54349. ) {
  54350. return {
  54351. type: 1,
  54352. tag: tag,
  54353. attrsList: attrs,
  54354. attrsMap: makeAttrsMap(attrs),
  54355. rawAttrsMap: {},
  54356. parent: parent,
  54357. children: []
  54358. }
  54359. }
  54360. /**
  54361. * Convert HTML string to AST.
  54362. */
  54363. function parse (
  54364. template,
  54365. options
  54366. ) {
  54367. warn$2 = options.warn || baseWarn;
  54368. platformIsPreTag = options.isPreTag || no;
  54369. platformMustUseProp = options.mustUseProp || no;
  54370. platformGetTagNamespace = options.getTagNamespace || no;
  54371. var isReservedTag = options.isReservedTag || no;
  54372. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  54373. transforms = pluckModuleFunction(options.modules, 'transformNode');
  54374. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  54375. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  54376. delimiters = options.delimiters;
  54377. var stack = [];
  54378. var preserveWhitespace = options.preserveWhitespace !== false;
  54379. var whitespaceOption = options.whitespace;
  54380. var root;
  54381. var currentParent;
  54382. var inVPre = false;
  54383. var inPre = false;
  54384. var warned = false;
  54385. function warnOnce (msg, range) {
  54386. if (!warned) {
  54387. warned = true;
  54388. warn$2(msg, range);
  54389. }
  54390. }
  54391. function closeElement (element) {
  54392. trimEndingWhitespace(element);
  54393. if (!inVPre && !element.processed) {
  54394. element = processElement(element, options);
  54395. }
  54396. // tree management
  54397. if (!stack.length && element !== root) {
  54398. // allow root elements with v-if, v-else-if and v-else
  54399. if (root.if && (element.elseif || element.else)) {
  54400. {
  54401. checkRootConstraints(element);
  54402. }
  54403. addIfCondition(root, {
  54404. exp: element.elseif,
  54405. block: element
  54406. });
  54407. } else {
  54408. warnOnce(
  54409. "Component template should contain exactly one root element. " +
  54410. "If you are using v-if on multiple elements, " +
  54411. "use v-else-if to chain them instead.",
  54412. { start: element.start }
  54413. );
  54414. }
  54415. }
  54416. if (currentParent && !element.forbidden) {
  54417. if (element.elseif || element.else) {
  54418. processIfConditions(element, currentParent);
  54419. } else {
  54420. if (element.slotScope) {
  54421. // scoped slot
  54422. // keep it in the children list so that v-else(-if) conditions can
  54423. // find it as the prev node.
  54424. var name = element.slotTarget || '"default"'
  54425. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  54426. }
  54427. currentParent.children.push(element);
  54428. element.parent = currentParent;
  54429. }
  54430. }
  54431. // final children cleanup
  54432. // filter out scoped slots
  54433. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  54434. // remove trailing whitespace node again
  54435. trimEndingWhitespace(element);
  54436. // check pre state
  54437. if (element.pre) {
  54438. inVPre = false;
  54439. }
  54440. if (platformIsPreTag(element.tag)) {
  54441. inPre = false;
  54442. }
  54443. // apply post-transforms
  54444. for (var i = 0; i < postTransforms.length; i++) {
  54445. postTransforms[i](element, options);
  54446. }
  54447. }
  54448. function trimEndingWhitespace (el) {
  54449. // remove trailing whitespace node
  54450. if (!inPre) {
  54451. var lastNode;
  54452. while (
  54453. (lastNode = el.children[el.children.length - 1]) &&
  54454. lastNode.type === 3 &&
  54455. lastNode.text === ' '
  54456. ) {
  54457. el.children.pop();
  54458. }
  54459. }
  54460. }
  54461. function checkRootConstraints (el) {
  54462. if (el.tag === 'slot' || el.tag === 'template') {
  54463. warnOnce(
  54464. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  54465. 'contain multiple nodes.',
  54466. { start: el.start }
  54467. );
  54468. }
  54469. if (el.attrsMap.hasOwnProperty('v-for')) {
  54470. warnOnce(
  54471. 'Cannot use v-for on stateful component root element because ' +
  54472. 'it renders multiple elements.',
  54473. el.rawAttrsMap['v-for']
  54474. );
  54475. }
  54476. }
  54477. parseHTML(template, {
  54478. warn: warn$2,
  54479. expectHTML: options.expectHTML,
  54480. isUnaryTag: options.isUnaryTag,
  54481. canBeLeftOpenTag: options.canBeLeftOpenTag,
  54482. shouldDecodeNewlines: options.shouldDecodeNewlines,
  54483. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  54484. shouldKeepComment: options.comments,
  54485. outputSourceRange: options.outputSourceRange,
  54486. start: function start (tag, attrs, unary, start$1, end) {
  54487. // check namespace.
  54488. // inherit parent ns if there is one
  54489. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  54490. // handle IE svg bug
  54491. /* istanbul ignore if */
  54492. if (isIE && ns === 'svg') {
  54493. attrs = guardIESVGBug(attrs);
  54494. }
  54495. var element = createASTElement(tag, attrs, currentParent);
  54496. if (ns) {
  54497. element.ns = ns;
  54498. }
  54499. {
  54500. if (options.outputSourceRange) {
  54501. element.start = start$1;
  54502. element.end = end;
  54503. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  54504. cumulated[attr.name] = attr;
  54505. return cumulated
  54506. }, {});
  54507. }
  54508. attrs.forEach(function (attr) {
  54509. if (invalidAttributeRE.test(attr.name)) {
  54510. warn$2(
  54511. "Invalid dynamic argument expression: attribute names cannot contain " +
  54512. "spaces, quotes, <, >, / or =.",
  54513. {
  54514. start: attr.start + attr.name.indexOf("["),
  54515. end: attr.start + attr.name.length
  54516. }
  54517. );
  54518. }
  54519. });
  54520. }
  54521. if (isForbiddenTag(element) && !isServerRendering()) {
  54522. element.forbidden = true;
  54523. warn$2(
  54524. 'Templates should only be responsible for mapping the state to the ' +
  54525. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  54526. "<" + tag + ">" + ', as they will not be parsed.',
  54527. { start: element.start }
  54528. );
  54529. }
  54530. // apply pre-transforms
  54531. for (var i = 0; i < preTransforms.length; i++) {
  54532. element = preTransforms[i](element, options) || element;
  54533. }
  54534. if (!inVPre) {
  54535. processPre(element);
  54536. if (element.pre) {
  54537. inVPre = true;
  54538. }
  54539. }
  54540. if (platformIsPreTag(element.tag)) {
  54541. inPre = true;
  54542. }
  54543. if (inVPre) {
  54544. processRawAttrs(element);
  54545. } else if (!element.processed) {
  54546. // structural directives
  54547. processFor(element);
  54548. processIf(element);
  54549. processOnce(element);
  54550. }
  54551. if (!root) {
  54552. root = element;
  54553. {
  54554. checkRootConstraints(root);
  54555. }
  54556. }
  54557. if (!unary) {
  54558. currentParent = element;
  54559. stack.push(element);
  54560. } else {
  54561. closeElement(element);
  54562. }
  54563. },
  54564. end: function end (tag, start, end$1) {
  54565. var element = stack[stack.length - 1];
  54566. // pop stack
  54567. stack.length -= 1;
  54568. currentParent = stack[stack.length - 1];
  54569. if (options.outputSourceRange) {
  54570. element.end = end$1;
  54571. }
  54572. closeElement(element);
  54573. },
  54574. chars: function chars (text, start, end) {
  54575. if (!currentParent) {
  54576. {
  54577. if (text === template) {
  54578. warnOnce(
  54579. 'Component template requires a root element, rather than just text.',
  54580. { start: start }
  54581. );
  54582. } else if ((text = text.trim())) {
  54583. warnOnce(
  54584. ("text \"" + text + "\" outside root element will be ignored."),
  54585. { start: start }
  54586. );
  54587. }
  54588. }
  54589. return
  54590. }
  54591. // IE textarea placeholder bug
  54592. /* istanbul ignore if */
  54593. if (isIE &&
  54594. currentParent.tag === 'textarea' &&
  54595. currentParent.attrsMap.placeholder === text
  54596. ) {
  54597. return
  54598. }
  54599. var children = currentParent.children;
  54600. if (inPre || text.trim()) {
  54601. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  54602. } else if (!children.length) {
  54603. // remove the whitespace-only node right after an opening tag
  54604. text = '';
  54605. } else if (whitespaceOption) {
  54606. if (whitespaceOption === 'condense') {
  54607. // in condense mode, remove the whitespace node if it contains
  54608. // line break, otherwise condense to a single space
  54609. text = lineBreakRE.test(text) ? '' : ' ';
  54610. } else {
  54611. text = ' ';
  54612. }
  54613. } else {
  54614. text = preserveWhitespace ? ' ' : '';
  54615. }
  54616. if (text) {
  54617. if (!inPre && whitespaceOption === 'condense') {
  54618. // condense consecutive whitespaces into single space
  54619. text = text.replace(whitespaceRE$1, ' ');
  54620. }
  54621. var res;
  54622. var child;
  54623. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  54624. child = {
  54625. type: 2,
  54626. expression: res.expression,
  54627. tokens: res.tokens,
  54628. text: text
  54629. };
  54630. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  54631. child = {
  54632. type: 3,
  54633. text: text
  54634. };
  54635. }
  54636. if (child) {
  54637. if (options.outputSourceRange) {
  54638. child.start = start;
  54639. child.end = end;
  54640. }
  54641. children.push(child);
  54642. }
  54643. }
  54644. },
  54645. comment: function comment (text, start, end) {
  54646. // adding anyting as a sibling to the root node is forbidden
  54647. // comments should still be allowed, but ignored
  54648. if (currentParent) {
  54649. var child = {
  54650. type: 3,
  54651. text: text,
  54652. isComment: true
  54653. };
  54654. if (options.outputSourceRange) {
  54655. child.start = start;
  54656. child.end = end;
  54657. }
  54658. currentParent.children.push(child);
  54659. }
  54660. }
  54661. });
  54662. return root
  54663. }
  54664. function processPre (el) {
  54665. if (getAndRemoveAttr(el, 'v-pre') != null) {
  54666. el.pre = true;
  54667. }
  54668. }
  54669. function processRawAttrs (el) {
  54670. var list = el.attrsList;
  54671. var len = list.length;
  54672. if (len) {
  54673. var attrs = el.attrs = new Array(len);
  54674. for (var i = 0; i < len; i++) {
  54675. attrs[i] = {
  54676. name: list[i].name,
  54677. value: JSON.stringify(list[i].value)
  54678. };
  54679. if (list[i].start != null) {
  54680. attrs[i].start = list[i].start;
  54681. attrs[i].end = list[i].end;
  54682. }
  54683. }
  54684. } else if (!el.pre) {
  54685. // non root node in pre blocks with no attributes
  54686. el.plain = true;
  54687. }
  54688. }
  54689. function processElement (
  54690. element,
  54691. options
  54692. ) {
  54693. processKey(element);
  54694. // determine whether this is a plain element after
  54695. // removing structural attributes
  54696. element.plain = (
  54697. !element.key &&
  54698. !element.scopedSlots &&
  54699. !element.attrsList.length
  54700. );
  54701. processRef(element);
  54702. processSlotContent(element);
  54703. processSlotOutlet(element);
  54704. processComponent(element);
  54705. for (var i = 0; i < transforms.length; i++) {
  54706. element = transforms[i](element, options) || element;
  54707. }
  54708. processAttrs(element);
  54709. return element
  54710. }
  54711. function processKey (el) {
  54712. var exp = getBindingAttr(el, 'key');
  54713. if (exp) {
  54714. {
  54715. if (el.tag === 'template') {
  54716. warn$2(
  54717. "<template> cannot be keyed. Place the key on real elements instead.",
  54718. getRawBindingAttr(el, 'key')
  54719. );
  54720. }
  54721. if (el.for) {
  54722. var iterator = el.iterator2 || el.iterator1;
  54723. var parent = el.parent;
  54724. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  54725. warn$2(
  54726. "Do not use v-for index as key on <transition-group> children, " +
  54727. "this is the same as not using keys.",
  54728. getRawBindingAttr(el, 'key'),
  54729. true /* tip */
  54730. );
  54731. }
  54732. }
  54733. }
  54734. el.key = exp;
  54735. }
  54736. }
  54737. function processRef (el) {
  54738. var ref = getBindingAttr(el, 'ref');
  54739. if (ref) {
  54740. el.ref = ref;
  54741. el.refInFor = checkInFor(el);
  54742. }
  54743. }
  54744. function processFor (el) {
  54745. var exp;
  54746. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  54747. var res = parseFor(exp);
  54748. if (res) {
  54749. extend(el, res);
  54750. } else {
  54751. warn$2(
  54752. ("Invalid v-for expression: " + exp),
  54753. el.rawAttrsMap['v-for']
  54754. );
  54755. }
  54756. }
  54757. }
  54758. function parseFor (exp) {
  54759. var inMatch = exp.match(forAliasRE);
  54760. if (!inMatch) { return }
  54761. var res = {};
  54762. res.for = inMatch[2].trim();
  54763. var alias = inMatch[1].trim().replace(stripParensRE, '');
  54764. var iteratorMatch = alias.match(forIteratorRE);
  54765. if (iteratorMatch) {
  54766. res.alias = alias.replace(forIteratorRE, '').trim();
  54767. res.iterator1 = iteratorMatch[1].trim();
  54768. if (iteratorMatch[2]) {
  54769. res.iterator2 = iteratorMatch[2].trim();
  54770. }
  54771. } else {
  54772. res.alias = alias;
  54773. }
  54774. return res
  54775. }
  54776. function processIf (el) {
  54777. var exp = getAndRemoveAttr(el, 'v-if');
  54778. if (exp) {
  54779. el.if = exp;
  54780. addIfCondition(el, {
  54781. exp: exp,
  54782. block: el
  54783. });
  54784. } else {
  54785. if (getAndRemoveAttr(el, 'v-else') != null) {
  54786. el.else = true;
  54787. }
  54788. var elseif = getAndRemoveAttr(el, 'v-else-if');
  54789. if (elseif) {
  54790. el.elseif = elseif;
  54791. }
  54792. }
  54793. }
  54794. function processIfConditions (el, parent) {
  54795. var prev = findPrevElement(parent.children);
  54796. if (prev && prev.if) {
  54797. addIfCondition(prev, {
  54798. exp: el.elseif,
  54799. block: el
  54800. });
  54801. } else {
  54802. warn$2(
  54803. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  54804. "used on element <" + (el.tag) + "> without corresponding v-if.",
  54805. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  54806. );
  54807. }
  54808. }
  54809. function findPrevElement (children) {
  54810. var i = children.length;
  54811. while (i--) {
  54812. if (children[i].type === 1) {
  54813. return children[i]
  54814. } else {
  54815. if (children[i].text !== ' ') {
  54816. warn$2(
  54817. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  54818. "will be ignored.",
  54819. children[i]
  54820. );
  54821. }
  54822. children.pop();
  54823. }
  54824. }
  54825. }
  54826. function addIfCondition (el, condition) {
  54827. if (!el.ifConditions) {
  54828. el.ifConditions = [];
  54829. }
  54830. el.ifConditions.push(condition);
  54831. }
  54832. function processOnce (el) {
  54833. var once$$1 = getAndRemoveAttr(el, 'v-once');
  54834. if (once$$1 != null) {
  54835. el.once = true;
  54836. }
  54837. }
  54838. // handle content being passed to a component as slot,
  54839. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  54840. function processSlotContent (el) {
  54841. var slotScope;
  54842. if (el.tag === 'template') {
  54843. slotScope = getAndRemoveAttr(el, 'scope');
  54844. /* istanbul ignore if */
  54845. if (slotScope) {
  54846. warn$2(
  54847. "the \"scope\" attribute for scoped slots have been deprecated and " +
  54848. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  54849. "can also be used on plain elements in addition to <template> to " +
  54850. "denote scoped slots.",
  54851. el.rawAttrsMap['scope'],
  54852. true
  54853. );
  54854. }
  54855. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  54856. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  54857. /* istanbul ignore if */
  54858. if (el.attrsMap['v-for']) {
  54859. warn$2(
  54860. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  54861. "(v-for takes higher priority). Use a wrapper <template> for the " +
  54862. "scoped slot to make it clearer.",
  54863. el.rawAttrsMap['slot-scope'],
  54864. true
  54865. );
  54866. }
  54867. el.slotScope = slotScope;
  54868. }
  54869. // slot="xxx"
  54870. var slotTarget = getBindingAttr(el, 'slot');
  54871. if (slotTarget) {
  54872. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  54873. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  54874. // preserve slot as an attribute for native shadow DOM compat
  54875. // only for non-scoped slots.
  54876. if (el.tag !== 'template' && !el.slotScope) {
  54877. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  54878. }
  54879. }
  54880. // 2.6 v-slot syntax
  54881. {
  54882. if (el.tag === 'template') {
  54883. // v-slot on <template>
  54884. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  54885. if (slotBinding) {
  54886. {
  54887. if (el.slotTarget || el.slotScope) {
  54888. warn$2(
  54889. "Unexpected mixed usage of different slot syntaxes.",
  54890. el
  54891. );
  54892. }
  54893. if (el.parent && !maybeComponent(el.parent)) {
  54894. warn$2(
  54895. "<template v-slot> can only appear at the root level inside " +
  54896. "the receiving component",
  54897. el
  54898. );
  54899. }
  54900. }
  54901. var ref = getSlotName(slotBinding);
  54902. var name = ref.name;
  54903. var dynamic = ref.dynamic;
  54904. el.slotTarget = name;
  54905. el.slotTargetDynamic = dynamic;
  54906. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  54907. }
  54908. } else {
  54909. // v-slot on component, denotes default slot
  54910. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  54911. if (slotBinding$1) {
  54912. {
  54913. if (!maybeComponent(el)) {
  54914. warn$2(
  54915. "v-slot can only be used on components or <template>.",
  54916. slotBinding$1
  54917. );
  54918. }
  54919. if (el.slotScope || el.slotTarget) {
  54920. warn$2(
  54921. "Unexpected mixed usage of different slot syntaxes.",
  54922. el
  54923. );
  54924. }
  54925. if (el.scopedSlots) {
  54926. warn$2(
  54927. "To avoid scope ambiguity, the default slot should also use " +
  54928. "<template> syntax when there are other named slots.",
  54929. slotBinding$1
  54930. );
  54931. }
  54932. }
  54933. // add the component's children to its default slot
  54934. var slots = el.scopedSlots || (el.scopedSlots = {});
  54935. var ref$1 = getSlotName(slotBinding$1);
  54936. var name$1 = ref$1.name;
  54937. var dynamic$1 = ref$1.dynamic;
  54938. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  54939. slotContainer.slotTarget = name$1;
  54940. slotContainer.slotTargetDynamic = dynamic$1;
  54941. slotContainer.children = el.children.filter(function (c) {
  54942. if (!c.slotScope) {
  54943. c.parent = slotContainer;
  54944. return true
  54945. }
  54946. });
  54947. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  54948. // remove children as they are returned from scopedSlots now
  54949. el.children = [];
  54950. // mark el non-plain so data gets generated
  54951. el.plain = false;
  54952. }
  54953. }
  54954. }
  54955. }
  54956. function getSlotName (binding) {
  54957. var name = binding.name.replace(slotRE, '');
  54958. if (!name) {
  54959. if (binding.name[0] !== '#') {
  54960. name = 'default';
  54961. } else {
  54962. warn$2(
  54963. "v-slot shorthand syntax requires a slot name.",
  54964. binding
  54965. );
  54966. }
  54967. }
  54968. return dynamicArgRE.test(name)
  54969. // dynamic [name]
  54970. ? { name: name.slice(1, -1), dynamic: true }
  54971. // static name
  54972. : { name: ("\"" + name + "\""), dynamic: false }
  54973. }
  54974. // handle <slot/> outlets
  54975. function processSlotOutlet (el) {
  54976. if (el.tag === 'slot') {
  54977. el.slotName = getBindingAttr(el, 'name');
  54978. if (el.key) {
  54979. warn$2(
  54980. "`key` does not work on <slot> because slots are abstract outlets " +
  54981. "and can possibly expand into multiple elements. " +
  54982. "Use the key on a wrapping element instead.",
  54983. getRawBindingAttr(el, 'key')
  54984. );
  54985. }
  54986. }
  54987. }
  54988. function processComponent (el) {
  54989. var binding;
  54990. if ((binding = getBindingAttr(el, 'is'))) {
  54991. el.component = binding;
  54992. }
  54993. if (getAndRemoveAttr(el, 'inline-template') != null) {
  54994. el.inlineTemplate = true;
  54995. }
  54996. }
  54997. function processAttrs (el) {
  54998. var list = el.attrsList;
  54999. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  55000. for (i = 0, l = list.length; i < l; i++) {
  55001. name = rawName = list[i].name;
  55002. value = list[i].value;
  55003. if (dirRE.test(name)) {
  55004. // mark element as dynamic
  55005. el.hasBindings = true;
  55006. // modifiers
  55007. modifiers = parseModifiers(name.replace(dirRE, ''));
  55008. // support .foo shorthand syntax for the .prop modifier
  55009. if (modifiers) {
  55010. name = name.replace(modifierRE, '');
  55011. }
  55012. if (bindRE.test(name)) { // v-bind
  55013. name = name.replace(bindRE, '');
  55014. value = parseFilters(value);
  55015. isDynamic = dynamicArgRE.test(name);
  55016. if (isDynamic) {
  55017. name = name.slice(1, -1);
  55018. }
  55019. if (
  55020. value.trim().length === 0
  55021. ) {
  55022. warn$2(
  55023. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  55024. );
  55025. }
  55026. if (modifiers) {
  55027. if (modifiers.prop && !isDynamic) {
  55028. name = camelize(name);
  55029. if (name === 'innerHtml') { name = 'innerHTML'; }
  55030. }
  55031. if (modifiers.camel && !isDynamic) {
  55032. name = camelize(name);
  55033. }
  55034. if (modifiers.sync) {
  55035. syncGen = genAssignmentCode(value, "$event");
  55036. if (!isDynamic) {
  55037. addHandler(
  55038. el,
  55039. ("update:" + (camelize(name))),
  55040. syncGen,
  55041. null,
  55042. false,
  55043. warn$2,
  55044. list[i]
  55045. );
  55046. if (hyphenate(name) !== camelize(name)) {
  55047. addHandler(
  55048. el,
  55049. ("update:" + (hyphenate(name))),
  55050. syncGen,
  55051. null,
  55052. false,
  55053. warn$2,
  55054. list[i]
  55055. );
  55056. }
  55057. } else {
  55058. // handler w/ dynamic event name
  55059. addHandler(
  55060. el,
  55061. ("\"update:\"+(" + name + ")"),
  55062. syncGen,
  55063. null,
  55064. false,
  55065. warn$2,
  55066. list[i],
  55067. true // dynamic
  55068. );
  55069. }
  55070. }
  55071. }
  55072. if ((modifiers && modifiers.prop) || (
  55073. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  55074. )) {
  55075. addProp(el, name, value, list[i], isDynamic);
  55076. } else {
  55077. addAttr(el, name, value, list[i], isDynamic);
  55078. }
  55079. } else if (onRE.test(name)) { // v-on
  55080. name = name.replace(onRE, '');
  55081. isDynamic = dynamicArgRE.test(name);
  55082. if (isDynamic) {
  55083. name = name.slice(1, -1);
  55084. }
  55085. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  55086. } else { // normal directives
  55087. name = name.replace(dirRE, '');
  55088. // parse arg
  55089. var argMatch = name.match(argRE);
  55090. var arg = argMatch && argMatch[1];
  55091. isDynamic = false;
  55092. if (arg) {
  55093. name = name.slice(0, -(arg.length + 1));
  55094. if (dynamicArgRE.test(arg)) {
  55095. arg = arg.slice(1, -1);
  55096. isDynamic = true;
  55097. }
  55098. }
  55099. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  55100. if (name === 'model') {
  55101. checkForAliasModel(el, value);
  55102. }
  55103. }
  55104. } else {
  55105. // literal attribute
  55106. {
  55107. var res = parseText(value, delimiters);
  55108. if (res) {
  55109. warn$2(
  55110. name + "=\"" + value + "\": " +
  55111. 'Interpolation inside attributes has been removed. ' +
  55112. 'Use v-bind or the colon shorthand instead. For example, ' +
  55113. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  55114. list[i]
  55115. );
  55116. }
  55117. }
  55118. addAttr(el, name, JSON.stringify(value), list[i]);
  55119. // #6887 firefox doesn't update muted state if set via attribute
  55120. // even immediately after element creation
  55121. if (!el.component &&
  55122. name === 'muted' &&
  55123. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  55124. addProp(el, name, 'true', list[i]);
  55125. }
  55126. }
  55127. }
  55128. }
  55129. function checkInFor (el) {
  55130. var parent = el;
  55131. while (parent) {
  55132. if (parent.for !== undefined) {
  55133. return true
  55134. }
  55135. parent = parent.parent;
  55136. }
  55137. return false
  55138. }
  55139. function parseModifiers (name) {
  55140. var match = name.match(modifierRE);
  55141. if (match) {
  55142. var ret = {};
  55143. match.forEach(function (m) { ret[m.slice(1)] = true; });
  55144. return ret
  55145. }
  55146. }
  55147. function makeAttrsMap (attrs) {
  55148. var map = {};
  55149. for (var i = 0, l = attrs.length; i < l; i++) {
  55150. if (
  55151. map[attrs[i].name] && !isIE && !isEdge
  55152. ) {
  55153. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  55154. }
  55155. map[attrs[i].name] = attrs[i].value;
  55156. }
  55157. return map
  55158. }
  55159. // for script (e.g. type="x/template") or style, do not decode content
  55160. function isTextTag (el) {
  55161. return el.tag === 'script' || el.tag === 'style'
  55162. }
  55163. function isForbiddenTag (el) {
  55164. return (
  55165. el.tag === 'style' ||
  55166. (el.tag === 'script' && (
  55167. !el.attrsMap.type ||
  55168. el.attrsMap.type === 'text/javascript'
  55169. ))
  55170. )
  55171. }
  55172. var ieNSBug = /^xmlns:NS\d+/;
  55173. var ieNSPrefix = /^NS\d+:/;
  55174. /* istanbul ignore next */
  55175. function guardIESVGBug (attrs) {
  55176. var res = [];
  55177. for (var i = 0; i < attrs.length; i++) {
  55178. var attr = attrs[i];
  55179. if (!ieNSBug.test(attr.name)) {
  55180. attr.name = attr.name.replace(ieNSPrefix, '');
  55181. res.push(attr);
  55182. }
  55183. }
  55184. return res
  55185. }
  55186. function checkForAliasModel (el, value) {
  55187. var _el = el;
  55188. while (_el) {
  55189. if (_el.for && _el.alias === value) {
  55190. warn$2(
  55191. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  55192. "You are binding v-model directly to a v-for iteration alias. " +
  55193. "This will not be able to modify the v-for source array because " +
  55194. "writing to the alias is like modifying a function local variable. " +
  55195. "Consider using an array of objects and use v-model on an object property instead.",
  55196. el.rawAttrsMap['v-model']
  55197. );
  55198. }
  55199. _el = _el.parent;
  55200. }
  55201. }
  55202. /* */
  55203. function preTransformNode (el, options) {
  55204. if (el.tag === 'input') {
  55205. var map = el.attrsMap;
  55206. if (!map['v-model']) {
  55207. return
  55208. }
  55209. var typeBinding;
  55210. if (map[':type'] || map['v-bind:type']) {
  55211. typeBinding = getBindingAttr(el, 'type');
  55212. }
  55213. if (!map.type && !typeBinding && map['v-bind']) {
  55214. typeBinding = "(" + (map['v-bind']) + ").type";
  55215. }
  55216. if (typeBinding) {
  55217. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  55218. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  55219. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  55220. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  55221. // 1. checkbox
  55222. var branch0 = cloneASTElement(el);
  55223. // process for on the main node
  55224. processFor(branch0);
  55225. addRawAttr(branch0, 'type', 'checkbox');
  55226. processElement(branch0, options);
  55227. branch0.processed = true; // prevent it from double-processed
  55228. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  55229. addIfCondition(branch0, {
  55230. exp: branch0.if,
  55231. block: branch0
  55232. });
  55233. // 2. add radio else-if condition
  55234. var branch1 = cloneASTElement(el);
  55235. getAndRemoveAttr(branch1, 'v-for', true);
  55236. addRawAttr(branch1, 'type', 'radio');
  55237. processElement(branch1, options);
  55238. addIfCondition(branch0, {
  55239. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  55240. block: branch1
  55241. });
  55242. // 3. other
  55243. var branch2 = cloneASTElement(el);
  55244. getAndRemoveAttr(branch2, 'v-for', true);
  55245. addRawAttr(branch2, ':type', typeBinding);
  55246. processElement(branch2, options);
  55247. addIfCondition(branch0, {
  55248. exp: ifCondition,
  55249. block: branch2
  55250. });
  55251. if (hasElse) {
  55252. branch0.else = true;
  55253. } else if (elseIfCondition) {
  55254. branch0.elseif = elseIfCondition;
  55255. }
  55256. return branch0
  55257. }
  55258. }
  55259. }
  55260. function cloneASTElement (el) {
  55261. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  55262. }
  55263. var model$1 = {
  55264. preTransformNode: preTransformNode
  55265. };
  55266. var modules$1 = [
  55267. klass$1,
  55268. style$1,
  55269. model$1
  55270. ];
  55271. /* */
  55272. function text (el, dir) {
  55273. if (dir.value) {
  55274. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  55275. }
  55276. }
  55277. /* */
  55278. function html (el, dir) {
  55279. if (dir.value) {
  55280. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  55281. }
  55282. }
  55283. var directives$1 = {
  55284. model: model,
  55285. text: text,
  55286. html: html
  55287. };
  55288. /* */
  55289. var baseOptions = {
  55290. expectHTML: true,
  55291. modules: modules$1,
  55292. directives: directives$1,
  55293. isPreTag: isPreTag,
  55294. isUnaryTag: isUnaryTag,
  55295. mustUseProp: mustUseProp,
  55296. canBeLeftOpenTag: canBeLeftOpenTag,
  55297. isReservedTag: isReservedTag,
  55298. getTagNamespace: getTagNamespace,
  55299. staticKeys: genStaticKeys(modules$1)
  55300. };
  55301. /* */
  55302. var isStaticKey;
  55303. var isPlatformReservedTag;
  55304. var genStaticKeysCached = cached(genStaticKeys$1);
  55305. /**
  55306. * Goal of the optimizer: walk the generated template AST tree
  55307. * and detect sub-trees that are purely static, i.e. parts of
  55308. * the DOM that never needs to change.
  55309. *
  55310. * Once we detect these sub-trees, we can:
  55311. *
  55312. * 1. Hoist them into constants, so that we no longer need to
  55313. * create fresh nodes for them on each re-render;
  55314. * 2. Completely skip them in the patching process.
  55315. */
  55316. function optimize (root, options) {
  55317. if (!root) { return }
  55318. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  55319. isPlatformReservedTag = options.isReservedTag || no;
  55320. // first pass: mark all non-static nodes.
  55321. markStatic$1(root);
  55322. // second pass: mark static roots.
  55323. markStaticRoots(root, false);
  55324. }
  55325. function genStaticKeys$1 (keys) {
  55326. return makeMap(
  55327. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  55328. (keys ? ',' + keys : '')
  55329. )
  55330. }
  55331. function markStatic$1 (node) {
  55332. node.static = isStatic(node);
  55333. if (node.type === 1) {
  55334. // do not make component slot content static. this avoids
  55335. // 1. components not able to mutate slot nodes
  55336. // 2. static slot content fails for hot-reloading
  55337. if (
  55338. !isPlatformReservedTag(node.tag) &&
  55339. node.tag !== 'slot' &&
  55340. node.attrsMap['inline-template'] == null
  55341. ) {
  55342. return
  55343. }
  55344. for (var i = 0, l = node.children.length; i < l; i++) {
  55345. var child = node.children[i];
  55346. markStatic$1(child);
  55347. if (!child.static) {
  55348. node.static = false;
  55349. }
  55350. }
  55351. if (node.ifConditions) {
  55352. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  55353. var block = node.ifConditions[i$1].block;
  55354. markStatic$1(block);
  55355. if (!block.static) {
  55356. node.static = false;
  55357. }
  55358. }
  55359. }
  55360. }
  55361. }
  55362. function markStaticRoots (node, isInFor) {
  55363. if (node.type === 1) {
  55364. if (node.static || node.once) {
  55365. node.staticInFor = isInFor;
  55366. }
  55367. // For a node to qualify as a static root, it should have children that
  55368. // are not just static text. Otherwise the cost of hoisting out will
  55369. // outweigh the benefits and it's better off to just always render it fresh.
  55370. if (node.static && node.children.length && !(
  55371. node.children.length === 1 &&
  55372. node.children[0].type === 3
  55373. )) {
  55374. node.staticRoot = true;
  55375. return
  55376. } else {
  55377. node.staticRoot = false;
  55378. }
  55379. if (node.children) {
  55380. for (var i = 0, l = node.children.length; i < l; i++) {
  55381. markStaticRoots(node.children[i], isInFor || !!node.for);
  55382. }
  55383. }
  55384. if (node.ifConditions) {
  55385. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  55386. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  55387. }
  55388. }
  55389. }
  55390. }
  55391. function isStatic (node) {
  55392. if (node.type === 2) { // expression
  55393. return false
  55394. }
  55395. if (node.type === 3) { // text
  55396. return true
  55397. }
  55398. return !!(node.pre || (
  55399. !node.hasBindings && // no dynamic bindings
  55400. !node.if && !node.for && // not v-if or v-for or v-else
  55401. !isBuiltInTag(node.tag) && // not a built-in
  55402. isPlatformReservedTag(node.tag) && // not a component
  55403. !isDirectChildOfTemplateFor(node) &&
  55404. Object.keys(node).every(isStaticKey)
  55405. ))
  55406. }
  55407. function isDirectChildOfTemplateFor (node) {
  55408. while (node.parent) {
  55409. node = node.parent;
  55410. if (node.tag !== 'template') {
  55411. return false
  55412. }
  55413. if (node.for) {
  55414. return true
  55415. }
  55416. }
  55417. return false
  55418. }
  55419. /* */
  55420. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  55421. var fnInvokeRE = /\([^)]*?\);*$/;
  55422. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  55423. // KeyboardEvent.keyCode aliases
  55424. var keyCodes = {
  55425. esc: 27,
  55426. tab: 9,
  55427. enter: 13,
  55428. space: 32,
  55429. up: 38,
  55430. left: 37,
  55431. right: 39,
  55432. down: 40,
  55433. 'delete': [8, 46]
  55434. };
  55435. // KeyboardEvent.key aliases
  55436. var keyNames = {
  55437. // #7880: IE11 and Edge use `Esc` for Escape key name.
  55438. esc: ['Esc', 'Escape'],
  55439. tab: 'Tab',
  55440. enter: 'Enter',
  55441. // #9112: IE11 uses `Spacebar` for Space key name.
  55442. space: [' ', 'Spacebar'],
  55443. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  55444. up: ['Up', 'ArrowUp'],
  55445. left: ['Left', 'ArrowLeft'],
  55446. right: ['Right', 'ArrowRight'],
  55447. down: ['Down', 'ArrowDown'],
  55448. // #9112: IE11 uses `Del` for Delete key name.
  55449. 'delete': ['Backspace', 'Delete', 'Del']
  55450. };
  55451. // #4868: modifiers that prevent the execution of the listener
  55452. // need to explicitly return null so that we can determine whether to remove
  55453. // the listener for .once
  55454. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  55455. var modifierCode = {
  55456. stop: '$event.stopPropagation();',
  55457. prevent: '$event.preventDefault();',
  55458. self: genGuard("$event.target !== $event.currentTarget"),
  55459. ctrl: genGuard("!$event.ctrlKey"),
  55460. shift: genGuard("!$event.shiftKey"),
  55461. alt: genGuard("!$event.altKey"),
  55462. meta: genGuard("!$event.metaKey"),
  55463. left: genGuard("'button' in $event && $event.button !== 0"),
  55464. middle: genGuard("'button' in $event && $event.button !== 1"),
  55465. right: genGuard("'button' in $event && $event.button !== 2")
  55466. };
  55467. function genHandlers (
  55468. events,
  55469. isNative
  55470. ) {
  55471. var prefix = isNative ? 'nativeOn:' : 'on:';
  55472. var staticHandlers = "";
  55473. var dynamicHandlers = "";
  55474. for (var name in events) {
  55475. var handlerCode = genHandler(events[name]);
  55476. if (events[name] && events[name].dynamic) {
  55477. dynamicHandlers += name + "," + handlerCode + ",";
  55478. } else {
  55479. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  55480. }
  55481. }
  55482. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  55483. if (dynamicHandlers) {
  55484. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  55485. } else {
  55486. return prefix + staticHandlers
  55487. }
  55488. }
  55489. function genHandler (handler) {
  55490. if (!handler) {
  55491. return 'function(){}'
  55492. }
  55493. if (Array.isArray(handler)) {
  55494. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  55495. }
  55496. var isMethodPath = simplePathRE.test(handler.value);
  55497. var isFunctionExpression = fnExpRE.test(handler.value);
  55498. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  55499. if (!handler.modifiers) {
  55500. if (isMethodPath || isFunctionExpression) {
  55501. return handler.value
  55502. }
  55503. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  55504. } else {
  55505. var code = '';
  55506. var genModifierCode = '';
  55507. var keys = [];
  55508. for (var key in handler.modifiers) {
  55509. if (modifierCode[key]) {
  55510. genModifierCode += modifierCode[key];
  55511. // left/right
  55512. if (keyCodes[key]) {
  55513. keys.push(key);
  55514. }
  55515. } else if (key === 'exact') {
  55516. var modifiers = (handler.modifiers);
  55517. genModifierCode += genGuard(
  55518. ['ctrl', 'shift', 'alt', 'meta']
  55519. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  55520. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  55521. .join('||')
  55522. );
  55523. } else {
  55524. keys.push(key);
  55525. }
  55526. }
  55527. if (keys.length) {
  55528. code += genKeyFilter(keys);
  55529. }
  55530. // Make sure modifiers like prevent and stop get executed after key filtering
  55531. if (genModifierCode) {
  55532. code += genModifierCode;
  55533. }
  55534. var handlerCode = isMethodPath
  55535. ? ("return " + (handler.value) + "($event)")
  55536. : isFunctionExpression
  55537. ? ("return (" + (handler.value) + ")($event)")
  55538. : isFunctionInvocation
  55539. ? ("return " + (handler.value))
  55540. : handler.value;
  55541. return ("function($event){" + code + handlerCode + "}")
  55542. }
  55543. }
  55544. function genKeyFilter (keys) {
  55545. return (
  55546. // make sure the key filters only apply to KeyboardEvents
  55547. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  55548. // key events that do not have keyCode property...
  55549. "if(!$event.type.indexOf('key')&&" +
  55550. (keys.map(genFilterCode).join('&&')) + ")return null;"
  55551. )
  55552. }
  55553. function genFilterCode (key) {
  55554. var keyVal = parseInt(key, 10);
  55555. if (keyVal) {
  55556. return ("$event.keyCode!==" + keyVal)
  55557. }
  55558. var keyCode = keyCodes[key];
  55559. var keyName = keyNames[key];
  55560. return (
  55561. "_k($event.keyCode," +
  55562. (JSON.stringify(key)) + "," +
  55563. (JSON.stringify(keyCode)) + "," +
  55564. "$event.key," +
  55565. "" + (JSON.stringify(keyName)) +
  55566. ")"
  55567. )
  55568. }
  55569. /* */
  55570. function on (el, dir) {
  55571. if (dir.modifiers) {
  55572. warn("v-on without argument does not support modifiers.");
  55573. }
  55574. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  55575. }
  55576. /* */
  55577. function bind$1 (el, dir) {
  55578. el.wrapData = function (code) {
  55579. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  55580. };
  55581. }
  55582. /* */
  55583. var baseDirectives = {
  55584. on: on,
  55585. bind: bind$1,
  55586. cloak: noop
  55587. };
  55588. /* */
  55589. var CodegenState = function CodegenState (options) {
  55590. this.options = options;
  55591. this.warn = options.warn || baseWarn;
  55592. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  55593. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  55594. this.directives = extend(extend({}, baseDirectives), options.directives);
  55595. var isReservedTag = options.isReservedTag || no;
  55596. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  55597. this.onceId = 0;
  55598. this.staticRenderFns = [];
  55599. this.pre = false;
  55600. };
  55601. function generate (
  55602. ast,
  55603. options
  55604. ) {
  55605. var state = new CodegenState(options);
  55606. var code = ast ? genElement(ast, state) : '_c("div")';
  55607. return {
  55608. render: ("with(this){return " + code + "}"),
  55609. staticRenderFns: state.staticRenderFns
  55610. }
  55611. }
  55612. function genElement (el, state) {
  55613. if (el.parent) {
  55614. el.pre = el.pre || el.parent.pre;
  55615. }
  55616. if (el.staticRoot && !el.staticProcessed) {
  55617. return genStatic(el, state)
  55618. } else if (el.once && !el.onceProcessed) {
  55619. return genOnce(el, state)
  55620. } else if (el.for && !el.forProcessed) {
  55621. return genFor(el, state)
  55622. } else if (el.if && !el.ifProcessed) {
  55623. return genIf(el, state)
  55624. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  55625. return genChildren(el, state) || 'void 0'
  55626. } else if (el.tag === 'slot') {
  55627. return genSlot(el, state)
  55628. } else {
  55629. // component or element
  55630. var code;
  55631. if (el.component) {
  55632. code = genComponent(el.component, el, state);
  55633. } else {
  55634. var data;
  55635. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  55636. data = genData$2(el, state);
  55637. }
  55638. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  55639. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  55640. }
  55641. // module transforms
  55642. for (var i = 0; i < state.transforms.length; i++) {
  55643. code = state.transforms[i](el, code);
  55644. }
  55645. return code
  55646. }
  55647. }
  55648. // hoist static sub-trees out
  55649. function genStatic (el, state) {
  55650. el.staticProcessed = true;
  55651. // Some elements (templates) need to behave differently inside of a v-pre
  55652. // node. All pre nodes are static roots, so we can use this as a location to
  55653. // wrap a state change and reset it upon exiting the pre node.
  55654. var originalPreState = state.pre;
  55655. if (el.pre) {
  55656. state.pre = el.pre;
  55657. }
  55658. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  55659. state.pre = originalPreState;
  55660. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  55661. }
  55662. // v-once
  55663. function genOnce (el, state) {
  55664. el.onceProcessed = true;
  55665. if (el.if && !el.ifProcessed) {
  55666. return genIf(el, state)
  55667. } else if (el.staticInFor) {
  55668. var key = '';
  55669. var parent = el.parent;
  55670. while (parent) {
  55671. if (parent.for) {
  55672. key = parent.key;
  55673. break
  55674. }
  55675. parent = parent.parent;
  55676. }
  55677. if (!key) {
  55678. state.warn(
  55679. "v-once can only be used inside v-for that is keyed. ",
  55680. el.rawAttrsMap['v-once']
  55681. );
  55682. return genElement(el, state)
  55683. }
  55684. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  55685. } else {
  55686. return genStatic(el, state)
  55687. }
  55688. }
  55689. function genIf (
  55690. el,
  55691. state,
  55692. altGen,
  55693. altEmpty
  55694. ) {
  55695. el.ifProcessed = true; // avoid recursion
  55696. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  55697. }
  55698. function genIfConditions (
  55699. conditions,
  55700. state,
  55701. altGen,
  55702. altEmpty
  55703. ) {
  55704. if (!conditions.length) {
  55705. return altEmpty || '_e()'
  55706. }
  55707. var condition = conditions.shift();
  55708. if (condition.exp) {
  55709. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  55710. } else {
  55711. return ("" + (genTernaryExp(condition.block)))
  55712. }
  55713. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  55714. function genTernaryExp (el) {
  55715. return altGen
  55716. ? altGen(el, state)
  55717. : el.once
  55718. ? genOnce(el, state)
  55719. : genElement(el, state)
  55720. }
  55721. }
  55722. function genFor (
  55723. el,
  55724. state,
  55725. altGen,
  55726. altHelper
  55727. ) {
  55728. var exp = el.for;
  55729. var alias = el.alias;
  55730. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  55731. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  55732. if (state.maybeComponent(el) &&
  55733. el.tag !== 'slot' &&
  55734. el.tag !== 'template' &&
  55735. !el.key
  55736. ) {
  55737. state.warn(
  55738. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  55739. "v-for should have explicit keys. " +
  55740. "See https://vuejs.org/guide/list.html#key for more info.",
  55741. el.rawAttrsMap['v-for'],
  55742. true /* tip */
  55743. );
  55744. }
  55745. el.forProcessed = true; // avoid recursion
  55746. return (altHelper || '_l') + "((" + exp + ")," +
  55747. "function(" + alias + iterator1 + iterator2 + "){" +
  55748. "return " + ((altGen || genElement)(el, state)) +
  55749. '})'
  55750. }
  55751. function genData$2 (el, state) {
  55752. var data = '{';
  55753. // directives first.
  55754. // directives may mutate the el's other properties before they are generated.
  55755. var dirs = genDirectives(el, state);
  55756. if (dirs) { data += dirs + ','; }
  55757. // key
  55758. if (el.key) {
  55759. data += "key:" + (el.key) + ",";
  55760. }
  55761. // ref
  55762. if (el.ref) {
  55763. data += "ref:" + (el.ref) + ",";
  55764. }
  55765. if (el.refInFor) {
  55766. data += "refInFor:true,";
  55767. }
  55768. // pre
  55769. if (el.pre) {
  55770. data += "pre:true,";
  55771. }
  55772. // record original tag name for components using "is" attribute
  55773. if (el.component) {
  55774. data += "tag:\"" + (el.tag) + "\",";
  55775. }
  55776. // module data generation functions
  55777. for (var i = 0; i < state.dataGenFns.length; i++) {
  55778. data += state.dataGenFns[i](el);
  55779. }
  55780. // attributes
  55781. if (el.attrs) {
  55782. data += "attrs:" + (genProps(el.attrs)) + ",";
  55783. }
  55784. // DOM props
  55785. if (el.props) {
  55786. data += "domProps:" + (genProps(el.props)) + ",";
  55787. }
  55788. // event handlers
  55789. if (el.events) {
  55790. data += (genHandlers(el.events, false)) + ",";
  55791. }
  55792. if (el.nativeEvents) {
  55793. data += (genHandlers(el.nativeEvents, true)) + ",";
  55794. }
  55795. // slot target
  55796. // only for non-scoped slots
  55797. if (el.slotTarget && !el.slotScope) {
  55798. data += "slot:" + (el.slotTarget) + ",";
  55799. }
  55800. // scoped slots
  55801. if (el.scopedSlots) {
  55802. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  55803. }
  55804. // component v-model
  55805. if (el.model) {
  55806. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  55807. }
  55808. // inline-template
  55809. if (el.inlineTemplate) {
  55810. var inlineTemplate = genInlineTemplate(el, state);
  55811. if (inlineTemplate) {
  55812. data += inlineTemplate + ",";
  55813. }
  55814. }
  55815. data = data.replace(/,$/, '') + '}';
  55816. // v-bind dynamic argument wrap
  55817. // v-bind with dynamic arguments must be applied using the same v-bind object
  55818. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  55819. if (el.dynamicAttrs) {
  55820. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  55821. }
  55822. // v-bind data wrap
  55823. if (el.wrapData) {
  55824. data = el.wrapData(data);
  55825. }
  55826. // v-on data wrap
  55827. if (el.wrapListeners) {
  55828. data = el.wrapListeners(data);
  55829. }
  55830. return data
  55831. }
  55832. function genDirectives (el, state) {
  55833. var dirs = el.directives;
  55834. if (!dirs) { return }
  55835. var res = 'directives:[';
  55836. var hasRuntime = false;
  55837. var i, l, dir, needRuntime;
  55838. for (i = 0, l = dirs.length; i < l; i++) {
  55839. dir = dirs[i];
  55840. needRuntime = true;
  55841. var gen = state.directives[dir.name];
  55842. if (gen) {
  55843. // compile-time directive that manipulates AST.
  55844. // returns true if it also needs a runtime counterpart.
  55845. needRuntime = !!gen(el, dir, state.warn);
  55846. }
  55847. if (needRuntime) {
  55848. hasRuntime = true;
  55849. 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))) : '') + "},";
  55850. }
  55851. }
  55852. if (hasRuntime) {
  55853. return res.slice(0, -1) + ']'
  55854. }
  55855. }
  55856. function genInlineTemplate (el, state) {
  55857. var ast = el.children[0];
  55858. if (el.children.length !== 1 || ast.type !== 1) {
  55859. state.warn(
  55860. 'Inline-template components must have exactly one child element.',
  55861. { start: el.start }
  55862. );
  55863. }
  55864. if (ast && ast.type === 1) {
  55865. var inlineRenderFns = generate(ast, state.options);
  55866. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  55867. }
  55868. }
  55869. function genScopedSlots (
  55870. el,
  55871. slots,
  55872. state
  55873. ) {
  55874. // by default scoped slots are considered "stable", this allows child
  55875. // components with only scoped slots to skip forced updates from parent.
  55876. // but in some cases we have to bail-out of this optimization
  55877. // for example if the slot contains dynamic names, has v-if or v-for on them...
  55878. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  55879. var slot = slots[key];
  55880. return (
  55881. slot.slotTargetDynamic ||
  55882. slot.if ||
  55883. slot.for ||
  55884. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  55885. )
  55886. });
  55887. // #9534: if a component with scoped slots is inside a conditional branch,
  55888. // it's possible for the same component to be reused but with different
  55889. // compiled slot content. To avoid that, we generate a unique key based on
  55890. // the generated code of all the slot contents.
  55891. var needsKey = !!el.if;
  55892. // OR when it is inside another scoped slot or v-for (the reactivity may be
  55893. // disconnected due to the intermediate scope variable)
  55894. // #9438, #9506
  55895. // TODO: this can be further optimized by properly analyzing in-scope bindings
  55896. // and skip force updating ones that do not actually use scope variables.
  55897. if (!needsForceUpdate) {
  55898. var parent = el.parent;
  55899. while (parent) {
  55900. if (
  55901. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  55902. parent.for
  55903. ) {
  55904. needsForceUpdate = true;
  55905. break
  55906. }
  55907. if (parent.if) {
  55908. needsKey = true;
  55909. }
  55910. parent = parent.parent;
  55911. }
  55912. }
  55913. var generatedSlots = Object.keys(slots)
  55914. .map(function (key) { return genScopedSlot(slots[key], state); })
  55915. .join(',');
  55916. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  55917. }
  55918. function hash(str) {
  55919. var hash = 5381;
  55920. var i = str.length;
  55921. while(i) {
  55922. hash = (hash * 33) ^ str.charCodeAt(--i);
  55923. }
  55924. return hash >>> 0
  55925. }
  55926. function containsSlotChild (el) {
  55927. if (el.type === 1) {
  55928. if (el.tag === 'slot') {
  55929. return true
  55930. }
  55931. return el.children.some(containsSlotChild)
  55932. }
  55933. return false
  55934. }
  55935. function genScopedSlot (
  55936. el,
  55937. state
  55938. ) {
  55939. var isLegacySyntax = el.attrsMap['slot-scope'];
  55940. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  55941. return genIf(el, state, genScopedSlot, "null")
  55942. }
  55943. if (el.for && !el.forProcessed) {
  55944. return genFor(el, state, genScopedSlot)
  55945. }
  55946. var slotScope = el.slotScope === emptySlotScopeToken
  55947. ? ""
  55948. : String(el.slotScope);
  55949. var fn = "function(" + slotScope + "){" +
  55950. "return " + (el.tag === 'template'
  55951. ? el.if && isLegacySyntax
  55952. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  55953. : genChildren(el, state) || 'undefined'
  55954. : genElement(el, state)) + "}";
  55955. // reverse proxy v-slot without scope on this.$slots
  55956. var reverseProxy = slotScope ? "" : ",proxy:true";
  55957. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  55958. }
  55959. function genChildren (
  55960. el,
  55961. state,
  55962. checkSkip,
  55963. altGenElement,
  55964. altGenNode
  55965. ) {
  55966. var children = el.children;
  55967. if (children.length) {
  55968. var el$1 = children[0];
  55969. // optimize single v-for
  55970. if (children.length === 1 &&
  55971. el$1.for &&
  55972. el$1.tag !== 'template' &&
  55973. el$1.tag !== 'slot'
  55974. ) {
  55975. var normalizationType = checkSkip
  55976. ? state.maybeComponent(el$1) ? ",1" : ",0"
  55977. : "";
  55978. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  55979. }
  55980. var normalizationType$1 = checkSkip
  55981. ? getNormalizationType(children, state.maybeComponent)
  55982. : 0;
  55983. var gen = altGenNode || genNode;
  55984. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  55985. }
  55986. }
  55987. // determine the normalization needed for the children array.
  55988. // 0: no normalization needed
  55989. // 1: simple normalization needed (possible 1-level deep nested array)
  55990. // 2: full normalization needed
  55991. function getNormalizationType (
  55992. children,
  55993. maybeComponent
  55994. ) {
  55995. var res = 0;
  55996. for (var i = 0; i < children.length; i++) {
  55997. var el = children[i];
  55998. if (el.type !== 1) {
  55999. continue
  56000. }
  56001. if (needsNormalization(el) ||
  56002. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  56003. res = 2;
  56004. break
  56005. }
  56006. if (maybeComponent(el) ||
  56007. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  56008. res = 1;
  56009. }
  56010. }
  56011. return res
  56012. }
  56013. function needsNormalization (el) {
  56014. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  56015. }
  56016. function genNode (node, state) {
  56017. if (node.type === 1) {
  56018. return genElement(node, state)
  56019. } else if (node.type === 3 && node.isComment) {
  56020. return genComment(node)
  56021. } else {
  56022. return genText(node)
  56023. }
  56024. }
  56025. function genText (text) {
  56026. return ("_v(" + (text.type === 2
  56027. ? text.expression // no need for () because already wrapped in _s()
  56028. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  56029. }
  56030. function genComment (comment) {
  56031. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  56032. }
  56033. function genSlot (el, state) {
  56034. var slotName = el.slotName || '"default"';
  56035. var children = genChildren(el, state);
  56036. var res = "_t(" + slotName + (children ? ("," + children) : '');
  56037. var attrs = el.attrs || el.dynamicAttrs
  56038. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  56039. // slot props are camelized
  56040. name: camelize(attr.name),
  56041. value: attr.value,
  56042. dynamic: attr.dynamic
  56043. }); }))
  56044. : null;
  56045. var bind$$1 = el.attrsMap['v-bind'];
  56046. if ((attrs || bind$$1) && !children) {
  56047. res += ",null";
  56048. }
  56049. if (attrs) {
  56050. res += "," + attrs;
  56051. }
  56052. if (bind$$1) {
  56053. res += (attrs ? '' : ',null') + "," + bind$$1;
  56054. }
  56055. return res + ')'
  56056. }
  56057. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  56058. function genComponent (
  56059. componentName,
  56060. el,
  56061. state
  56062. ) {
  56063. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  56064. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  56065. }
  56066. function genProps (props) {
  56067. var staticProps = "";
  56068. var dynamicProps = "";
  56069. for (var i = 0; i < props.length; i++) {
  56070. var prop = props[i];
  56071. var value = transformSpecialNewlines(prop.value);
  56072. if (prop.dynamic) {
  56073. dynamicProps += (prop.name) + "," + value + ",";
  56074. } else {
  56075. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  56076. }
  56077. }
  56078. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  56079. if (dynamicProps) {
  56080. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  56081. } else {
  56082. return staticProps
  56083. }
  56084. }
  56085. // #3895, #4268
  56086. function transformSpecialNewlines (text) {
  56087. return text
  56088. .replace(/\u2028/g, '\\u2028')
  56089. .replace(/\u2029/g, '\\u2029')
  56090. }
  56091. /* */
  56092. // these keywords should not appear inside expressions, but operators like
  56093. // typeof, instanceof and in are allowed
  56094. var prohibitedKeywordRE = new RegExp('\\b' + (
  56095. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  56096. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  56097. 'extends,finally,continue,debugger,function,arguments'
  56098. ).split(',').join('\\b|\\b') + '\\b');
  56099. // these unary operators should not be used as property/method names
  56100. var unaryOperatorsRE = new RegExp('\\b' + (
  56101. 'delete,typeof,void'
  56102. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  56103. // strip strings in expressions
  56104. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  56105. // detect problematic expressions in a template
  56106. function detectErrors (ast, warn) {
  56107. if (ast) {
  56108. checkNode(ast, warn);
  56109. }
  56110. }
  56111. function checkNode (node, warn) {
  56112. if (node.type === 1) {
  56113. for (var name in node.attrsMap) {
  56114. if (dirRE.test(name)) {
  56115. var value = node.attrsMap[name];
  56116. if (value) {
  56117. var range = node.rawAttrsMap[name];
  56118. if (name === 'v-for') {
  56119. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  56120. } else if (name === 'v-slot' || name[0] === '#') {
  56121. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  56122. } else if (onRE.test(name)) {
  56123. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  56124. } else {
  56125. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  56126. }
  56127. }
  56128. }
  56129. }
  56130. if (node.children) {
  56131. for (var i = 0; i < node.children.length; i++) {
  56132. checkNode(node.children[i], warn);
  56133. }
  56134. }
  56135. } else if (node.type === 2) {
  56136. checkExpression(node.expression, node.text, warn, node);
  56137. }
  56138. }
  56139. function checkEvent (exp, text, warn, range) {
  56140. var stripped = exp.replace(stripStringRE, '');
  56141. var keywordMatch = stripped.match(unaryOperatorsRE);
  56142. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  56143. warn(
  56144. "avoid using JavaScript unary operator as property name: " +
  56145. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  56146. range
  56147. );
  56148. }
  56149. checkExpression(exp, text, warn, range);
  56150. }
  56151. function checkFor (node, text, warn, range) {
  56152. checkExpression(node.for || '', text, warn, range);
  56153. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  56154. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  56155. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  56156. }
  56157. function checkIdentifier (
  56158. ident,
  56159. type,
  56160. text,
  56161. warn,
  56162. range
  56163. ) {
  56164. if (typeof ident === 'string') {
  56165. try {
  56166. new Function(("var " + ident + "=_"));
  56167. } catch (e) {
  56168. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  56169. }
  56170. }
  56171. }
  56172. function checkExpression (exp, text, warn, range) {
  56173. try {
  56174. new Function(("return " + exp));
  56175. } catch (e) {
  56176. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  56177. if (keywordMatch) {
  56178. warn(
  56179. "avoid using JavaScript keyword as property name: " +
  56180. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  56181. range
  56182. );
  56183. } else {
  56184. warn(
  56185. "invalid expression: " + (e.message) + " in\n\n" +
  56186. " " + exp + "\n\n" +
  56187. " Raw expression: " + (text.trim()) + "\n",
  56188. range
  56189. );
  56190. }
  56191. }
  56192. }
  56193. function checkFunctionParameterExpression (exp, text, warn, range) {
  56194. try {
  56195. new Function(exp, '');
  56196. } catch (e) {
  56197. warn(
  56198. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  56199. " " + exp + "\n\n" +
  56200. " Raw expression: " + (text.trim()) + "\n",
  56201. range
  56202. );
  56203. }
  56204. }
  56205. /* */
  56206. var range = 2;
  56207. function generateCodeFrame (
  56208. source,
  56209. start,
  56210. end
  56211. ) {
  56212. if ( start === void 0 ) start = 0;
  56213. if ( end === void 0 ) end = source.length;
  56214. var lines = source.split(/\r?\n/);
  56215. var count = 0;
  56216. var res = [];
  56217. for (var i = 0; i < lines.length; i++) {
  56218. count += lines[i].length + 1;
  56219. if (count >= start) {
  56220. for (var j = i - range; j <= i + range || end > count; j++) {
  56221. if (j < 0 || j >= lines.length) { continue }
  56222. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  56223. var lineLength = lines[j].length;
  56224. if (j === i) {
  56225. // push underline
  56226. var pad = start - (count - lineLength) + 1;
  56227. var length = end > count ? lineLength - pad : end - start;
  56228. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  56229. } else if (j > i) {
  56230. if (end > count) {
  56231. var length$1 = Math.min(end - count, lineLength);
  56232. res.push(" | " + repeat$1("^", length$1));
  56233. }
  56234. count += lineLength + 1;
  56235. }
  56236. }
  56237. break
  56238. }
  56239. }
  56240. return res.join('\n')
  56241. }
  56242. function repeat$1 (str, n) {
  56243. var result = '';
  56244. if (n > 0) {
  56245. while (true) { // eslint-disable-line
  56246. if (n & 1) { result += str; }
  56247. n >>>= 1;
  56248. if (n <= 0) { break }
  56249. str += str;
  56250. }
  56251. }
  56252. return result
  56253. }
  56254. /* */
  56255. function createFunction (code, errors) {
  56256. try {
  56257. return new Function(code)
  56258. } catch (err) {
  56259. errors.push({ err: err, code: code });
  56260. return noop
  56261. }
  56262. }
  56263. function createCompileToFunctionFn (compile) {
  56264. var cache = Object.create(null);
  56265. return function compileToFunctions (
  56266. template,
  56267. options,
  56268. vm
  56269. ) {
  56270. options = extend({}, options);
  56271. var warn$$1 = options.warn || warn;
  56272. delete options.warn;
  56273. /* istanbul ignore if */
  56274. {
  56275. // detect possible CSP restriction
  56276. try {
  56277. new Function('return 1');
  56278. } catch (e) {
  56279. if (e.toString().match(/unsafe-eval|CSP/)) {
  56280. warn$$1(
  56281. 'It seems you are using the standalone build of Vue.js in an ' +
  56282. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  56283. 'The template compiler cannot work in this environment. Consider ' +
  56284. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  56285. 'templates into render functions.'
  56286. );
  56287. }
  56288. }
  56289. }
  56290. // check cache
  56291. var key = options.delimiters
  56292. ? String(options.delimiters) + template
  56293. : template;
  56294. if (cache[key]) {
  56295. return cache[key]
  56296. }
  56297. // compile
  56298. var compiled = compile(template, options);
  56299. // check compilation errors/tips
  56300. {
  56301. if (compiled.errors && compiled.errors.length) {
  56302. if (options.outputSourceRange) {
  56303. compiled.errors.forEach(function (e) {
  56304. warn$$1(
  56305. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  56306. generateCodeFrame(template, e.start, e.end),
  56307. vm
  56308. );
  56309. });
  56310. } else {
  56311. warn$$1(
  56312. "Error compiling template:\n\n" + template + "\n\n" +
  56313. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  56314. vm
  56315. );
  56316. }
  56317. }
  56318. if (compiled.tips && compiled.tips.length) {
  56319. if (options.outputSourceRange) {
  56320. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  56321. } else {
  56322. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  56323. }
  56324. }
  56325. }
  56326. // turn code into functions
  56327. var res = {};
  56328. var fnGenErrors = [];
  56329. res.render = createFunction(compiled.render, fnGenErrors);
  56330. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  56331. return createFunction(code, fnGenErrors)
  56332. });
  56333. // check function generation errors.
  56334. // this should only happen if there is a bug in the compiler itself.
  56335. // mostly for codegen development use
  56336. /* istanbul ignore if */
  56337. {
  56338. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  56339. warn$$1(
  56340. "Failed to generate render function:\n\n" +
  56341. fnGenErrors.map(function (ref) {
  56342. var err = ref.err;
  56343. var code = ref.code;
  56344. return ((err.toString()) + " in\n\n" + code + "\n");
  56345. }).join('\n'),
  56346. vm
  56347. );
  56348. }
  56349. }
  56350. return (cache[key] = res)
  56351. }
  56352. }
  56353. /* */
  56354. function createCompilerCreator (baseCompile) {
  56355. return function createCompiler (baseOptions) {
  56356. function compile (
  56357. template,
  56358. options
  56359. ) {
  56360. var finalOptions = Object.create(baseOptions);
  56361. var errors = [];
  56362. var tips = [];
  56363. var warn = function (msg, range, tip) {
  56364. (tip ? tips : errors).push(msg);
  56365. };
  56366. if (options) {
  56367. if (options.outputSourceRange) {
  56368. // $flow-disable-line
  56369. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  56370. warn = function (msg, range, tip) {
  56371. var data = { msg: msg };
  56372. if (range) {
  56373. if (range.start != null) {
  56374. data.start = range.start + leadingSpaceLength;
  56375. }
  56376. if (range.end != null) {
  56377. data.end = range.end + leadingSpaceLength;
  56378. }
  56379. }
  56380. (tip ? tips : errors).push(data);
  56381. };
  56382. }
  56383. // merge custom modules
  56384. if (options.modules) {
  56385. finalOptions.modules =
  56386. (baseOptions.modules || []).concat(options.modules);
  56387. }
  56388. // merge custom directives
  56389. if (options.directives) {
  56390. finalOptions.directives = extend(
  56391. Object.create(baseOptions.directives || null),
  56392. options.directives
  56393. );
  56394. }
  56395. // copy other options
  56396. for (var key in options) {
  56397. if (key !== 'modules' && key !== 'directives') {
  56398. finalOptions[key] = options[key];
  56399. }
  56400. }
  56401. }
  56402. finalOptions.warn = warn;
  56403. var compiled = baseCompile(template.trim(), finalOptions);
  56404. {
  56405. detectErrors(compiled.ast, warn);
  56406. }
  56407. compiled.errors = errors;
  56408. compiled.tips = tips;
  56409. return compiled
  56410. }
  56411. return {
  56412. compile: compile,
  56413. compileToFunctions: createCompileToFunctionFn(compile)
  56414. }
  56415. }
  56416. }
  56417. /* */
  56418. // `createCompilerCreator` allows creating compilers that use alternative
  56419. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  56420. // Here we just export a default compiler using the default parts.
  56421. var createCompiler = createCompilerCreator(function baseCompile (
  56422. template,
  56423. options
  56424. ) {
  56425. var ast = parse(template.trim(), options);
  56426. if (options.optimize !== false) {
  56427. optimize(ast, options);
  56428. }
  56429. var code = generate(ast, options);
  56430. return {
  56431. ast: ast,
  56432. render: code.render,
  56433. staticRenderFns: code.staticRenderFns
  56434. }
  56435. });
  56436. /* */
  56437. var ref$1 = createCompiler(baseOptions);
  56438. var compile = ref$1.compile;
  56439. var compileToFunctions = ref$1.compileToFunctions;
  56440. /* */
  56441. // check whether current browser encodes a char inside attribute values
  56442. var div;
  56443. function getShouldDecode (href) {
  56444. div = div || document.createElement('div');
  56445. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  56446. return div.innerHTML.indexOf('&#10;') > 0
  56447. }
  56448. // #3663: IE encodes newlines inside attribute values while other browsers don't
  56449. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  56450. // #6828: chrome encodes content in a[href]
  56451. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  56452. /* */
  56453. var idToTemplate = cached(function (id) {
  56454. var el = query(id);
  56455. return el && el.innerHTML
  56456. });
  56457. var mount = Vue.prototype.$mount;
  56458. Vue.prototype.$mount = function (
  56459. el,
  56460. hydrating
  56461. ) {
  56462. el = el && query(el);
  56463. /* istanbul ignore if */
  56464. if (el === document.body || el === document.documentElement) {
  56465. warn(
  56466. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  56467. );
  56468. return this
  56469. }
  56470. var options = this.$options;
  56471. // resolve template/el and convert to render function
  56472. if (!options.render) {
  56473. var template = options.template;
  56474. if (template) {
  56475. if (typeof template === 'string') {
  56476. if (template.charAt(0) === '#') {
  56477. template = idToTemplate(template);
  56478. /* istanbul ignore if */
  56479. if (!template) {
  56480. warn(
  56481. ("Template element not found or is empty: " + (options.template)),
  56482. this
  56483. );
  56484. }
  56485. }
  56486. } else if (template.nodeType) {
  56487. template = template.innerHTML;
  56488. } else {
  56489. {
  56490. warn('invalid template option:' + template, this);
  56491. }
  56492. return this
  56493. }
  56494. } else if (el) {
  56495. template = getOuterHTML(el);
  56496. }
  56497. if (template) {
  56498. /* istanbul ignore if */
  56499. if (config.performance && mark) {
  56500. mark('compile');
  56501. }
  56502. var ref = compileToFunctions(template, {
  56503. outputSourceRange: "development" !== 'production',
  56504. shouldDecodeNewlines: shouldDecodeNewlines,
  56505. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  56506. delimiters: options.delimiters,
  56507. comments: options.comments
  56508. }, this);
  56509. var render = ref.render;
  56510. var staticRenderFns = ref.staticRenderFns;
  56511. options.render = render;
  56512. options.staticRenderFns = staticRenderFns;
  56513. /* istanbul ignore if */
  56514. if (config.performance && mark) {
  56515. mark('compile end');
  56516. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  56517. }
  56518. }
  56519. }
  56520. return mount.call(this, el, hydrating)
  56521. };
  56522. /**
  56523. * Get outerHTML of elements, taking care
  56524. * of SVG elements in IE as well.
  56525. */
  56526. function getOuterHTML (el) {
  56527. if (el.outerHTML) {
  56528. return el.outerHTML
  56529. } else {
  56530. var container = document.createElement('div');
  56531. container.appendChild(el.cloneNode(true));
  56532. return container.innerHTML
  56533. }
  56534. }
  56535. Vue.compile = compileToFunctions;
  56536. module.exports = Vue;
  56537. /* 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))
  56538. /***/ }),
  56539. /***/ "./node_modules/vue/dist/vue.common.js":
  56540. /*!*********************************************!*\
  56541. !*** ./node_modules/vue/dist/vue.common.js ***!
  56542. \*********************************************/
  56543. /*! no static exports found */
  56544. /***/ (function(module, exports, __webpack_require__) {
  56545. if (false) {} else {
  56546. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  56547. }
  56548. /***/ }),
  56549. /***/ "./node_modules/webpack/buildin/global.js":
  56550. /*!***********************************!*\
  56551. !*** (webpack)/buildin/global.js ***!
  56552. \***********************************/
  56553. /*! no static exports found */
  56554. /***/ (function(module, exports) {
  56555. var g;
  56556. // This works in non-strict mode
  56557. g = (function() {
  56558. return this;
  56559. })();
  56560. try {
  56561. // This works if eval is allowed (see CSP)
  56562. g = g || new Function("return this")();
  56563. } catch (e) {
  56564. // This works if the window reference is available
  56565. if (typeof window === "object") g = window;
  56566. }
  56567. // g can still be undefined, but nothing to do about it...
  56568. // We return undefined, instead of nothing here, so it's
  56569. // easier to handle this case. if(!global) { ...}
  56570. module.exports = g;
  56571. /***/ }),
  56572. /***/ "./node_modules/webpack/buildin/module.js":
  56573. /*!***********************************!*\
  56574. !*** (webpack)/buildin/module.js ***!
  56575. \***********************************/
  56576. /*! no static exports found */
  56577. /***/ (function(module, exports) {
  56578. module.exports = function(module) {
  56579. if (!module.webpackPolyfill) {
  56580. module.deprecate = function() {};
  56581. module.paths = [];
  56582. // module.parent = undefined by default
  56583. if (!module.children) module.children = [];
  56584. Object.defineProperty(module, "loaded", {
  56585. enumerable: true,
  56586. get: function() {
  56587. return module.l;
  56588. }
  56589. });
  56590. Object.defineProperty(module, "id", {
  56591. enumerable: true,
  56592. get: function() {
  56593. return module.i;
  56594. }
  56595. });
  56596. module.webpackPolyfill = 1;
  56597. }
  56598. return module;
  56599. };
  56600. /***/ }),
  56601. /***/ "./resources/js/app.js":
  56602. /*!*****************************!*\
  56603. !*** ./resources/js/app.js ***!
  56604. \*****************************/
  56605. /*! no exports provided */
  56606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56607. "use strict";
  56608. __webpack_require__.r(__webpack_exports__);
  56609. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  56610. /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__);
  56611. /* harmony import */ var vue_router__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vue-router */ "./node_modules/vue-router/dist/vue-router.esm.js");
  56612. /* harmony import */ var _views_App__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./views/App */ "./resources/js/views/App.vue");
  56613. /* harmony import */ var _views_Welcome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./views/Welcome */ "./resources/js/views/Welcome.vue");
  56614. /**
  56615. * First we will load all of this project's JavaScript dependencies which
  56616. * includes Vue and other libraries. It is a great starting point when
  56617. * building robust, powerful web applications using Vue and Laravel.
  56618. */
  56619. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  56620. window.Clipboard = __webpack_require__(/*! clipboard */ "./node_modules/clipboard/dist/clipboard.js");
  56621. __webpack_require__(/*! ./notify.min.js */ "./resources/js/notify.min.js");
  56622. vue__WEBPACK_IMPORTED_MODULE_0___default.a.use(vue_router__WEBPACK_IMPORTED_MODULE_1__["default"]);
  56623. var router = new vue_router__WEBPACK_IMPORTED_MODULE_1__["default"]({
  56624. mode: 'history',
  56625. routes: [{
  56626. path: '/',
  56627. name: 'home',
  56628. component: _views_Welcome__WEBPACK_IMPORTED_MODULE_3__["default"]
  56629. }]
  56630. });
  56631. var app = new vue__WEBPACK_IMPORTED_MODULE_0___default.a({
  56632. el: '#app',
  56633. components: {
  56634. App: _views_App__WEBPACK_IMPORTED_MODULE_2__["default"]
  56635. },
  56636. router: router
  56637. });
  56638. $(function () {
  56639. $('[data-toggle="tooltip"]').tooltip();
  56640. });
  56641. var clipboard = new Clipboard('.btn-clip');
  56642. clipboard.on('success', function (e) {
  56643. $('#' + e.trigger.getAttribute('id')).notify('Copied to Clipboard', {
  56644. position: "right",
  56645. className: 'success'
  56646. });
  56647. e.clearSelection();
  56648. });
  56649. /***/ }),
  56650. /***/ "./resources/js/bootstrap.js":
  56651. /*!***********************************!*\
  56652. !*** ./resources/js/bootstrap.js ***!
  56653. \***********************************/
  56654. /*! no exports provided */
  56655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56656. "use strict";
  56657. __webpack_require__.r(__webpack_exports__);
  56658. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  56659. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  56660. /**
  56661. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  56662. * for JavaScript based Bootstrap features such as modals and tabs. This
  56663. * code may be modified to fit the specific needs of your application.
  56664. */
  56665. try {
  56666. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  56667. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  56668. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  56669. } catch (e) {}
  56670. /**
  56671. * We'll load the axios HTTP library which allows us to easily issue requests
  56672. * to our Laravel back-end. This library automatically handles sending the
  56673. * CSRF token as a header based on the value of the "XSRF" token cookie.
  56674. */
  56675. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  56676. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  56677. /**
  56678. * Echo exposes an expressive API for subscribing to channels and listening
  56679. * for events that are broadcast by Laravel. Echo and event broadcasting
  56680. * allows your team to easily build robust real-time web applications.
  56681. */
  56682. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  56683. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  56684. broadcaster: 'pusher',
  56685. key: "upccrt",
  56686. authEndpoint: '/broadcasting/auth',
  56687. wsHost: window.location.hostname,
  56688. wsPort: 6001,
  56689. disableStats: true
  56690. });
  56691. /***/ }),
  56692. /***/ "./resources/js/notify.min.js":
  56693. /*!************************************!*\
  56694. !*** ./resources/js/notify.min.js ***!
  56695. \************************************/
  56696. /*! no static exports found */
  56697. /***/ (function(module, exports, __webpack_require__) {
  56698. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  56699. (function (e) {
  56700. true ? !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (e),
  56701. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  56702. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  56703. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : undefined;
  56704. })(function (e) {
  56705. function A(t, n, i) {
  56706. typeof i == "string" && (i = {
  56707. className: i
  56708. }), this.options = E(w, e.isPlainObject(i) ? i : {}), this.loadHTML(), this.wrapper = e(h.html), this.options.clickToHide && this.wrapper.addClass(r + "-hidable"), this.wrapper.data(r, this), this.arrow = this.wrapper.find("." + r + "-arrow"), this.container = this.wrapper.find("." + r + "-container"), this.container.append(this.userContainer), t && t.length && (this.elementType = t.attr("type"), this.originalElement = t, this.elem = N(t), this.elem.data(r, this), this.elem.before(this.wrapper)), this.container.hide(), this.run(n);
  56709. }
  56710. var t = [].indexOf || function (e) {
  56711. for (var t = 0, n = this.length; t < n; t++) {
  56712. if (t in this && this[t] === e) return t;
  56713. }
  56714. return -1;
  56715. },
  56716. n = "notify",
  56717. r = n + "js",
  56718. i = n + "!blank",
  56719. s = {
  56720. t: "top",
  56721. m: "middle",
  56722. b: "bottom",
  56723. l: "left",
  56724. c: "center",
  56725. r: "right"
  56726. },
  56727. o = ["l", "c", "r"],
  56728. u = ["t", "m", "b"],
  56729. a = ["t", "b", "l", "r"],
  56730. f = {
  56731. t: "b",
  56732. m: null,
  56733. b: "t",
  56734. l: "r",
  56735. c: null,
  56736. r: "l"
  56737. },
  56738. l = function l(t) {
  56739. var n;
  56740. return n = [], e.each(t.split(/\W+/), function (e, t) {
  56741. var r;
  56742. r = t.toLowerCase().charAt(0);
  56743. if (s[r]) return n.push(r);
  56744. }), n;
  56745. },
  56746. c = {},
  56747. h = {
  56748. name: "core",
  56749. html: '<div class="' + r + '-wrapper">\n <div class="' + r + '-arrow"></div>\n <div class="' + r + '-container"></div>\n</div>',
  56750. css: "." + r + "-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n." + r + "-corner ." + r + "-wrapper,\n." + r + "-corner ." + r + "-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n." + r + "-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n." + r + "-container {\n display: none;\n z-index: 1;\n position: absolute;\n}\n\n." + r + "-hidable {\n cursor: pointer;\n}\n\n[data-notify-text],[data-notify-html] {\n position: relative;\n}\n\n." + r + "-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"
  56751. },
  56752. p = {
  56753. "border-radius": ["-webkit-", "-moz-"]
  56754. },
  56755. d = function d(e) {
  56756. return c[e];
  56757. },
  56758. v = function v(e) {
  56759. if (!e) throw "Missing Style name";
  56760. c[e] && delete c[e];
  56761. },
  56762. m = function m(t, i) {
  56763. if (!t) throw "Missing Style name";
  56764. if (!i) throw "Missing Style definition";
  56765. if (!i.html) throw "Missing Style HTML";
  56766. var s = c[t];
  56767. s && s.cssElem && (window.console && console.warn(n + ": overwriting style '" + t + "'"), c[t].cssElem.remove()), i.name = t, c[t] = i;
  56768. var o = "";
  56769. i.classes && e.each(i.classes, function (t, n) {
  56770. return o += "." + r + "-" + i.name + "-" + t + " {\n", e.each(n, function (t, n) {
  56771. return p[t] && e.each(p[t], function (e, r) {
  56772. return o += " " + r + t + ": " + n + ";\n";
  56773. }), o += " " + t + ": " + n + ";\n";
  56774. }), o += "}\n";
  56775. }), i.css && (o += "/* styles for " + i.name + " */\n" + i.css), o && (i.cssElem = g(o), i.cssElem.attr("id", "notify-" + i.name));
  56776. var u = {},
  56777. a = e(i.html);
  56778. y("html", a, u), y("text", a, u), i.fields = u;
  56779. },
  56780. g = function g(t) {
  56781. var n, r, i;
  56782. r = x("style"), r.attr("type", "text/css"), e("head").append(r);
  56783. try {
  56784. r.html(t);
  56785. } catch (s) {
  56786. r[0].styleSheet.cssText = t;
  56787. }
  56788. return r;
  56789. },
  56790. y = function y(t, n, r) {
  56791. var s;
  56792. return t !== "html" && (t = "text"), s = "data-notify-" + t, b(n, "[" + s + "]").each(function () {
  56793. var n;
  56794. n = e(this).attr(s), n || (n = i), r[n] = t;
  56795. });
  56796. },
  56797. b = function b(e, t) {
  56798. return e.is(t) ? e : e.find(t);
  56799. },
  56800. w = {
  56801. clickToHide: !0,
  56802. autoHide: !0,
  56803. autoHideDelay: 5e3,
  56804. arrowShow: !0,
  56805. arrowSize: 5,
  56806. breakNewLines: !0,
  56807. elementPosition: "bottom",
  56808. globalPosition: "top right",
  56809. style: "bootstrap",
  56810. className: "error",
  56811. showAnimation: "slideDown",
  56812. showDuration: 400,
  56813. hideAnimation: "slideUp",
  56814. hideDuration: 200,
  56815. gap: 5
  56816. },
  56817. E = function E(t, n) {
  56818. var r;
  56819. return r = function r() {}, r.prototype = t, e.extend(!0, new r(), n);
  56820. },
  56821. S = function S(t) {
  56822. return e.extend(w, t);
  56823. },
  56824. x = function x(t) {
  56825. return e("<" + t + "></" + t + ">");
  56826. },
  56827. T = {},
  56828. N = function N(t) {
  56829. var n;
  56830. return t.is("[type=radio]") && (n = t.parents("form:first").find("[type=radio]").filter(function (n, r) {
  56831. return e(r).attr("name") === t.attr("name");
  56832. }), t = n.first()), t;
  56833. },
  56834. C = function C(e, t, n) {
  56835. var r, i;
  56836. if (typeof n == "string") n = parseInt(n, 10);else if (typeof n != "number") return;
  56837. if (isNaN(n)) return;
  56838. return r = s[f[t.charAt(0)]], i = t, e[r] !== undefined && (t = s[r.charAt(0)], n = -n), e[t] === undefined ? e[t] = n : e[t] += n, null;
  56839. },
  56840. k = function k(e, t, n) {
  56841. if (e === "l" || e === "t") return 0;
  56842. if (e === "c" || e === "m") return n / 2 - t / 2;
  56843. if (e === "r" || e === "b") return n - t;
  56844. throw "Invalid alignment";
  56845. },
  56846. L = function L(e) {
  56847. return L.e = L.e || x("div"), L.e.text(e).html();
  56848. };
  56849. A.prototype.loadHTML = function () {
  56850. var t;
  56851. t = this.getStyle(), this.userContainer = e(t.html), this.userFields = t.fields;
  56852. }, A.prototype.show = function (e, t) {
  56853. var n, r, i, s, o;
  56854. r = function (n) {
  56855. return function () {
  56856. !e && !n.elem && n.destroy();
  56857. if (t) return t();
  56858. };
  56859. }(this), o = this.container.parent().parents(":hidden").length > 0, i = this.container.add(this.arrow), n = [];
  56860. if (o && e) s = "show";else if (o && !e) s = "hide";else if (!o && e) s = this.options.showAnimation, n.push(this.options.showDuration);else {
  56861. if (!!o || !!e) return r();
  56862. s = this.options.hideAnimation, n.push(this.options.hideDuration);
  56863. }
  56864. return n.push(r), i[s].apply(i, n);
  56865. }, A.prototype.setGlobalPosition = function () {
  56866. var t = this.getPosition(),
  56867. n = t[0],
  56868. i = t[1],
  56869. o = s[n],
  56870. u = s[i],
  56871. a = n + "|" + i,
  56872. f = T[a];
  56873. if (!f || !document.body.contains(f[0])) {
  56874. f = T[a] = x("div");
  56875. var l = {};
  56876. l[o] = 0, u === "middle" ? l.top = "45%" : u === "center" ? l.left = "45%" : l[u] = 0, f.css(l).addClass(r + "-corner"), e("body").append(f);
  56877. }
  56878. return f.prepend(this.wrapper);
  56879. }, A.prototype.setElementPosition = function () {
  56880. var n, r, i, l, c, h, p, d, v, m, g, y, b, w, E, S, x, T, N, L, A, O, M, _, D, P, H, B, j;
  56881. H = this.getPosition(), _ = H[0], O = H[1], M = H[2], g = this.elem.position(), d = this.elem.outerHeight(), y = this.elem.outerWidth(), v = this.elem.innerHeight(), m = this.elem.innerWidth(), j = this.wrapper.position(), c = this.container.height(), h = this.container.width(), T = s[_], L = f[_], A = s[L], p = {}, p[A] = _ === "b" ? d : _ === "r" ? y : 0, C(p, "top", g.top - j.top), C(p, "left", g.left - j.left), B = ["top", "left"];
  56882. for (w = 0, S = B.length; w < S; w++) {
  56883. D = B[w], N = parseInt(this.elem.css("margin-" + D), 10), N && C(p, D, N);
  56884. }
  56885. b = Math.max(0, this.options.gap - (this.options.arrowShow ? i : 0)), C(p, A, b);
  56886. if (!this.options.arrowShow) this.arrow.hide();else {
  56887. i = this.options.arrowSize, r = e.extend({}, p), n = this.userContainer.css("border-color") || this.userContainer.css("border-top-color") || this.userContainer.css("background-color") || "white";
  56888. for (E = 0, x = a.length; E < x; E++) {
  56889. D = a[E], P = s[D];
  56890. if (D === L) continue;
  56891. l = P === T ? n : "transparent", r["border-" + P] = i + "px solid " + l;
  56892. }
  56893. C(p, s[L], i), t.call(a, O) >= 0 && C(r, s[O], i * 2);
  56894. }
  56895. t.call(u, _) >= 0 ? (C(p, "left", k(O, h, y)), r && C(r, "left", k(O, i, m))) : t.call(o, _) >= 0 && (C(p, "top", k(O, c, d)), r && C(r, "top", k(O, i, v))), this.container.is(":visible") && (p.display = "block"), this.container.removeAttr("style").css(p);
  56896. if (r) return this.arrow.removeAttr("style").css(r);
  56897. }, A.prototype.getPosition = function () {
  56898. var e, n, r, i, s, f, c, h;
  56899. h = this.options.position || (this.elem ? this.options.elementPosition : this.options.globalPosition), e = l(h), e.length === 0 && (e[0] = "b");
  56900. if (n = e[0], t.call(a, n) < 0) throw "Must be one of [" + a + "]";
  56901. if (e.length === 1 || (r = e[0], t.call(u, r) >= 0) && (i = e[1], t.call(o, i) < 0) || (s = e[0], t.call(o, s) >= 0) && (f = e[1], t.call(u, f) < 0)) e[1] = (c = e[0], t.call(o, c) >= 0) ? "m" : "l";
  56902. return e.length === 2 && (e[2] = e[1]), e;
  56903. }, A.prototype.getStyle = function (e) {
  56904. var t;
  56905. e || (e = this.options.style), e || (e = "default"), t = c[e];
  56906. if (!t) throw "Missing style: " + e;
  56907. return t;
  56908. }, A.prototype.updateClasses = function () {
  56909. var t, n;
  56910. return t = ["base"], e.isArray(this.options.className) ? t = t.concat(this.options.className) : this.options.className && t.push(this.options.className), n = this.getStyle(), t = e.map(t, function (e) {
  56911. return r + "-" + n.name + "-" + e;
  56912. }).join(" "), this.userContainer.attr("class", t);
  56913. }, A.prototype.run = function (t, n) {
  56914. var r, s, o, u, a;
  56915. e.isPlainObject(n) ? e.extend(this.options, n) : e.type(n) === "string" && (this.options.className = n);
  56916. if (this.container && !t) {
  56917. this.show(!1);
  56918. return;
  56919. }
  56920. if (!this.container && !t) return;
  56921. s = {}, e.isPlainObject(t) ? s = t : s[i] = t;
  56922. for (o in s) {
  56923. r = s[o], u = this.userFields[o];
  56924. if (!u) continue;
  56925. u === "text" && (r = L(r), this.options.breakNewLines && (r = r.replace(/\n/g, "<br/>"))), a = o === i ? "" : "=" + o, b(this.userContainer, "[data-notify-" + u + a + "]").html(r);
  56926. }
  56927. this.updateClasses(), this.elem ? this.setElementPosition() : this.setGlobalPosition(), this.show(!0), this.options.autoHide && (clearTimeout(this.autohideTimer), this.autohideTimer = setTimeout(this.show.bind(this, !1), this.options.autoHideDelay));
  56928. }, A.prototype.destroy = function () {
  56929. this.wrapper.data(r, null), this.wrapper.remove();
  56930. }, e[n] = function (t, r, i) {
  56931. return t && t.nodeName || t.jquery ? e(t)[n](r, i) : (i = r, r = t, new A(null, r, i)), t;
  56932. }, e.fn[n] = function (t, n) {
  56933. return e(this).each(function () {
  56934. var i = N(e(this)).data(r);
  56935. i && i.destroy();
  56936. var s = new A(e(this), t, n);
  56937. }), this;
  56938. }, e.extend(e[n], {
  56939. defaults: S,
  56940. addStyle: m,
  56941. removeStyle: v,
  56942. pluginOptions: w,
  56943. getStyle: d,
  56944. insertCSS: g
  56945. }), m("bootstrap", {
  56946. html: "<div>\n<span data-notify-text></span>\n</div>",
  56947. classes: {
  56948. base: {
  56949. "font-weight": "bold",
  56950. padding: "8px 15px 8px 14px",
  56951. "text-shadow": "0 1px 0 rgba(255, 255, 255, 0.5)",
  56952. "background-color": "#fcf8e3",
  56953. border: "1px solid #fbeed5",
  56954. "border-radius": "4px",
  56955. "white-space": "nowrap",
  56956. "padding-left": "25px",
  56957. "background-repeat": "no-repeat",
  56958. "background-position": "3px 7px"
  56959. },
  56960. error: {
  56961. color: "#B94A48",
  56962. "background-color": "#F2DEDE",
  56963. "border-color": "#EED3D7",
  56964. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtRJREFUeNqkVc1u00AQHq+dOD+0poIQfkIjalW0SEGqRMuRnHos3DjwAH0ArlyQeANOOSMeAA5VjyBxKBQhgSpVUKKQNGloFdw4cWw2jtfMOna6JOUArDTazXi/b3dm55socPqQhFka++aHBsI8GsopRJERNFlY88FCEk9Yiwf8RhgRyaHFQpPHCDmZG5oX2ui2yilkcTT1AcDsbYC1NMAyOi7zTX2Agx7A9luAl88BauiiQ/cJaZQfIpAlngDcvZZMrl8vFPK5+XktrWlx3/ehZ5r9+t6e+WVnp1pxnNIjgBe4/6dAysQc8dsmHwPcW9C0h3fW1hans1ltwJhy0GxK7XZbUlMp5Ww2eyan6+ft/f2FAqXGK4CvQk5HueFz7D6GOZtIrK+srupdx1GRBBqNBtzc2AiMr7nPplRdKhb1q6q6zjFhrklEFOUutoQ50xcX86ZlqaZpQrfbBdu2R6/G19zX6XSgh6RX5ubyHCM8nqSID6ICrGiZjGYYxojEsiw4PDwMSL5VKsC8Yf4VRYFzMzMaxwjlJSlCyAQ9l0CW44PBADzXhe7xMdi9HtTrdYjFYkDQL0cn4Xdq2/EAE+InCnvADTf2eah4Sx9vExQjkqXT6aAERICMewd/UAp/IeYANM2joxt+q5VI+ieq2i0Wg3l6DNzHwTERPgo1ko7XBXj3vdlsT2F+UuhIhYkp7u7CarkcrFOCtR3H5JiwbAIeImjT/YQKKBtGjRFCU5IUgFRe7fF4cCNVIPMYo3VKqxwjyNAXNepuopyqnld602qVsfRpEkkz+GFL1wPj6ySXBpJtWVa5xlhpcyhBNwpZHmtX8AGgfIExo0ZpzkWVTBGiXCSEaHh62/PoR0p/vHaczxXGnj4bSo+G78lELU80h1uogBwWLf5YlsPmgDEd4M236xjm+8nm4IuE/9u+/PH2JXZfbwz4zw1WbO+SQPpXfwG/BBgAhCNZiSb/pOQAAAAASUVORK5CYII=)"
  56965. },
  56966. success: {
  56967. color: "#468847",
  56968. "background-color": "#DFF0D8",
  56969. "border-color": "#D6E9C6",
  56970. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAutJREFUeNq0lctPE0Ecx38zu/RFS1EryqtgJFA08YCiMZIAQQ4eRG8eDGdPJiYeTIwHTfwPiAcvXIwXLwoXPaDxkWgQ6islKlJLSQWLUraPLTv7Gme32zoF9KSTfLO7v53vZ3d/M7/fIth+IO6INt2jjoA7bjHCJoAlzCRw59YwHYjBnfMPqAKWQYKjGkfCJqAF0xwZjipQtA3MxeSG87VhOOYegVrUCy7UZM9S6TLIdAamySTclZdYhFhRHloGYg7mgZv1Zzztvgud7V1tbQ2twYA34LJmF4p5dXF1KTufnE+SxeJtuCZNsLDCQU0+RyKTF27Unw101l8e6hns3u0PBalORVVVkcaEKBJDgV3+cGM4tKKmI+ohlIGnygKX00rSBfszz/n2uXv81wd6+rt1orsZCHRdr1Imk2F2Kob3hutSxW8thsd8AXNaln9D7CTfA6O+0UgkMuwVvEFFUbbAcrkcTA8+AtOk8E6KiQiDmMFSDqZItAzEVQviRkdDdaFgPp8HSZKAEAL5Qh7Sq2lIJBJwv2scUqkUnKoZgNhcDKhKg5aH+1IkcouCAdFGAQsuWZYhOjwFHQ96oagWgRoUov1T9kRBEODAwxM2QtEUl+Wp+Ln9VRo6BcMw4ErHRYjH4/B26AlQoQQTRdHWwcd9AH57+UAXddvDD37DmrBBV34WfqiXPl61g+vr6xA9zsGeM9gOdsNXkgpEtTwVvwOklXLKm6+/p5ezwk4B+j6droBs2CsGa/gNs6RIxazl4Tc25mpTgw/apPR1LYlNRFAzgsOxkyXYLIM1V8NMwyAkJSctD1eGVKiq5wWjSPdjmeTkiKvVW4f2YPHWl3GAVq6ymcyCTgovM3FzyRiDe2TaKcEKsLpJvNHjZgPNqEtyi6mZIm4SRFyLMUsONSSdkPeFtY1n0mczoY3BHTLhwPRy9/lzcziCw9ACI+yql0VLzcGAZbYSM5CCSZg1/9oc/nn7+i8N9p/8An4JMADxhH+xHfuiKwAAAABJRU5ErkJggg==)"
  56971. },
  56972. info: {
  56973. color: "#3A87AD",
  56974. "background-color": "#D9EDF7",
  56975. "border-color": "#BCE8F1",
  56976. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QYFAhkSsdes/QAAA8dJREFUOMvVlGtMW2UYx//POaWHXg6lLaW0ypAtw1UCgbniNOLcVOLmAjHZolOYlxmTGXVZdAnRfXQm+7SoU4mXaOaiZsEpC9FkiQs6Z6bdCnNYruM6KNBw6YWewzl9z+sHImEWv+vz7XmT95f/+3/+7wP814v+efDOV3/SoX3lHAA+6ODeUFfMfjOWMADgdk+eEKz0pF7aQdMAcOKLLjrcVMVX3xdWN29/GhYP7SvnP0cWfS8caSkfHZsPE9Fgnt02JNutQ0QYHB2dDz9/pKX8QjjuO9xUxd/66HdxTeCHZ3rojQObGQBcuNjfplkD3b19Y/6MrimSaKgSMmpGU5WevmE/swa6Oy73tQHA0Rdr2Mmv/6A1n9w9suQ7097Z9lM4FlTgTDrzZTu4StXVfpiI48rVcUDM5cmEksrFnHxfpTtU/3BFQzCQF/2bYVoNbH7zmItbSoMj40JSzmMyX5qDvriA7QdrIIpA+3cdsMpu0nXI8cV0MtKXCPZev+gCEM1S2NHPvWfP/hL+7FSr3+0p5RBEyhEN5JCKYr8XnASMT0xBNyzQGQeI8fjsGD39RMPk7se2bd5ZtTyoFYXftF6y37gx7NeUtJJOTFlAHDZLDuILU3j3+H5oOrD3yWbIztugaAzgnBKJuBLpGfQrS8wO4FZgV+c1IxaLgWVU0tMLEETCos4xMzEIv9cJXQcyagIwigDGwJgOAtHAwAhisQUjy0ORGERiELgG4iakkzo4MYAxcM5hAMi1WWG1yYCJIcMUaBkVRLdGeSU2995TLWzcUAzONJ7J6FBVBYIggMzmFbvdBV44Corg8vjhzC+EJEl8U1kJtgYrhCzgc/vvTwXKSib1paRFVRVORDAJAsw5FuTaJEhWM2SHB3mOAlhkNxwuLzeJsGwqWzf5TFNdKgtY5qHp6ZFf67Y/sAVadCaVY5YACDDb3Oi4NIjLnWMw2QthCBIsVhsUTU9tvXsjeq9+X1d75/KEs4LNOfcdf/+HthMnvwxOD0wmHaXr7ZItn2wuH2SnBzbZAbPJwpPx+VQuzcm7dgRCB57a1uBzUDRL4bfnI0RE0eaXd9W89mpjqHZnUI5Hh2l2dkZZUhOqpi2qSmpOmZ64Tuu9qlz/SEXo6MEHa3wOip46F1n7633eekV8ds8Wxjn37Wl63VVa+ej5oeEZ/82ZBETJjpJ1Rbij2D3Z/1trXUvLsblCK0XfOx0SX2kMsn9dX+d+7Kf6h8o4AIykuffjT8L20LU+w4AZd5VvEPY+XpWqLV327HR7DzXuDnD8r+ovkBehJ8i+y8YAAAAASUVORK5CYII=)"
  56977. },
  56978. warn: {
  56979. color: "#C09853",
  56980. "background-color": "#FCF8E3",
  56981. "border-color": "#FBEED5",
  56982. "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABJlBMVEXr6eb/2oD/wi7/xjr/0mP/ykf/tQD/vBj/3o7/uQ//vyL/twebhgD/4pzX1K3z8e349vK6tHCilCWbiQymn0jGworr6dXQza3HxcKkn1vWvV/5uRfk4dXZ1bD18+/52YebiAmyr5S9mhCzrWq5t6ufjRH54aLs0oS+qD751XqPhAybhwXsujG3sm+Zk0PTwG6Shg+PhhObhwOPgQL4zV2nlyrf27uLfgCPhRHu7OmLgAafkyiWkD3l49ibiAfTs0C+lgCniwD4sgDJxqOilzDWowWFfAH08uebig6qpFHBvH/aw26FfQTQzsvy8OyEfz20r3jAvaKbhgG9q0nc2LbZxXanoUu/u5WSggCtp1anpJKdmFz/zlX/1nGJiYmuq5Dx7+sAAADoPUZSAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfdBgUBGhh4aah5AAAAlklEQVQY02NgoBIIE8EUcwn1FkIXM1Tj5dDUQhPU502Mi7XXQxGz5uVIjGOJUUUW81HnYEyMi2HVcUOICQZzMMYmxrEyMylJwgUt5BljWRLjmJm4pI1hYp5SQLGYxDgmLnZOVxuooClIDKgXKMbN5ggV1ACLJcaBxNgcoiGCBiZwdWxOETBDrTyEFey0jYJ4eHjMGWgEAIpRFRCUt08qAAAAAElFTkSuQmCC)"
  56983. }
  56984. }
  56985. }), e(function () {
  56986. g(h.css).attr("id", "core-notify"), e(document).on("click", "." + r + "-hidable", function (t) {
  56987. e(this).trigger("notify-hide");
  56988. }), e(document).on("notify-hide", "." + r + "-wrapper", function (t) {
  56989. var n = e(this).data(r);
  56990. n && n.show(!1);
  56991. });
  56992. });
  56993. });
  56994. /***/ }),
  56995. /***/ "./resources/js/views/App.vue":
  56996. /*!************************************!*\
  56997. !*** ./resources/js/views/App.vue ***!
  56998. \************************************/
  56999. /*! exports provided: default */
  57000. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57001. "use strict";
  57002. __webpack_require__.r(__webpack_exports__);
  57003. /* harmony import */ var _App_vue_vue_type_template_id_91ac6b5c___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./App.vue?vue&type=template&id=91ac6b5c& */ "./resources/js/views/App.vue?vue&type=template&id=91ac6b5c&");
  57004. /* harmony import */ var _App_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./App.vue?vue&type=script&lang=js& */ "./resources/js/views/App.vue?vue&type=script&lang=js&");
  57005. /* 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");
  57006. /* normalize component */
  57007. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  57008. _App_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  57009. _App_vue_vue_type_template_id_91ac6b5c___WEBPACK_IMPORTED_MODULE_0__["render"],
  57010. _App_vue_vue_type_template_id_91ac6b5c___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  57011. false,
  57012. null,
  57013. null,
  57014. null
  57015. )
  57016. /* hot reload */
  57017. if (false) { var api; }
  57018. component.options.__file = "resources/js/views/App.vue"
  57019. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  57020. /***/ }),
  57021. /***/ "./resources/js/views/App.vue?vue&type=script&lang=js&":
  57022. /*!*************************************************************!*\
  57023. !*** ./resources/js/views/App.vue?vue&type=script&lang=js& ***!
  57024. \*************************************************************/
  57025. /*! exports provided: default */
  57026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57027. "use strict";
  57028. __webpack_require__.r(__webpack_exports__);
  57029. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_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!./App.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/App.vue?vue&type=script&lang=js&");
  57030. /* 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_App_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  57031. /***/ }),
  57032. /***/ "./resources/js/views/App.vue?vue&type=template&id=91ac6b5c&":
  57033. /*!*******************************************************************!*\
  57034. !*** ./resources/js/views/App.vue?vue&type=template&id=91ac6b5c& ***!
  57035. \*******************************************************************/
  57036. /*! exports provided: render, staticRenderFns */
  57037. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57038. "use strict";
  57039. __webpack_require__.r(__webpack_exports__);
  57040. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_template_id_91ac6b5c___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!./App.vue?vue&type=template&id=91ac6b5c& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/App.vue?vue&type=template&id=91ac6b5c&");
  57041. /* 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_App_vue_vue_type_template_id_91ac6b5c___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  57042. /* 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_App_vue_vue_type_template_id_91ac6b5c___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  57043. /***/ }),
  57044. /***/ "./resources/js/views/Welcome.vue":
  57045. /*!****************************************!*\
  57046. !*** ./resources/js/views/Welcome.vue ***!
  57047. \****************************************/
  57048. /*! exports provided: default */
  57049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57050. "use strict";
  57051. __webpack_require__.r(__webpack_exports__);
  57052. /* harmony import */ var _Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true& */ "./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true&");
  57053. /* harmony import */ var _Welcome_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Welcome.vue?vue&type=script&lang=js& */ "./resources/js/views/Welcome.vue?vue&type=script&lang=js&");
  57054. /* empty/unused harmony star reexport *//* harmony import */ var _Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& */ "./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&");
  57055. /* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js");
  57056. /* normalize component */
  57057. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_3__["default"])(
  57058. _Welcome_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  57059. _Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___WEBPACK_IMPORTED_MODULE_0__["render"],
  57060. _Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  57061. false,
  57062. null,
  57063. "1ae8ae93",
  57064. null
  57065. )
  57066. /* hot reload */
  57067. if (false) { var api; }
  57068. component.options.__file = "resources/js/views/Welcome.vue"
  57069. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  57070. /***/ }),
  57071. /***/ "./resources/js/views/Welcome.vue?vue&type=script&lang=js&":
  57072. /*!*****************************************************************!*\
  57073. !*** ./resources/js/views/Welcome.vue?vue&type=script&lang=js& ***!
  57074. \*****************************************************************/
  57075. /*! exports provided: default */
  57076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57077. "use strict";
  57078. __webpack_require__.r(__webpack_exports__);
  57079. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_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!./Welcome.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=script&lang=js&");
  57080. /* 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_Welcome_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  57081. /***/ }),
  57082. /***/ "./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&":
  57083. /*!*************************************************************************************************!*\
  57084. !*** ./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& ***!
  57085. \*************************************************************************************************/
  57086. /*! no static exports found */
  57087. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57088. "use strict";
  57089. __webpack_require__.r(__webpack_exports__);
  57090. /* harmony import */ var _node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/style-loader!../../../node_modules/css-loader??ref--6-1!../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../node_modules/postcss-loader/src??ref--6-2!../../../node_modules/vue-loader/lib??vue-loader-options!./Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css& */ "./node_modules/style-loader/index.js!./node_modules/css-loader/index.js?!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=style&index=0&id=1ae8ae93&scoped=true&lang=css&");
  57091. /* harmony import */ var _node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__);
  57092. /* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__));
  57093. /* harmony default export */ __webpack_exports__["default"] = (_node_modules_style_loader_index_js_node_modules_css_loader_index_js_ref_6_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_2_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_style_index_0_id_1ae8ae93_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0___default.a);
  57094. /***/ }),
  57095. /***/ "./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true&":
  57096. /*!***********************************************************************************!*\
  57097. !*** ./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true& ***!
  57098. \***********************************************************************************/
  57099. /*! exports provided: render, staticRenderFns */
  57100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57101. "use strict";
  57102. __webpack_require__.r(__webpack_exports__);
  57103. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___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!./Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/views/Welcome.vue?vue&type=template&id=1ae8ae93&scoped=true&");
  57104. /* 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_Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  57105. /* 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_Welcome_vue_vue_type_template_id_1ae8ae93_scoped_true___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  57106. /***/ }),
  57107. /***/ "./resources/sass/app.scss":
  57108. /*!*********************************!*\
  57109. !*** ./resources/sass/app.scss ***!
  57110. \*********************************/
  57111. /*! no static exports found */
  57112. /***/ (function(module, exports) {
  57113. // removed by extract-text-webpack-plugin
  57114. /***/ }),
  57115. /***/ 0:
  57116. /*!*************************************************************!*\
  57117. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  57118. \*************************************************************/
  57119. /*! no static exports found */
  57120. /***/ (function(module, exports, __webpack_require__) {
  57121. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  57122. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  57123. /***/ })
  57124. /******/ });