app.js 1.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 0);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/axios/index.js":
  89. /*!*************************************!*\
  90. !*** ./node_modules/axios/index.js ***!
  91. \*************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports, __webpack_require__) {
  94. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  95. /***/ }),
  96. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  97. /*!************************************************!*\
  98. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  99. \************************************************/
  100. /*! no static exports found */
  101. /***/ (function(module, exports, __webpack_require__) {
  102. "use strict";
  103. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  104. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  105. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  106. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  107. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  108. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  109. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  110. module.exports = function xhrAdapter(config) {
  111. return new Promise(function dispatchXhrRequest(resolve, reject) {
  112. var requestData = config.data;
  113. var requestHeaders = config.headers;
  114. if (utils.isFormData(requestData)) {
  115. delete requestHeaders['Content-Type']; // Let the browser set it
  116. }
  117. var request = new XMLHttpRequest();
  118. // HTTP basic authentication
  119. if (config.auth) {
  120. var username = config.auth.username || '';
  121. var password = config.auth.password || '';
  122. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  123. }
  124. var fullPath = buildFullPath(config.baseURL, config.url);
  125. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  126. // Set the request timeout in MS
  127. request.timeout = config.timeout;
  128. // Listen for ready state
  129. request.onreadystatechange = function handleLoad() {
  130. if (!request || request.readyState !== 4) {
  131. return;
  132. }
  133. // The request errored out and we didn't get a response, this will be
  134. // handled by onerror instead
  135. // With one exception: request that using file: protocol, most browsers
  136. // will return status as 0 even though it's a successful request
  137. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  138. return;
  139. }
  140. // Prepare the response
  141. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  142. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  143. var response = {
  144. data: responseData,
  145. status: request.status,
  146. statusText: request.statusText,
  147. headers: responseHeaders,
  148. config: config,
  149. request: request
  150. };
  151. settle(resolve, reject, response);
  152. // Clean up request
  153. request = null;
  154. };
  155. // Handle browser request cancellation (as opposed to a manual cancellation)
  156. request.onabort = function handleAbort() {
  157. if (!request) {
  158. return;
  159. }
  160. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  161. // Clean up request
  162. request = null;
  163. };
  164. // Handle low level network errors
  165. request.onerror = function handleError() {
  166. // Real errors are hidden from us by the browser
  167. // onerror should only fire if it's a network error
  168. reject(createError('Network Error', config, null, request));
  169. // Clean up request
  170. request = null;
  171. };
  172. // Handle timeout
  173. request.ontimeout = function handleTimeout() {
  174. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  175. if (config.timeoutErrorMessage) {
  176. timeoutErrorMessage = config.timeoutErrorMessage;
  177. }
  178. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  179. request));
  180. // Clean up request
  181. request = null;
  182. };
  183. // Add xsrf header
  184. // This is only done if running in a standard browser environment.
  185. // Specifically not if we're in a web worker, or react-native.
  186. if (utils.isStandardBrowserEnv()) {
  187. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  188. // Add xsrf header
  189. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  190. cookies.read(config.xsrfCookieName) :
  191. undefined;
  192. if (xsrfValue) {
  193. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  194. }
  195. }
  196. // Add headers to the request
  197. if ('setRequestHeader' in request) {
  198. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  199. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  200. // Remove Content-Type if data is undefined
  201. delete requestHeaders[key];
  202. } else {
  203. // Otherwise add header to the request
  204. request.setRequestHeader(key, val);
  205. }
  206. });
  207. }
  208. // Add withCredentials to request if needed
  209. if (!utils.isUndefined(config.withCredentials)) {
  210. request.withCredentials = !!config.withCredentials;
  211. }
  212. // Add responseType to request if needed
  213. if (config.responseType) {
  214. try {
  215. request.responseType = config.responseType;
  216. } catch (e) {
  217. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  218. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  219. if (config.responseType !== 'json') {
  220. throw e;
  221. }
  222. }
  223. }
  224. // Handle progress if needed
  225. if (typeof config.onDownloadProgress === 'function') {
  226. request.addEventListener('progress', config.onDownloadProgress);
  227. }
  228. // Not all browsers support upload events
  229. if (typeof config.onUploadProgress === 'function' && request.upload) {
  230. request.upload.addEventListener('progress', config.onUploadProgress);
  231. }
  232. if (config.cancelToken) {
  233. // Handle cancellation
  234. config.cancelToken.promise.then(function onCanceled(cancel) {
  235. if (!request) {
  236. return;
  237. }
  238. request.abort();
  239. reject(cancel);
  240. // Clean up request
  241. request = null;
  242. });
  243. }
  244. if (requestData === undefined) {
  245. requestData = null;
  246. }
  247. // Send the request
  248. request.send(requestData);
  249. });
  250. };
  251. /***/ }),
  252. /***/ "./node_modules/axios/lib/axios.js":
  253. /*!*****************************************!*\
  254. !*** ./node_modules/axios/lib/axios.js ***!
  255. \*****************************************/
  256. /*! no static exports found */
  257. /***/ (function(module, exports, __webpack_require__) {
  258. "use strict";
  259. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  260. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  261. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  262. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  263. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  264. /**
  265. * Create an instance of Axios
  266. *
  267. * @param {Object} defaultConfig The default config for the instance
  268. * @return {Axios} A new instance of Axios
  269. */
  270. function createInstance(defaultConfig) {
  271. var context = new Axios(defaultConfig);
  272. var instance = bind(Axios.prototype.request, context);
  273. // Copy axios.prototype to instance
  274. utils.extend(instance, Axios.prototype, context);
  275. // Copy context to instance
  276. utils.extend(instance, context);
  277. return instance;
  278. }
  279. // Create the default instance to be exported
  280. var axios = createInstance(defaults);
  281. // Expose Axios class to allow class inheritance
  282. axios.Axios = Axios;
  283. // Factory for creating new instances
  284. axios.create = function create(instanceConfig) {
  285. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  286. };
  287. // Expose Cancel & CancelToken
  288. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  289. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  290. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  291. // Expose all/spread
  292. axios.all = function all(promises) {
  293. return Promise.all(promises);
  294. };
  295. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  296. module.exports = axios;
  297. // Allow use of default import syntax in TypeScript
  298. module.exports.default = axios;
  299. /***/ }),
  300. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  301. /*!*************************************************!*\
  302. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  303. \*************************************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports, __webpack_require__) {
  306. "use strict";
  307. /**
  308. * A `Cancel` is an object that is thrown when an operation is canceled.
  309. *
  310. * @class
  311. * @param {string=} message The message.
  312. */
  313. function Cancel(message) {
  314. this.message = message;
  315. }
  316. Cancel.prototype.toString = function toString() {
  317. return 'Cancel' + (this.message ? ': ' + this.message : '');
  318. };
  319. Cancel.prototype.__CANCEL__ = true;
  320. module.exports = Cancel;
  321. /***/ }),
  322. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  323. /*!******************************************************!*\
  324. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  325. \******************************************************/
  326. /*! no static exports found */
  327. /***/ (function(module, exports, __webpack_require__) {
  328. "use strict";
  329. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  330. /**
  331. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  332. *
  333. * @class
  334. * @param {Function} executor The executor function.
  335. */
  336. function CancelToken(executor) {
  337. if (typeof executor !== 'function') {
  338. throw new TypeError('executor must be a function.');
  339. }
  340. var resolvePromise;
  341. this.promise = new Promise(function promiseExecutor(resolve) {
  342. resolvePromise = resolve;
  343. });
  344. var token = this;
  345. executor(function cancel(message) {
  346. if (token.reason) {
  347. // Cancellation has already been requested
  348. return;
  349. }
  350. token.reason = new Cancel(message);
  351. resolvePromise(token.reason);
  352. });
  353. }
  354. /**
  355. * Throws a `Cancel` if cancellation has been requested.
  356. */
  357. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  358. if (this.reason) {
  359. throw this.reason;
  360. }
  361. };
  362. /**
  363. * Returns an object that contains a new `CancelToken` and a function that, when called,
  364. * cancels the `CancelToken`.
  365. */
  366. CancelToken.source = function source() {
  367. var cancel;
  368. var token = new CancelToken(function executor(c) {
  369. cancel = c;
  370. });
  371. return {
  372. token: token,
  373. cancel: cancel
  374. };
  375. };
  376. module.exports = CancelToken;
  377. /***/ }),
  378. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  379. /*!***************************************************!*\
  380. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  381. \***************************************************/
  382. /*! no static exports found */
  383. /***/ (function(module, exports, __webpack_require__) {
  384. "use strict";
  385. module.exports = function isCancel(value) {
  386. return !!(value && value.__CANCEL__);
  387. };
  388. /***/ }),
  389. /***/ "./node_modules/axios/lib/core/Axios.js":
  390. /*!**********************************************!*\
  391. !*** ./node_modules/axios/lib/core/Axios.js ***!
  392. \**********************************************/
  393. /*! no static exports found */
  394. /***/ (function(module, exports, __webpack_require__) {
  395. "use strict";
  396. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  397. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  398. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  399. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  400. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  401. /**
  402. * Create a new instance of Axios
  403. *
  404. * @param {Object} instanceConfig The default config for the instance
  405. */
  406. function Axios(instanceConfig) {
  407. this.defaults = instanceConfig;
  408. this.interceptors = {
  409. request: new InterceptorManager(),
  410. response: new InterceptorManager()
  411. };
  412. }
  413. /**
  414. * Dispatch a request
  415. *
  416. * @param {Object} config The config specific for this request (merged with this.defaults)
  417. */
  418. Axios.prototype.request = function request(config) {
  419. /*eslint no-param-reassign:0*/
  420. // Allow for axios('example/url'[, config]) a la fetch API
  421. if (typeof config === 'string') {
  422. config = arguments[1] || {};
  423. config.url = arguments[0];
  424. } else {
  425. config = config || {};
  426. }
  427. config = mergeConfig(this.defaults, config);
  428. // Set config.method
  429. if (config.method) {
  430. config.method = config.method.toLowerCase();
  431. } else if (this.defaults.method) {
  432. config.method = this.defaults.method.toLowerCase();
  433. } else {
  434. config.method = 'get';
  435. }
  436. // Hook up interceptors middleware
  437. var chain = [dispatchRequest, undefined];
  438. var promise = Promise.resolve(config);
  439. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  440. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  441. });
  442. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  443. chain.push(interceptor.fulfilled, interceptor.rejected);
  444. });
  445. while (chain.length) {
  446. promise = promise.then(chain.shift(), chain.shift());
  447. }
  448. return promise;
  449. };
  450. Axios.prototype.getUri = function getUri(config) {
  451. config = mergeConfig(this.defaults, config);
  452. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  453. };
  454. // Provide aliases for supported request methods
  455. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  456. /*eslint func-names:0*/
  457. Axios.prototype[method] = function(url, config) {
  458. return this.request(utils.merge(config || {}, {
  459. method: method,
  460. url: url
  461. }));
  462. };
  463. });
  464. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  465. /*eslint func-names:0*/
  466. Axios.prototype[method] = function(url, data, config) {
  467. return this.request(utils.merge(config || {}, {
  468. method: method,
  469. url: url,
  470. data: data
  471. }));
  472. };
  473. });
  474. module.exports = Axios;
  475. /***/ }),
  476. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  477. /*!***********************************************************!*\
  478. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  479. \***********************************************************/
  480. /*! no static exports found */
  481. /***/ (function(module, exports, __webpack_require__) {
  482. "use strict";
  483. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  484. function InterceptorManager() {
  485. this.handlers = [];
  486. }
  487. /**
  488. * Add a new interceptor to the stack
  489. *
  490. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  491. * @param {Function} rejected The function to handle `reject` for a `Promise`
  492. *
  493. * @return {Number} An ID used to remove interceptor later
  494. */
  495. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  496. this.handlers.push({
  497. fulfilled: fulfilled,
  498. rejected: rejected
  499. });
  500. return this.handlers.length - 1;
  501. };
  502. /**
  503. * Remove an interceptor from the stack
  504. *
  505. * @param {Number} id The ID that was returned by `use`
  506. */
  507. InterceptorManager.prototype.eject = function eject(id) {
  508. if (this.handlers[id]) {
  509. this.handlers[id] = null;
  510. }
  511. };
  512. /**
  513. * Iterate over all the registered interceptors
  514. *
  515. * This method is particularly useful for skipping over any
  516. * interceptors that may have become `null` calling `eject`.
  517. *
  518. * @param {Function} fn The function to call for each interceptor
  519. */
  520. InterceptorManager.prototype.forEach = function forEach(fn) {
  521. utils.forEach(this.handlers, function forEachHandler(h) {
  522. if (h !== null) {
  523. fn(h);
  524. }
  525. });
  526. };
  527. module.exports = InterceptorManager;
  528. /***/ }),
  529. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  530. /*!******************************************************!*\
  531. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  532. \******************************************************/
  533. /*! no static exports found */
  534. /***/ (function(module, exports, __webpack_require__) {
  535. "use strict";
  536. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  537. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  538. /**
  539. * Creates a new URL by combining the baseURL with the requestedURL,
  540. * only when the requestedURL is not already an absolute URL.
  541. * If the requestURL is absolute, this function returns the requestedURL untouched.
  542. *
  543. * @param {string} baseURL The base URL
  544. * @param {string} requestedURL Absolute or relative URL to combine
  545. * @returns {string} The combined full path
  546. */
  547. module.exports = function buildFullPath(baseURL, requestedURL) {
  548. if (baseURL && !isAbsoluteURL(requestedURL)) {
  549. return combineURLs(baseURL, requestedURL);
  550. }
  551. return requestedURL;
  552. };
  553. /***/ }),
  554. /***/ "./node_modules/axios/lib/core/createError.js":
  555. /*!****************************************************!*\
  556. !*** ./node_modules/axios/lib/core/createError.js ***!
  557. \****************************************************/
  558. /*! no static exports found */
  559. /***/ (function(module, exports, __webpack_require__) {
  560. "use strict";
  561. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  562. /**
  563. * Create an Error with the specified message, config, error code, request and response.
  564. *
  565. * @param {string} message The error message.
  566. * @param {Object} config The config.
  567. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  568. * @param {Object} [request] The request.
  569. * @param {Object} [response] The response.
  570. * @returns {Error} The created error.
  571. */
  572. module.exports = function createError(message, config, code, request, response) {
  573. var error = new Error(message);
  574. return enhanceError(error, config, code, request, response);
  575. };
  576. /***/ }),
  577. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  578. /*!********************************************************!*\
  579. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  580. \********************************************************/
  581. /*! no static exports found */
  582. /***/ (function(module, exports, __webpack_require__) {
  583. "use strict";
  584. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  585. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  586. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  587. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  588. /**
  589. * Throws a `Cancel` if cancellation has been requested.
  590. */
  591. function throwIfCancellationRequested(config) {
  592. if (config.cancelToken) {
  593. config.cancelToken.throwIfRequested();
  594. }
  595. }
  596. /**
  597. * Dispatch a request to the server using the configured adapter.
  598. *
  599. * @param {object} config The config that is to be used for the request
  600. * @returns {Promise} The Promise to be fulfilled
  601. */
  602. module.exports = function dispatchRequest(config) {
  603. throwIfCancellationRequested(config);
  604. // Ensure headers exist
  605. config.headers = config.headers || {};
  606. // Transform request data
  607. config.data = transformData(
  608. config.data,
  609. config.headers,
  610. config.transformRequest
  611. );
  612. // Flatten headers
  613. config.headers = utils.merge(
  614. config.headers.common || {},
  615. config.headers[config.method] || {},
  616. config.headers
  617. );
  618. utils.forEach(
  619. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  620. function cleanHeaderConfig(method) {
  621. delete config.headers[method];
  622. }
  623. );
  624. var adapter = config.adapter || defaults.adapter;
  625. return adapter(config).then(function onAdapterResolution(response) {
  626. throwIfCancellationRequested(config);
  627. // Transform response data
  628. response.data = transformData(
  629. response.data,
  630. response.headers,
  631. config.transformResponse
  632. );
  633. return response;
  634. }, function onAdapterRejection(reason) {
  635. if (!isCancel(reason)) {
  636. throwIfCancellationRequested(config);
  637. // Transform response data
  638. if (reason && reason.response) {
  639. reason.response.data = transformData(
  640. reason.response.data,
  641. reason.response.headers,
  642. config.transformResponse
  643. );
  644. }
  645. }
  646. return Promise.reject(reason);
  647. });
  648. };
  649. /***/ }),
  650. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  651. /*!*****************************************************!*\
  652. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  653. \*****************************************************/
  654. /*! no static exports found */
  655. /***/ (function(module, exports, __webpack_require__) {
  656. "use strict";
  657. /**
  658. * Update an Error with the specified config, error code, and response.
  659. *
  660. * @param {Error} error The error to update.
  661. * @param {Object} config The config.
  662. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  663. * @param {Object} [request] The request.
  664. * @param {Object} [response] The response.
  665. * @returns {Error} The error.
  666. */
  667. module.exports = function enhanceError(error, config, code, request, response) {
  668. error.config = config;
  669. if (code) {
  670. error.code = code;
  671. }
  672. error.request = request;
  673. error.response = response;
  674. error.isAxiosError = true;
  675. error.toJSON = function() {
  676. return {
  677. // Standard
  678. message: this.message,
  679. name: this.name,
  680. // Microsoft
  681. description: this.description,
  682. number: this.number,
  683. // Mozilla
  684. fileName: this.fileName,
  685. lineNumber: this.lineNumber,
  686. columnNumber: this.columnNumber,
  687. stack: this.stack,
  688. // Axios
  689. config: this.config,
  690. code: this.code
  691. };
  692. };
  693. return error;
  694. };
  695. /***/ }),
  696. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  697. /*!****************************************************!*\
  698. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  699. \****************************************************/
  700. /*! no static exports found */
  701. /***/ (function(module, exports, __webpack_require__) {
  702. "use strict";
  703. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  704. /**
  705. * Config-specific merge-function which creates a new config-object
  706. * by merging two configuration objects together.
  707. *
  708. * @param {Object} config1
  709. * @param {Object} config2
  710. * @returns {Object} New object resulting from merging config2 to config1
  711. */
  712. module.exports = function mergeConfig(config1, config2) {
  713. // eslint-disable-next-line no-param-reassign
  714. config2 = config2 || {};
  715. var config = {};
  716. var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
  717. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
  718. var defaultToConfig2Keys = [
  719. 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
  720. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  721. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
  722. 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
  723. 'httpsAgent', 'cancelToken', 'socketPath'
  724. ];
  725. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  726. if (typeof config2[prop] !== 'undefined') {
  727. config[prop] = config2[prop];
  728. }
  729. });
  730. utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
  731. if (utils.isObject(config2[prop])) {
  732. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  733. } else if (typeof config2[prop] !== 'undefined') {
  734. config[prop] = config2[prop];
  735. } else if (utils.isObject(config1[prop])) {
  736. config[prop] = utils.deepMerge(config1[prop]);
  737. } else if (typeof config1[prop] !== 'undefined') {
  738. config[prop] = config1[prop];
  739. }
  740. });
  741. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  742. if (typeof config2[prop] !== 'undefined') {
  743. config[prop] = config2[prop];
  744. } else if (typeof config1[prop] !== 'undefined') {
  745. config[prop] = config1[prop];
  746. }
  747. });
  748. var axiosKeys = valueFromConfig2Keys
  749. .concat(mergeDeepPropertiesKeys)
  750. .concat(defaultToConfig2Keys);
  751. var otherKeys = Object
  752. .keys(config2)
  753. .filter(function filterAxiosKeys(key) {
  754. return axiosKeys.indexOf(key) === -1;
  755. });
  756. utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
  757. if (typeof config2[prop] !== 'undefined') {
  758. config[prop] = config2[prop];
  759. } else if (typeof config1[prop] !== 'undefined') {
  760. config[prop] = config1[prop];
  761. }
  762. });
  763. return config;
  764. };
  765. /***/ }),
  766. /***/ "./node_modules/axios/lib/core/settle.js":
  767. /*!***********************************************!*\
  768. !*** ./node_modules/axios/lib/core/settle.js ***!
  769. \***********************************************/
  770. /*! no static exports found */
  771. /***/ (function(module, exports, __webpack_require__) {
  772. "use strict";
  773. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  774. /**
  775. * Resolve or reject a Promise based on response status.
  776. *
  777. * @param {Function} resolve A function that resolves the promise.
  778. * @param {Function} reject A function that rejects the promise.
  779. * @param {object} response The response.
  780. */
  781. module.exports = function settle(resolve, reject, response) {
  782. var validateStatus = response.config.validateStatus;
  783. if (!validateStatus || validateStatus(response.status)) {
  784. resolve(response);
  785. } else {
  786. reject(createError(
  787. 'Request failed with status code ' + response.status,
  788. response.config,
  789. null,
  790. response.request,
  791. response
  792. ));
  793. }
  794. };
  795. /***/ }),
  796. /***/ "./node_modules/axios/lib/core/transformData.js":
  797. /*!******************************************************!*\
  798. !*** ./node_modules/axios/lib/core/transformData.js ***!
  799. \******************************************************/
  800. /*! no static exports found */
  801. /***/ (function(module, exports, __webpack_require__) {
  802. "use strict";
  803. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  804. /**
  805. * Transform the data for a request or a response
  806. *
  807. * @param {Object|String} data The data to be transformed
  808. * @param {Array} headers The headers for the request or response
  809. * @param {Array|Function} fns A single function or Array of functions
  810. * @returns {*} The resulting transformed data
  811. */
  812. module.exports = function transformData(data, headers, fns) {
  813. /*eslint no-param-reassign:0*/
  814. utils.forEach(fns, function transform(fn) {
  815. data = fn(data, headers);
  816. });
  817. return data;
  818. };
  819. /***/ }),
  820. /***/ "./node_modules/axios/lib/defaults.js":
  821. /*!********************************************!*\
  822. !*** ./node_modules/axios/lib/defaults.js ***!
  823. \********************************************/
  824. /*! no static exports found */
  825. /***/ (function(module, exports, __webpack_require__) {
  826. "use strict";
  827. /* WEBPACK VAR INJECTION */(function(process) {
  828. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  829. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  830. var DEFAULT_CONTENT_TYPE = {
  831. 'Content-Type': 'application/x-www-form-urlencoded'
  832. };
  833. function setContentTypeIfUnset(headers, value) {
  834. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  835. headers['Content-Type'] = value;
  836. }
  837. }
  838. function getDefaultAdapter() {
  839. var adapter;
  840. if (typeof XMLHttpRequest !== 'undefined') {
  841. // For browsers use XHR adapter
  842. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  843. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  844. // For node use HTTP adapter
  845. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  846. }
  847. return adapter;
  848. }
  849. var defaults = {
  850. adapter: getDefaultAdapter(),
  851. transformRequest: [function transformRequest(data, headers) {
  852. normalizeHeaderName(headers, 'Accept');
  853. normalizeHeaderName(headers, 'Content-Type');
  854. if (utils.isFormData(data) ||
  855. utils.isArrayBuffer(data) ||
  856. utils.isBuffer(data) ||
  857. utils.isStream(data) ||
  858. utils.isFile(data) ||
  859. utils.isBlob(data)
  860. ) {
  861. return data;
  862. }
  863. if (utils.isArrayBufferView(data)) {
  864. return data.buffer;
  865. }
  866. if (utils.isURLSearchParams(data)) {
  867. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  868. return data.toString();
  869. }
  870. if (utils.isObject(data)) {
  871. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  872. return JSON.stringify(data);
  873. }
  874. return data;
  875. }],
  876. transformResponse: [function transformResponse(data) {
  877. /*eslint no-param-reassign:0*/
  878. if (typeof data === 'string') {
  879. try {
  880. data = JSON.parse(data);
  881. } catch (e) { /* Ignore */ }
  882. }
  883. return data;
  884. }],
  885. /**
  886. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  887. * timeout is not created.
  888. */
  889. timeout: 0,
  890. xsrfCookieName: 'XSRF-TOKEN',
  891. xsrfHeaderName: 'X-XSRF-TOKEN',
  892. maxContentLength: -1,
  893. validateStatus: function validateStatus(status) {
  894. return status >= 200 && status < 300;
  895. }
  896. };
  897. defaults.headers = {
  898. common: {
  899. 'Accept': 'application/json, text/plain, */*'
  900. }
  901. };
  902. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  903. defaults.headers[method] = {};
  904. });
  905. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  906. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  907. });
  908. module.exports = defaults;
  909. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  910. /***/ }),
  911. /***/ "./node_modules/axios/lib/helpers/bind.js":
  912. /*!************************************************!*\
  913. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  914. \************************************************/
  915. /*! no static exports found */
  916. /***/ (function(module, exports, __webpack_require__) {
  917. "use strict";
  918. module.exports = function bind(fn, thisArg) {
  919. return function wrap() {
  920. var args = new Array(arguments.length);
  921. for (var i = 0; i < args.length; i++) {
  922. args[i] = arguments[i];
  923. }
  924. return fn.apply(thisArg, args);
  925. };
  926. };
  927. /***/ }),
  928. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  929. /*!****************************************************!*\
  930. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  931. \****************************************************/
  932. /*! no static exports found */
  933. /***/ (function(module, exports, __webpack_require__) {
  934. "use strict";
  935. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  936. function encode(val) {
  937. return encodeURIComponent(val).
  938. replace(/%40/gi, '@').
  939. replace(/%3A/gi, ':').
  940. replace(/%24/g, '$').
  941. replace(/%2C/gi, ',').
  942. replace(/%20/g, '+').
  943. replace(/%5B/gi, '[').
  944. replace(/%5D/gi, ']');
  945. }
  946. /**
  947. * Build a URL by appending params to the end
  948. *
  949. * @param {string} url The base of the url (e.g., http://www.google.com)
  950. * @param {object} [params] The params to be appended
  951. * @returns {string} The formatted url
  952. */
  953. module.exports = function buildURL(url, params, paramsSerializer) {
  954. /*eslint no-param-reassign:0*/
  955. if (!params) {
  956. return url;
  957. }
  958. var serializedParams;
  959. if (paramsSerializer) {
  960. serializedParams = paramsSerializer(params);
  961. } else if (utils.isURLSearchParams(params)) {
  962. serializedParams = params.toString();
  963. } else {
  964. var parts = [];
  965. utils.forEach(params, function serialize(val, key) {
  966. if (val === null || typeof val === 'undefined') {
  967. return;
  968. }
  969. if (utils.isArray(val)) {
  970. key = key + '[]';
  971. } else {
  972. val = [val];
  973. }
  974. utils.forEach(val, function parseValue(v) {
  975. if (utils.isDate(v)) {
  976. v = v.toISOString();
  977. } else if (utils.isObject(v)) {
  978. v = JSON.stringify(v);
  979. }
  980. parts.push(encode(key) + '=' + encode(v));
  981. });
  982. });
  983. serializedParams = parts.join('&');
  984. }
  985. if (serializedParams) {
  986. var hashmarkIndex = url.indexOf('#');
  987. if (hashmarkIndex !== -1) {
  988. url = url.slice(0, hashmarkIndex);
  989. }
  990. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  991. }
  992. return url;
  993. };
  994. /***/ }),
  995. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  996. /*!*******************************************************!*\
  997. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  998. \*******************************************************/
  999. /*! no static exports found */
  1000. /***/ (function(module, exports, __webpack_require__) {
  1001. "use strict";
  1002. /**
  1003. * Creates a new URL by combining the specified URLs
  1004. *
  1005. * @param {string} baseURL The base URL
  1006. * @param {string} relativeURL The relative URL
  1007. * @returns {string} The combined URL
  1008. */
  1009. module.exports = function combineURLs(baseURL, relativeURL) {
  1010. return relativeURL
  1011. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1012. : baseURL;
  1013. };
  1014. /***/ }),
  1015. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1016. /*!***************************************************!*\
  1017. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1018. \***************************************************/
  1019. /*! no static exports found */
  1020. /***/ (function(module, exports, __webpack_require__) {
  1021. "use strict";
  1022. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1023. module.exports = (
  1024. utils.isStandardBrowserEnv() ?
  1025. // Standard browser envs support document.cookie
  1026. (function standardBrowserEnv() {
  1027. return {
  1028. write: function write(name, value, expires, path, domain, secure) {
  1029. var cookie = [];
  1030. cookie.push(name + '=' + encodeURIComponent(value));
  1031. if (utils.isNumber(expires)) {
  1032. cookie.push('expires=' + new Date(expires).toGMTString());
  1033. }
  1034. if (utils.isString(path)) {
  1035. cookie.push('path=' + path);
  1036. }
  1037. if (utils.isString(domain)) {
  1038. cookie.push('domain=' + domain);
  1039. }
  1040. if (secure === true) {
  1041. cookie.push('secure');
  1042. }
  1043. document.cookie = cookie.join('; ');
  1044. },
  1045. read: function read(name) {
  1046. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1047. return (match ? decodeURIComponent(match[3]) : null);
  1048. },
  1049. remove: function remove(name) {
  1050. this.write(name, '', Date.now() - 86400000);
  1051. }
  1052. };
  1053. })() :
  1054. // Non standard browser env (web workers, react-native) lack needed support.
  1055. (function nonStandardBrowserEnv() {
  1056. return {
  1057. write: function write() {},
  1058. read: function read() { return null; },
  1059. remove: function remove() {}
  1060. };
  1061. })()
  1062. );
  1063. /***/ }),
  1064. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1065. /*!*********************************************************!*\
  1066. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1067. \*********************************************************/
  1068. /*! no static exports found */
  1069. /***/ (function(module, exports, __webpack_require__) {
  1070. "use strict";
  1071. /**
  1072. * Determines whether the specified URL is absolute
  1073. *
  1074. * @param {string} url The URL to test
  1075. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1076. */
  1077. module.exports = function isAbsoluteURL(url) {
  1078. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1079. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1080. // by any combination of letters, digits, plus, period, or hyphen.
  1081. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1082. };
  1083. /***/ }),
  1084. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1085. /*!***********************************************************!*\
  1086. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1087. \***********************************************************/
  1088. /*! no static exports found */
  1089. /***/ (function(module, exports, __webpack_require__) {
  1090. "use strict";
  1091. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1092. module.exports = (
  1093. utils.isStandardBrowserEnv() ?
  1094. // Standard browser envs have full support of the APIs needed to test
  1095. // whether the request URL is of the same origin as current location.
  1096. (function standardBrowserEnv() {
  1097. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1098. var urlParsingNode = document.createElement('a');
  1099. var originURL;
  1100. /**
  1101. * Parse a URL to discover it's components
  1102. *
  1103. * @param {String} url The URL to be parsed
  1104. * @returns {Object}
  1105. */
  1106. function resolveURL(url) {
  1107. var href = url;
  1108. if (msie) {
  1109. // IE needs attribute set twice to normalize properties
  1110. urlParsingNode.setAttribute('href', href);
  1111. href = urlParsingNode.href;
  1112. }
  1113. urlParsingNode.setAttribute('href', href);
  1114. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1115. return {
  1116. href: urlParsingNode.href,
  1117. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1118. host: urlParsingNode.host,
  1119. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1120. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1121. hostname: urlParsingNode.hostname,
  1122. port: urlParsingNode.port,
  1123. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1124. urlParsingNode.pathname :
  1125. '/' + urlParsingNode.pathname
  1126. };
  1127. }
  1128. originURL = resolveURL(window.location.href);
  1129. /**
  1130. * Determine if a URL shares the same origin as the current location
  1131. *
  1132. * @param {String} requestURL The URL to test
  1133. * @returns {boolean} True if URL shares the same origin, otherwise false
  1134. */
  1135. return function isURLSameOrigin(requestURL) {
  1136. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1137. return (parsed.protocol === originURL.protocol &&
  1138. parsed.host === originURL.host);
  1139. };
  1140. })() :
  1141. // Non standard browser envs (web workers, react-native) lack needed support.
  1142. (function nonStandardBrowserEnv() {
  1143. return function isURLSameOrigin() {
  1144. return true;
  1145. };
  1146. })()
  1147. );
  1148. /***/ }),
  1149. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1150. /*!***************************************************************!*\
  1151. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1152. \***************************************************************/
  1153. /*! no static exports found */
  1154. /***/ (function(module, exports, __webpack_require__) {
  1155. "use strict";
  1156. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1157. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1158. utils.forEach(headers, function processHeader(value, name) {
  1159. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1160. headers[normalizedName] = value;
  1161. delete headers[name];
  1162. }
  1163. });
  1164. };
  1165. /***/ }),
  1166. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1167. /*!********************************************************!*\
  1168. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1169. \********************************************************/
  1170. /*! no static exports found */
  1171. /***/ (function(module, exports, __webpack_require__) {
  1172. "use strict";
  1173. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1174. // Headers whose duplicates are ignored by node
  1175. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1176. var ignoreDuplicateOf = [
  1177. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1178. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1179. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1180. 'referer', 'retry-after', 'user-agent'
  1181. ];
  1182. /**
  1183. * Parse headers into an object
  1184. *
  1185. * ```
  1186. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1187. * Content-Type: application/json
  1188. * Connection: keep-alive
  1189. * Transfer-Encoding: chunked
  1190. * ```
  1191. *
  1192. * @param {String} headers Headers needing to be parsed
  1193. * @returns {Object} Headers parsed into an object
  1194. */
  1195. module.exports = function parseHeaders(headers) {
  1196. var parsed = {};
  1197. var key;
  1198. var val;
  1199. var i;
  1200. if (!headers) { return parsed; }
  1201. utils.forEach(headers.split('\n'), function parser(line) {
  1202. i = line.indexOf(':');
  1203. key = utils.trim(line.substr(0, i)).toLowerCase();
  1204. val = utils.trim(line.substr(i + 1));
  1205. if (key) {
  1206. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1207. return;
  1208. }
  1209. if (key === 'set-cookie') {
  1210. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1211. } else {
  1212. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1213. }
  1214. }
  1215. });
  1216. return parsed;
  1217. };
  1218. /***/ }),
  1219. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1220. /*!**************************************************!*\
  1221. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1222. \**************************************************/
  1223. /*! no static exports found */
  1224. /***/ (function(module, exports, __webpack_require__) {
  1225. "use strict";
  1226. /**
  1227. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1228. *
  1229. * Common use case would be to use `Function.prototype.apply`.
  1230. *
  1231. * ```js
  1232. * function f(x, y, z) {}
  1233. * var args = [1, 2, 3];
  1234. * f.apply(null, args);
  1235. * ```
  1236. *
  1237. * With `spread` this example can be re-written.
  1238. *
  1239. * ```js
  1240. * spread(function(x, y, z) {})([1, 2, 3]);
  1241. * ```
  1242. *
  1243. * @param {Function} callback
  1244. * @returns {Function}
  1245. */
  1246. module.exports = function spread(callback) {
  1247. return function wrap(arr) {
  1248. return callback.apply(null, arr);
  1249. };
  1250. };
  1251. /***/ }),
  1252. /***/ "./node_modules/axios/lib/utils.js":
  1253. /*!*****************************************!*\
  1254. !*** ./node_modules/axios/lib/utils.js ***!
  1255. \*****************************************/
  1256. /*! no static exports found */
  1257. /***/ (function(module, exports, __webpack_require__) {
  1258. "use strict";
  1259. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1260. /*global toString:true*/
  1261. // utils is a library of generic helper functions non-specific to axios
  1262. var toString = Object.prototype.toString;
  1263. /**
  1264. * Determine if a value is an Array
  1265. *
  1266. * @param {Object} val The value to test
  1267. * @returns {boolean} True if value is an Array, otherwise false
  1268. */
  1269. function isArray(val) {
  1270. return toString.call(val) === '[object Array]';
  1271. }
  1272. /**
  1273. * Determine if a value is undefined
  1274. *
  1275. * @param {Object} val The value to test
  1276. * @returns {boolean} True if the value is undefined, otherwise false
  1277. */
  1278. function isUndefined(val) {
  1279. return typeof val === 'undefined';
  1280. }
  1281. /**
  1282. * Determine if a value is a Buffer
  1283. *
  1284. * @param {Object} val The value to test
  1285. * @returns {boolean} True if value is a Buffer, otherwise false
  1286. */
  1287. function isBuffer(val) {
  1288. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1289. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1290. }
  1291. /**
  1292. * Determine if a value is an ArrayBuffer
  1293. *
  1294. * @param {Object} val The value to test
  1295. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1296. */
  1297. function isArrayBuffer(val) {
  1298. return toString.call(val) === '[object ArrayBuffer]';
  1299. }
  1300. /**
  1301. * Determine if a value is a FormData
  1302. *
  1303. * @param {Object} val The value to test
  1304. * @returns {boolean} True if value is an FormData, otherwise false
  1305. */
  1306. function isFormData(val) {
  1307. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1308. }
  1309. /**
  1310. * Determine if a value is a view on an ArrayBuffer
  1311. *
  1312. * @param {Object} val The value to test
  1313. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1314. */
  1315. function isArrayBufferView(val) {
  1316. var result;
  1317. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1318. result = ArrayBuffer.isView(val);
  1319. } else {
  1320. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1321. }
  1322. return result;
  1323. }
  1324. /**
  1325. * Determine if a value is a String
  1326. *
  1327. * @param {Object} val The value to test
  1328. * @returns {boolean} True if value is a String, otherwise false
  1329. */
  1330. function isString(val) {
  1331. return typeof val === 'string';
  1332. }
  1333. /**
  1334. * Determine if a value is a Number
  1335. *
  1336. * @param {Object} val The value to test
  1337. * @returns {boolean} True if value is a Number, otherwise false
  1338. */
  1339. function isNumber(val) {
  1340. return typeof val === 'number';
  1341. }
  1342. /**
  1343. * Determine if a value is an Object
  1344. *
  1345. * @param {Object} val The value to test
  1346. * @returns {boolean} True if value is an Object, otherwise false
  1347. */
  1348. function isObject(val) {
  1349. return val !== null && typeof val === 'object';
  1350. }
  1351. /**
  1352. * Determine if a value is a Date
  1353. *
  1354. * @param {Object} val The value to test
  1355. * @returns {boolean} True if value is a Date, otherwise false
  1356. */
  1357. function isDate(val) {
  1358. return toString.call(val) === '[object Date]';
  1359. }
  1360. /**
  1361. * Determine if a value is a File
  1362. *
  1363. * @param {Object} val The value to test
  1364. * @returns {boolean} True if value is a File, otherwise false
  1365. */
  1366. function isFile(val) {
  1367. return toString.call(val) === '[object File]';
  1368. }
  1369. /**
  1370. * Determine if a value is a Blob
  1371. *
  1372. * @param {Object} val The value to test
  1373. * @returns {boolean} True if value is a Blob, otherwise false
  1374. */
  1375. function isBlob(val) {
  1376. return toString.call(val) === '[object Blob]';
  1377. }
  1378. /**
  1379. * Determine if a value is a Function
  1380. *
  1381. * @param {Object} val The value to test
  1382. * @returns {boolean} True if value is a Function, otherwise false
  1383. */
  1384. function isFunction(val) {
  1385. return toString.call(val) === '[object Function]';
  1386. }
  1387. /**
  1388. * Determine if a value is a Stream
  1389. *
  1390. * @param {Object} val The value to test
  1391. * @returns {boolean} True if value is a Stream, otherwise false
  1392. */
  1393. function isStream(val) {
  1394. return isObject(val) && isFunction(val.pipe);
  1395. }
  1396. /**
  1397. * Determine if a value is a URLSearchParams object
  1398. *
  1399. * @param {Object} val The value to test
  1400. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1401. */
  1402. function isURLSearchParams(val) {
  1403. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1404. }
  1405. /**
  1406. * Trim excess whitespace off the beginning and end of a string
  1407. *
  1408. * @param {String} str The String to trim
  1409. * @returns {String} The String freed of excess whitespace
  1410. */
  1411. function trim(str) {
  1412. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1413. }
  1414. /**
  1415. * Determine if we're running in a standard browser environment
  1416. *
  1417. * This allows axios to run in a web worker, and react-native.
  1418. * Both environments support XMLHttpRequest, but not fully standard globals.
  1419. *
  1420. * web workers:
  1421. * typeof window -> undefined
  1422. * typeof document -> undefined
  1423. *
  1424. * react-native:
  1425. * navigator.product -> 'ReactNative'
  1426. * nativescript
  1427. * navigator.product -> 'NativeScript' or 'NS'
  1428. */
  1429. function isStandardBrowserEnv() {
  1430. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1431. navigator.product === 'NativeScript' ||
  1432. navigator.product === 'NS')) {
  1433. return false;
  1434. }
  1435. return (
  1436. typeof window !== 'undefined' &&
  1437. typeof document !== 'undefined'
  1438. );
  1439. }
  1440. /**
  1441. * Iterate over an Array or an Object invoking a function for each item.
  1442. *
  1443. * If `obj` is an Array callback will be called passing
  1444. * the value, index, and complete array for each item.
  1445. *
  1446. * If 'obj' is an Object callback will be called passing
  1447. * the value, key, and complete object for each property.
  1448. *
  1449. * @param {Object|Array} obj The object to iterate
  1450. * @param {Function} fn The callback to invoke for each item
  1451. */
  1452. function forEach(obj, fn) {
  1453. // Don't bother if no value provided
  1454. if (obj === null || typeof obj === 'undefined') {
  1455. return;
  1456. }
  1457. // Force an array if not already something iterable
  1458. if (typeof obj !== 'object') {
  1459. /*eslint no-param-reassign:0*/
  1460. obj = [obj];
  1461. }
  1462. if (isArray(obj)) {
  1463. // Iterate over array values
  1464. for (var i = 0, l = obj.length; i < l; i++) {
  1465. fn.call(null, obj[i], i, obj);
  1466. }
  1467. } else {
  1468. // Iterate over object keys
  1469. for (var key in obj) {
  1470. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1471. fn.call(null, obj[key], key, obj);
  1472. }
  1473. }
  1474. }
  1475. }
  1476. /**
  1477. * Accepts varargs expecting each argument to be an object, then
  1478. * immutably merges the properties of each object and returns result.
  1479. *
  1480. * When multiple objects contain the same key the later object in
  1481. * the arguments list will take precedence.
  1482. *
  1483. * Example:
  1484. *
  1485. * ```js
  1486. * var result = merge({foo: 123}, {foo: 456});
  1487. * console.log(result.foo); // outputs 456
  1488. * ```
  1489. *
  1490. * @param {Object} obj1 Object to merge
  1491. * @returns {Object} Result of all merge properties
  1492. */
  1493. function merge(/* obj1, obj2, obj3, ... */) {
  1494. var result = {};
  1495. function assignValue(val, key) {
  1496. if (typeof result[key] === 'object' && typeof val === 'object') {
  1497. result[key] = merge(result[key], val);
  1498. } else {
  1499. result[key] = val;
  1500. }
  1501. }
  1502. for (var i = 0, l = arguments.length; i < l; i++) {
  1503. forEach(arguments[i], assignValue);
  1504. }
  1505. return result;
  1506. }
  1507. /**
  1508. * Function equal to merge with the difference being that no reference
  1509. * to original objects is kept.
  1510. *
  1511. * @see merge
  1512. * @param {Object} obj1 Object to merge
  1513. * @returns {Object} Result of all merge properties
  1514. */
  1515. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1516. var result = {};
  1517. function assignValue(val, key) {
  1518. if (typeof result[key] === 'object' && typeof val === 'object') {
  1519. result[key] = deepMerge(result[key], val);
  1520. } else if (typeof val === 'object') {
  1521. result[key] = deepMerge({}, val);
  1522. } else {
  1523. result[key] = val;
  1524. }
  1525. }
  1526. for (var i = 0, l = arguments.length; i < l; i++) {
  1527. forEach(arguments[i], assignValue);
  1528. }
  1529. return result;
  1530. }
  1531. /**
  1532. * Extends object a by mutably adding to it the properties of object b.
  1533. *
  1534. * @param {Object} a The object to be extended
  1535. * @param {Object} b The object to copy properties from
  1536. * @param {Object} thisArg The object to bind function to
  1537. * @return {Object} The resulting value of object a
  1538. */
  1539. function extend(a, b, thisArg) {
  1540. forEach(b, function assignValue(val, key) {
  1541. if (thisArg && typeof val === 'function') {
  1542. a[key] = bind(val, thisArg);
  1543. } else {
  1544. a[key] = val;
  1545. }
  1546. });
  1547. return a;
  1548. }
  1549. module.exports = {
  1550. isArray: isArray,
  1551. isArrayBuffer: isArrayBuffer,
  1552. isBuffer: isBuffer,
  1553. isFormData: isFormData,
  1554. isArrayBufferView: isArrayBufferView,
  1555. isString: isString,
  1556. isNumber: isNumber,
  1557. isObject: isObject,
  1558. isUndefined: isUndefined,
  1559. isDate: isDate,
  1560. isFile: isFile,
  1561. isBlob: isBlob,
  1562. isFunction: isFunction,
  1563. isStream: isStream,
  1564. isURLSearchParams: isURLSearchParams,
  1565. isStandardBrowserEnv: isStandardBrowserEnv,
  1566. forEach: forEach,
  1567. merge: merge,
  1568. deepMerge: deepMerge,
  1569. extend: extend,
  1570. trim: trim
  1571. };
  1572. /***/ }),
  1573. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  1574. /*!***************************************************************************************************************************************************************************!*\
  1575. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  1576. \***************************************************************************************************************************************************************************/
  1577. /*! exports provided: default */
  1578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1579. "use strict";
  1580. __webpack_require__.r(__webpack_exports__);
  1581. //
  1582. //
  1583. //
  1584. //
  1585. //
  1586. //
  1587. //
  1588. //
  1589. //
  1590. //
  1591. //
  1592. //
  1593. //
  1594. //
  1595. //
  1596. //
  1597. /* harmony default export */ __webpack_exports__["default"] = ({
  1598. mounted: function mounted() {
  1599. console.log('Component mounted.');
  1600. }
  1601. });
  1602. /***/ }),
  1603. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  1604. /*!********************************************************************************************************************************************************************!*\
  1605. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  1606. \********************************************************************************************************************************************************************/
  1607. /*! exports provided: default */
  1608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1609. "use strict";
  1610. __webpack_require__.r(__webpack_exports__);
  1611. //
  1612. //
  1613. //
  1614. //
  1615. //
  1616. //
  1617. //
  1618. //
  1619. //
  1620. /* harmony default export */ __webpack_exports__["default"] = ({
  1621. props: ['asset'],
  1622. data: function data() {
  1623. return {
  1624. data: JSON.parse(this.asset)
  1625. };
  1626. },
  1627. mounted: function mounted() {
  1628. var _this = this;
  1629. Echo.channel('assets').listen('AssetUpdated', function (e) {
  1630. _this.data = JSON.parse(e.data);
  1631. });
  1632. }
  1633. });
  1634. /***/ }),
  1635. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=script&lang=js&":
  1636. /*!*********************************************************************************************************************************************************************!*\
  1637. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/credential.vue?vue&type=script&lang=js& ***!
  1638. \*********************************************************************************************************************************************************************/
  1639. /*! exports provided: default */
  1640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1641. "use strict";
  1642. __webpack_require__.r(__webpack_exports__);
  1643. //
  1644. //
  1645. //
  1646. //
  1647. //
  1648. //
  1649. //
  1650. //
  1651. //
  1652. //
  1653. //
  1654. //
  1655. //
  1656. //
  1657. //
  1658. //
  1659. //
  1660. //
  1661. //
  1662. //
  1663. //
  1664. //
  1665. //
  1666. //
  1667. //
  1668. //
  1669. //
  1670. //
  1671. //
  1672. //
  1673. /* harmony default export */ __webpack_exports__["default"] = ({
  1674. props: ['credential'],
  1675. data: function data() {
  1676. return {
  1677. data: JSON.parse(this.credential)
  1678. };
  1679. },
  1680. mounted: function mounted() {
  1681. var _this = this;
  1682. Echo.channel('credentials').listen('CredentialUpdated', function (e) {
  1683. _this.data = JSON.parse(e.data);
  1684. });
  1685. }
  1686. });
  1687. /***/ }),
  1688. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/notes.vue?vue&type=script&lang=js&":
  1689. /*!****************************************************************************************************************************************************************!*\
  1690. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/notes.vue?vue&type=script&lang=js& ***!
  1691. \****************************************************************************************************************************************************************/
  1692. /*! exports provided: default */
  1693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1694. "use strict";
  1695. __webpack_require__.r(__webpack_exports__);
  1696. /* harmony import */ var _mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mixins/dateMixin */ "./resources/js/mixins/dateMixin.js");
  1697. //
  1698. //
  1699. //
  1700. //
  1701. //
  1702. //
  1703. //
  1704. //
  1705. //
  1706. //
  1707. //
  1708. //
  1709. //
  1710. //
  1711. //
  1712. //
  1713. //
  1714. //
  1715. //
  1716. //
  1717. //
  1718. //
  1719. //
  1720. //
  1721. /* harmony default export */ __webpack_exports__["default"] = ({
  1722. mixins: [_mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__["default"]],
  1723. props: ['initialnotes', 'authusername'],
  1724. data: function data() {
  1725. return {
  1726. notes: this.initialnotes
  1727. };
  1728. }
  1729. });
  1730. /***/ }),
  1731. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  1732. /*!*****************************************************************************************************************************************************************!*\
  1733. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  1734. \*****************************************************************************************************************************************************************/
  1735. /*! exports provided: default */
  1736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1737. "use strict";
  1738. __webpack_require__.r(__webpack_exports__);
  1739. /* harmony import */ var _mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mixins/dateMixin */ "./resources/js/mixins/dateMixin.js");
  1740. //
  1741. //
  1742. //
  1743. //
  1744. //
  1745. //
  1746. //
  1747. //
  1748. //
  1749. //
  1750. //
  1751. //
  1752. //
  1753. //
  1754. //
  1755. //
  1756. //
  1757. //
  1758. /* harmony default export */ __webpack_exports__["default"] = ({
  1759. mixins: [_mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__["default"]],
  1760. props: ['workOrder'],
  1761. data: function data() {
  1762. return {
  1763. data: JSON.parse(this.workOrder)
  1764. };
  1765. },
  1766. mounted: function mounted() {
  1767. var _this = this;
  1768. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1769. _this.data = JSON.parse(e.data);
  1770. });
  1771. }
  1772. });
  1773. /***/ }),
  1774. /***/ "./node_modules/base64-js/index.js":
  1775. /*!*****************************************!*\
  1776. !*** ./node_modules/base64-js/index.js ***!
  1777. \*****************************************/
  1778. /*! no static exports found */
  1779. /***/ (function(module, exports, __webpack_require__) {
  1780. "use strict";
  1781. exports.byteLength = byteLength
  1782. exports.toByteArray = toByteArray
  1783. exports.fromByteArray = fromByteArray
  1784. var lookup = []
  1785. var revLookup = []
  1786. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1787. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1788. for (var i = 0, len = code.length; i < len; ++i) {
  1789. lookup[i] = code[i]
  1790. revLookup[code.charCodeAt(i)] = i
  1791. }
  1792. // Support decoding URL-safe base64 strings, as Node.js does.
  1793. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1794. revLookup['-'.charCodeAt(0)] = 62
  1795. revLookup['_'.charCodeAt(0)] = 63
  1796. function getLens (b64) {
  1797. var len = b64.length
  1798. if (len % 4 > 0) {
  1799. throw new Error('Invalid string. Length must be a multiple of 4')
  1800. }
  1801. // Trim off extra bytes after placeholder bytes are found
  1802. // See: https://github.com/beatgammit/base64-js/issues/42
  1803. var validLen = b64.indexOf('=')
  1804. if (validLen === -1) validLen = len
  1805. var placeHoldersLen = validLen === len
  1806. ? 0
  1807. : 4 - (validLen % 4)
  1808. return [validLen, placeHoldersLen]
  1809. }
  1810. // base64 is 4/3 + up to two characters of the original data
  1811. function byteLength (b64) {
  1812. var lens = getLens(b64)
  1813. var validLen = lens[0]
  1814. var placeHoldersLen = lens[1]
  1815. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1816. }
  1817. function _byteLength (b64, validLen, placeHoldersLen) {
  1818. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1819. }
  1820. function toByteArray (b64) {
  1821. var tmp
  1822. var lens = getLens(b64)
  1823. var validLen = lens[0]
  1824. var placeHoldersLen = lens[1]
  1825. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1826. var curByte = 0
  1827. // if there are placeholders, only get up to the last complete 4 chars
  1828. var len = placeHoldersLen > 0
  1829. ? validLen - 4
  1830. : validLen
  1831. var i
  1832. for (i = 0; i < len; i += 4) {
  1833. tmp =
  1834. (revLookup[b64.charCodeAt(i)] << 18) |
  1835. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1836. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1837. revLookup[b64.charCodeAt(i + 3)]
  1838. arr[curByte++] = (tmp >> 16) & 0xFF
  1839. arr[curByte++] = (tmp >> 8) & 0xFF
  1840. arr[curByte++] = tmp & 0xFF
  1841. }
  1842. if (placeHoldersLen === 2) {
  1843. tmp =
  1844. (revLookup[b64.charCodeAt(i)] << 2) |
  1845. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1846. arr[curByte++] = tmp & 0xFF
  1847. }
  1848. if (placeHoldersLen === 1) {
  1849. tmp =
  1850. (revLookup[b64.charCodeAt(i)] << 10) |
  1851. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1852. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1853. arr[curByte++] = (tmp >> 8) & 0xFF
  1854. arr[curByte++] = tmp & 0xFF
  1855. }
  1856. return arr
  1857. }
  1858. function tripletToBase64 (num) {
  1859. return lookup[num >> 18 & 0x3F] +
  1860. lookup[num >> 12 & 0x3F] +
  1861. lookup[num >> 6 & 0x3F] +
  1862. lookup[num & 0x3F]
  1863. }
  1864. function encodeChunk (uint8, start, end) {
  1865. var tmp
  1866. var output = []
  1867. for (var i = start; i < end; i += 3) {
  1868. tmp =
  1869. ((uint8[i] << 16) & 0xFF0000) +
  1870. ((uint8[i + 1] << 8) & 0xFF00) +
  1871. (uint8[i + 2] & 0xFF)
  1872. output.push(tripletToBase64(tmp))
  1873. }
  1874. return output.join('')
  1875. }
  1876. function fromByteArray (uint8) {
  1877. var tmp
  1878. var len = uint8.length
  1879. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1880. var parts = []
  1881. var maxChunkLength = 16383 // must be multiple of 3
  1882. // go through the array every three bytes, we'll deal with trailing stuff later
  1883. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1884. parts.push(encodeChunk(
  1885. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1886. ))
  1887. }
  1888. // pad the end with zeros, but make sure to not forget the extra bytes
  1889. if (extraBytes === 1) {
  1890. tmp = uint8[len - 1]
  1891. parts.push(
  1892. lookup[tmp >> 2] +
  1893. lookup[(tmp << 4) & 0x3F] +
  1894. '=='
  1895. )
  1896. } else if (extraBytes === 2) {
  1897. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1898. parts.push(
  1899. lookup[tmp >> 10] +
  1900. lookup[(tmp >> 4) & 0x3F] +
  1901. lookup[(tmp << 2) & 0x3F] +
  1902. '='
  1903. )
  1904. }
  1905. return parts.join('')
  1906. }
  1907. /***/ }),
  1908. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1909. /*!*****************************************************!*\
  1910. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1911. \*****************************************************/
  1912. /*! no static exports found */
  1913. /***/ (function(module, exports, __webpack_require__) {
  1914. /*!
  1915. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1916. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1917. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1918. */
  1919. (function (global, factory) {
  1920. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1921. undefined;
  1922. }(this, (function (exports, $, Popper) { 'use strict';
  1923. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1924. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1925. function _defineProperties(target, props) {
  1926. for (var i = 0; i < props.length; i++) {
  1927. var descriptor = props[i];
  1928. descriptor.enumerable = descriptor.enumerable || false;
  1929. descriptor.configurable = true;
  1930. if ("value" in descriptor) descriptor.writable = true;
  1931. Object.defineProperty(target, descriptor.key, descriptor);
  1932. }
  1933. }
  1934. function _createClass(Constructor, protoProps, staticProps) {
  1935. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1936. if (staticProps) _defineProperties(Constructor, staticProps);
  1937. return Constructor;
  1938. }
  1939. function _defineProperty(obj, key, value) {
  1940. if (key in obj) {
  1941. Object.defineProperty(obj, key, {
  1942. value: value,
  1943. enumerable: true,
  1944. configurable: true,
  1945. writable: true
  1946. });
  1947. } else {
  1948. obj[key] = value;
  1949. }
  1950. return obj;
  1951. }
  1952. function ownKeys(object, enumerableOnly) {
  1953. var keys = Object.keys(object);
  1954. if (Object.getOwnPropertySymbols) {
  1955. var symbols = Object.getOwnPropertySymbols(object);
  1956. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1957. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1958. });
  1959. keys.push.apply(keys, symbols);
  1960. }
  1961. return keys;
  1962. }
  1963. function _objectSpread2(target) {
  1964. for (var i = 1; i < arguments.length; i++) {
  1965. var source = arguments[i] != null ? arguments[i] : {};
  1966. if (i % 2) {
  1967. ownKeys(Object(source), true).forEach(function (key) {
  1968. _defineProperty(target, key, source[key]);
  1969. });
  1970. } else if (Object.getOwnPropertyDescriptors) {
  1971. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1972. } else {
  1973. ownKeys(Object(source)).forEach(function (key) {
  1974. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1975. });
  1976. }
  1977. }
  1978. return target;
  1979. }
  1980. function _inheritsLoose(subClass, superClass) {
  1981. subClass.prototype = Object.create(superClass.prototype);
  1982. subClass.prototype.constructor = subClass;
  1983. subClass.__proto__ = superClass;
  1984. }
  1985. /**
  1986. * --------------------------------------------------------------------------
  1987. * Bootstrap (v4.4.1): util.js
  1988. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1989. * --------------------------------------------------------------------------
  1990. */
  1991. /**
  1992. * ------------------------------------------------------------------------
  1993. * Private TransitionEnd Helpers
  1994. * ------------------------------------------------------------------------
  1995. */
  1996. var TRANSITION_END = 'transitionend';
  1997. var MAX_UID = 1000000;
  1998. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1999. function toType(obj) {
  2000. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  2001. }
  2002. function getSpecialTransitionEndEvent() {
  2003. return {
  2004. bindType: TRANSITION_END,
  2005. delegateType: TRANSITION_END,
  2006. handle: function handle(event) {
  2007. if ($(event.target).is(this)) {
  2008. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  2009. }
  2010. return undefined; // eslint-disable-line no-undefined
  2011. }
  2012. };
  2013. }
  2014. function transitionEndEmulator(duration) {
  2015. var _this = this;
  2016. var called = false;
  2017. $(this).one(Util.TRANSITION_END, function () {
  2018. called = true;
  2019. });
  2020. setTimeout(function () {
  2021. if (!called) {
  2022. Util.triggerTransitionEnd(_this);
  2023. }
  2024. }, duration);
  2025. return this;
  2026. }
  2027. function setTransitionEndSupport() {
  2028. $.fn.emulateTransitionEnd = transitionEndEmulator;
  2029. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  2030. }
  2031. /**
  2032. * --------------------------------------------------------------------------
  2033. * Public Util Api
  2034. * --------------------------------------------------------------------------
  2035. */
  2036. var Util = {
  2037. TRANSITION_END: 'bsTransitionEnd',
  2038. getUID: function getUID(prefix) {
  2039. do {
  2040. // eslint-disable-next-line no-bitwise
  2041. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  2042. } while (document.getElementById(prefix));
  2043. return prefix;
  2044. },
  2045. getSelectorFromElement: function getSelectorFromElement(element) {
  2046. var selector = element.getAttribute('data-target');
  2047. if (!selector || selector === '#') {
  2048. var hrefAttr = element.getAttribute('href');
  2049. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  2050. }
  2051. try {
  2052. return document.querySelector(selector) ? selector : null;
  2053. } catch (err) {
  2054. return null;
  2055. }
  2056. },
  2057. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  2058. if (!element) {
  2059. return 0;
  2060. } // Get transition-duration of the element
  2061. var transitionDuration = $(element).css('transition-duration');
  2062. var transitionDelay = $(element).css('transition-delay');
  2063. var floatTransitionDuration = parseFloat(transitionDuration);
  2064. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  2065. if (!floatTransitionDuration && !floatTransitionDelay) {
  2066. return 0;
  2067. } // If multiple durations are defined, take the first
  2068. transitionDuration = transitionDuration.split(',')[0];
  2069. transitionDelay = transitionDelay.split(',')[0];
  2070. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  2071. },
  2072. reflow: function reflow(element) {
  2073. return element.offsetHeight;
  2074. },
  2075. triggerTransitionEnd: function triggerTransitionEnd(element) {
  2076. $(element).trigger(TRANSITION_END);
  2077. },
  2078. // TODO: Remove in v5
  2079. supportsTransitionEnd: function supportsTransitionEnd() {
  2080. return Boolean(TRANSITION_END);
  2081. },
  2082. isElement: function isElement(obj) {
  2083. return (obj[0] || obj).nodeType;
  2084. },
  2085. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  2086. for (var property in configTypes) {
  2087. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  2088. var expectedTypes = configTypes[property];
  2089. var value = config[property];
  2090. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  2091. if (!new RegExp(expectedTypes).test(valueType)) {
  2092. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  2093. }
  2094. }
  2095. }
  2096. },
  2097. findShadowRoot: function findShadowRoot(element) {
  2098. if (!document.documentElement.attachShadow) {
  2099. return null;
  2100. } // Can find the shadow root otherwise it'll return the document
  2101. if (typeof element.getRootNode === 'function') {
  2102. var root = element.getRootNode();
  2103. return root instanceof ShadowRoot ? root : null;
  2104. }
  2105. if (element instanceof ShadowRoot) {
  2106. return element;
  2107. } // when we don't find a shadow root
  2108. if (!element.parentNode) {
  2109. return null;
  2110. }
  2111. return Util.findShadowRoot(element.parentNode);
  2112. },
  2113. jQueryDetection: function jQueryDetection() {
  2114. if (typeof $ === 'undefined') {
  2115. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2116. }
  2117. var version = $.fn.jquery.split(' ')[0].split('.');
  2118. var minMajor = 1;
  2119. var ltMajor = 2;
  2120. var minMinor = 9;
  2121. var minPatch = 1;
  2122. var maxMajor = 4;
  2123. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2124. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2125. }
  2126. }
  2127. };
  2128. Util.jQueryDetection();
  2129. setTransitionEndSupport();
  2130. /**
  2131. * ------------------------------------------------------------------------
  2132. * Constants
  2133. * ------------------------------------------------------------------------
  2134. */
  2135. var NAME = 'alert';
  2136. var VERSION = '4.4.1';
  2137. var DATA_KEY = 'bs.alert';
  2138. var EVENT_KEY = "." + DATA_KEY;
  2139. var DATA_API_KEY = '.data-api';
  2140. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2141. var Selector = {
  2142. DISMISS: '[data-dismiss="alert"]'
  2143. };
  2144. var Event = {
  2145. CLOSE: "close" + EVENT_KEY,
  2146. CLOSED: "closed" + EVENT_KEY,
  2147. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2148. };
  2149. var ClassName = {
  2150. ALERT: 'alert',
  2151. FADE: 'fade',
  2152. SHOW: 'show'
  2153. };
  2154. /**
  2155. * ------------------------------------------------------------------------
  2156. * Class Definition
  2157. * ------------------------------------------------------------------------
  2158. */
  2159. var Alert =
  2160. /*#__PURE__*/
  2161. function () {
  2162. function Alert(element) {
  2163. this._element = element;
  2164. } // Getters
  2165. var _proto = Alert.prototype;
  2166. // Public
  2167. _proto.close = function close(element) {
  2168. var rootElement = this._element;
  2169. if (element) {
  2170. rootElement = this._getRootElement(element);
  2171. }
  2172. var customEvent = this._triggerCloseEvent(rootElement);
  2173. if (customEvent.isDefaultPrevented()) {
  2174. return;
  2175. }
  2176. this._removeElement(rootElement);
  2177. };
  2178. _proto.dispose = function dispose() {
  2179. $.removeData(this._element, DATA_KEY);
  2180. this._element = null;
  2181. } // Private
  2182. ;
  2183. _proto._getRootElement = function _getRootElement(element) {
  2184. var selector = Util.getSelectorFromElement(element);
  2185. var parent = false;
  2186. if (selector) {
  2187. parent = document.querySelector(selector);
  2188. }
  2189. if (!parent) {
  2190. parent = $(element).closest("." + ClassName.ALERT)[0];
  2191. }
  2192. return parent;
  2193. };
  2194. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2195. var closeEvent = $.Event(Event.CLOSE);
  2196. $(element).trigger(closeEvent);
  2197. return closeEvent;
  2198. };
  2199. _proto._removeElement = function _removeElement(element) {
  2200. var _this = this;
  2201. $(element).removeClass(ClassName.SHOW);
  2202. if (!$(element).hasClass(ClassName.FADE)) {
  2203. this._destroyElement(element);
  2204. return;
  2205. }
  2206. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2207. $(element).one(Util.TRANSITION_END, function (event) {
  2208. return _this._destroyElement(element, event);
  2209. }).emulateTransitionEnd(transitionDuration);
  2210. };
  2211. _proto._destroyElement = function _destroyElement(element) {
  2212. $(element).detach().trigger(Event.CLOSED).remove();
  2213. } // Static
  2214. ;
  2215. Alert._jQueryInterface = function _jQueryInterface(config) {
  2216. return this.each(function () {
  2217. var $element = $(this);
  2218. var data = $element.data(DATA_KEY);
  2219. if (!data) {
  2220. data = new Alert(this);
  2221. $element.data(DATA_KEY, data);
  2222. }
  2223. if (config === 'close') {
  2224. data[config](this);
  2225. }
  2226. });
  2227. };
  2228. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2229. return function (event) {
  2230. if (event) {
  2231. event.preventDefault();
  2232. }
  2233. alertInstance.close(this);
  2234. };
  2235. };
  2236. _createClass(Alert, null, [{
  2237. key: "VERSION",
  2238. get: function get() {
  2239. return VERSION;
  2240. }
  2241. }]);
  2242. return Alert;
  2243. }();
  2244. /**
  2245. * ------------------------------------------------------------------------
  2246. * Data Api implementation
  2247. * ------------------------------------------------------------------------
  2248. */
  2249. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2250. /**
  2251. * ------------------------------------------------------------------------
  2252. * jQuery
  2253. * ------------------------------------------------------------------------
  2254. */
  2255. $.fn[NAME] = Alert._jQueryInterface;
  2256. $.fn[NAME].Constructor = Alert;
  2257. $.fn[NAME].noConflict = function () {
  2258. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2259. return Alert._jQueryInterface;
  2260. };
  2261. /**
  2262. * ------------------------------------------------------------------------
  2263. * Constants
  2264. * ------------------------------------------------------------------------
  2265. */
  2266. var NAME$1 = 'button';
  2267. var VERSION$1 = '4.4.1';
  2268. var DATA_KEY$1 = 'bs.button';
  2269. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2270. var DATA_API_KEY$1 = '.data-api';
  2271. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2272. var ClassName$1 = {
  2273. ACTIVE: 'active',
  2274. BUTTON: 'btn',
  2275. FOCUS: 'focus'
  2276. };
  2277. var Selector$1 = {
  2278. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2279. DATA_TOGGLES: '[data-toggle="buttons"]',
  2280. DATA_TOGGLE: '[data-toggle="button"]',
  2281. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2282. INPUT: 'input:not([type="hidden"])',
  2283. ACTIVE: '.active',
  2284. BUTTON: '.btn'
  2285. };
  2286. var Event$1 = {
  2287. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2288. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2289. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2290. };
  2291. /**
  2292. * ------------------------------------------------------------------------
  2293. * Class Definition
  2294. * ------------------------------------------------------------------------
  2295. */
  2296. var Button =
  2297. /*#__PURE__*/
  2298. function () {
  2299. function Button(element) {
  2300. this._element = element;
  2301. } // Getters
  2302. var _proto = Button.prototype;
  2303. // Public
  2304. _proto.toggle = function toggle() {
  2305. var triggerChangeEvent = true;
  2306. var addAriaPressed = true;
  2307. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2308. if (rootElement) {
  2309. var input = this._element.querySelector(Selector$1.INPUT);
  2310. if (input) {
  2311. if (input.type === 'radio') {
  2312. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2313. triggerChangeEvent = false;
  2314. } else {
  2315. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2316. if (activeElement) {
  2317. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2318. }
  2319. }
  2320. } else if (input.type === 'checkbox') {
  2321. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2322. triggerChangeEvent = false;
  2323. }
  2324. } else {
  2325. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2326. triggerChangeEvent = false;
  2327. }
  2328. if (triggerChangeEvent) {
  2329. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2330. $(input).trigger('change');
  2331. }
  2332. input.focus();
  2333. addAriaPressed = false;
  2334. }
  2335. }
  2336. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2337. if (addAriaPressed) {
  2338. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2339. }
  2340. if (triggerChangeEvent) {
  2341. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2342. }
  2343. }
  2344. };
  2345. _proto.dispose = function dispose() {
  2346. $.removeData(this._element, DATA_KEY$1);
  2347. this._element = null;
  2348. } // Static
  2349. ;
  2350. Button._jQueryInterface = function _jQueryInterface(config) {
  2351. return this.each(function () {
  2352. var data = $(this).data(DATA_KEY$1);
  2353. if (!data) {
  2354. data = new Button(this);
  2355. $(this).data(DATA_KEY$1, data);
  2356. }
  2357. if (config === 'toggle') {
  2358. data[config]();
  2359. }
  2360. });
  2361. };
  2362. _createClass(Button, null, [{
  2363. key: "VERSION",
  2364. get: function get() {
  2365. return VERSION$1;
  2366. }
  2367. }]);
  2368. return Button;
  2369. }();
  2370. /**
  2371. * ------------------------------------------------------------------------
  2372. * Data Api implementation
  2373. * ------------------------------------------------------------------------
  2374. */
  2375. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2376. var button = event.target;
  2377. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2378. button = $(button).closest(Selector$1.BUTTON)[0];
  2379. }
  2380. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2381. event.preventDefault(); // work around Firefox bug #1540995
  2382. } else {
  2383. var inputBtn = button.querySelector(Selector$1.INPUT);
  2384. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2385. event.preventDefault(); // work around Firefox bug #1540995
  2386. return;
  2387. }
  2388. Button._jQueryInterface.call($(button), 'toggle');
  2389. }
  2390. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2391. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2392. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2393. });
  2394. $(window).on(Event$1.LOAD_DATA_API, function () {
  2395. // ensure correct active class is set to match the controls' actual values/states
  2396. // find all checkboxes/readio buttons inside data-toggle groups
  2397. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2398. for (var i = 0, len = buttons.length; i < len; i++) {
  2399. var button = buttons[i];
  2400. var input = button.querySelector(Selector$1.INPUT);
  2401. if (input.checked || input.hasAttribute('checked')) {
  2402. button.classList.add(ClassName$1.ACTIVE);
  2403. } else {
  2404. button.classList.remove(ClassName$1.ACTIVE);
  2405. }
  2406. } // find all button toggles
  2407. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2408. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2409. var _button = buttons[_i];
  2410. if (_button.getAttribute('aria-pressed') === 'true') {
  2411. _button.classList.add(ClassName$1.ACTIVE);
  2412. } else {
  2413. _button.classList.remove(ClassName$1.ACTIVE);
  2414. }
  2415. }
  2416. });
  2417. /**
  2418. * ------------------------------------------------------------------------
  2419. * jQuery
  2420. * ------------------------------------------------------------------------
  2421. */
  2422. $.fn[NAME$1] = Button._jQueryInterface;
  2423. $.fn[NAME$1].Constructor = Button;
  2424. $.fn[NAME$1].noConflict = function () {
  2425. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2426. return Button._jQueryInterface;
  2427. };
  2428. /**
  2429. * ------------------------------------------------------------------------
  2430. * Constants
  2431. * ------------------------------------------------------------------------
  2432. */
  2433. var NAME$2 = 'carousel';
  2434. var VERSION$2 = '4.4.1';
  2435. var DATA_KEY$2 = 'bs.carousel';
  2436. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2437. var DATA_API_KEY$2 = '.data-api';
  2438. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2439. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2440. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2441. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2442. var SWIPE_THRESHOLD = 40;
  2443. var Default = {
  2444. interval: 5000,
  2445. keyboard: true,
  2446. slide: false,
  2447. pause: 'hover',
  2448. wrap: true,
  2449. touch: true
  2450. };
  2451. var DefaultType = {
  2452. interval: '(number|boolean)',
  2453. keyboard: 'boolean',
  2454. slide: '(boolean|string)',
  2455. pause: '(string|boolean)',
  2456. wrap: 'boolean',
  2457. touch: 'boolean'
  2458. };
  2459. var Direction = {
  2460. NEXT: 'next',
  2461. PREV: 'prev',
  2462. LEFT: 'left',
  2463. RIGHT: 'right'
  2464. };
  2465. var Event$2 = {
  2466. SLIDE: "slide" + EVENT_KEY$2,
  2467. SLID: "slid" + EVENT_KEY$2,
  2468. KEYDOWN: "keydown" + EVENT_KEY$2,
  2469. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2470. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2471. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2472. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2473. TOUCHEND: "touchend" + EVENT_KEY$2,
  2474. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2475. POINTERUP: "pointerup" + EVENT_KEY$2,
  2476. DRAG_START: "dragstart" + EVENT_KEY$2,
  2477. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2478. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2479. };
  2480. var ClassName$2 = {
  2481. CAROUSEL: 'carousel',
  2482. ACTIVE: 'active',
  2483. SLIDE: 'slide',
  2484. RIGHT: 'carousel-item-right',
  2485. LEFT: 'carousel-item-left',
  2486. NEXT: 'carousel-item-next',
  2487. PREV: 'carousel-item-prev',
  2488. ITEM: 'carousel-item',
  2489. POINTER_EVENT: 'pointer-event'
  2490. };
  2491. var Selector$2 = {
  2492. ACTIVE: '.active',
  2493. ACTIVE_ITEM: '.active.carousel-item',
  2494. ITEM: '.carousel-item',
  2495. ITEM_IMG: '.carousel-item img',
  2496. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2497. INDICATORS: '.carousel-indicators',
  2498. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2499. DATA_RIDE: '[data-ride="carousel"]'
  2500. };
  2501. var PointerType = {
  2502. TOUCH: 'touch',
  2503. PEN: 'pen'
  2504. };
  2505. /**
  2506. * ------------------------------------------------------------------------
  2507. * Class Definition
  2508. * ------------------------------------------------------------------------
  2509. */
  2510. var Carousel =
  2511. /*#__PURE__*/
  2512. function () {
  2513. function Carousel(element, config) {
  2514. this._items = null;
  2515. this._interval = null;
  2516. this._activeElement = null;
  2517. this._isPaused = false;
  2518. this._isSliding = false;
  2519. this.touchTimeout = null;
  2520. this.touchStartX = 0;
  2521. this.touchDeltaX = 0;
  2522. this._config = this._getConfig(config);
  2523. this._element = element;
  2524. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2525. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2526. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2527. this._addEventListeners();
  2528. } // Getters
  2529. var _proto = Carousel.prototype;
  2530. // Public
  2531. _proto.next = function next() {
  2532. if (!this._isSliding) {
  2533. this._slide(Direction.NEXT);
  2534. }
  2535. };
  2536. _proto.nextWhenVisible = function nextWhenVisible() {
  2537. // Don't call next when the page isn't visible
  2538. // or the carousel or its parent isn't visible
  2539. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2540. this.next();
  2541. }
  2542. };
  2543. _proto.prev = function prev() {
  2544. if (!this._isSliding) {
  2545. this._slide(Direction.PREV);
  2546. }
  2547. };
  2548. _proto.pause = function pause(event) {
  2549. if (!event) {
  2550. this._isPaused = true;
  2551. }
  2552. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2553. Util.triggerTransitionEnd(this._element);
  2554. this.cycle(true);
  2555. }
  2556. clearInterval(this._interval);
  2557. this._interval = null;
  2558. };
  2559. _proto.cycle = function cycle(event) {
  2560. if (!event) {
  2561. this._isPaused = false;
  2562. }
  2563. if (this._interval) {
  2564. clearInterval(this._interval);
  2565. this._interval = null;
  2566. }
  2567. if (this._config.interval && !this._isPaused) {
  2568. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2569. }
  2570. };
  2571. _proto.to = function to(index) {
  2572. var _this = this;
  2573. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2574. var activeIndex = this._getItemIndex(this._activeElement);
  2575. if (index > this._items.length - 1 || index < 0) {
  2576. return;
  2577. }
  2578. if (this._isSliding) {
  2579. $(this._element).one(Event$2.SLID, function () {
  2580. return _this.to(index);
  2581. });
  2582. return;
  2583. }
  2584. if (activeIndex === index) {
  2585. this.pause();
  2586. this.cycle();
  2587. return;
  2588. }
  2589. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2590. this._slide(direction, this._items[index]);
  2591. };
  2592. _proto.dispose = function dispose() {
  2593. $(this._element).off(EVENT_KEY$2);
  2594. $.removeData(this._element, DATA_KEY$2);
  2595. this._items = null;
  2596. this._config = null;
  2597. this._element = null;
  2598. this._interval = null;
  2599. this._isPaused = null;
  2600. this._isSliding = null;
  2601. this._activeElement = null;
  2602. this._indicatorsElement = null;
  2603. } // Private
  2604. ;
  2605. _proto._getConfig = function _getConfig(config) {
  2606. config = _objectSpread2({}, Default, {}, config);
  2607. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2608. return config;
  2609. };
  2610. _proto._handleSwipe = function _handleSwipe() {
  2611. var absDeltax = Math.abs(this.touchDeltaX);
  2612. if (absDeltax <= SWIPE_THRESHOLD) {
  2613. return;
  2614. }
  2615. var direction = absDeltax / this.touchDeltaX;
  2616. this.touchDeltaX = 0; // swipe left
  2617. if (direction > 0) {
  2618. this.prev();
  2619. } // swipe right
  2620. if (direction < 0) {
  2621. this.next();
  2622. }
  2623. };
  2624. _proto._addEventListeners = function _addEventListeners() {
  2625. var _this2 = this;
  2626. if (this._config.keyboard) {
  2627. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2628. return _this2._keydown(event);
  2629. });
  2630. }
  2631. if (this._config.pause === 'hover') {
  2632. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2633. return _this2.pause(event);
  2634. }).on(Event$2.MOUSELEAVE, function (event) {
  2635. return _this2.cycle(event);
  2636. });
  2637. }
  2638. if (this._config.touch) {
  2639. this._addTouchEventListeners();
  2640. }
  2641. };
  2642. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2643. var _this3 = this;
  2644. if (!this._touchSupported) {
  2645. return;
  2646. }
  2647. var start = function start(event) {
  2648. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2649. _this3.touchStartX = event.originalEvent.clientX;
  2650. } else if (!_this3._pointerEvent) {
  2651. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2652. }
  2653. };
  2654. var move = function move(event) {
  2655. // ensure swiping with one touch and not pinching
  2656. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2657. _this3.touchDeltaX = 0;
  2658. } else {
  2659. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2660. }
  2661. };
  2662. var end = function end(event) {
  2663. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2664. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2665. }
  2666. _this3._handleSwipe();
  2667. if (_this3._config.pause === 'hover') {
  2668. // If it's a touch-enabled device, mouseenter/leave are fired as
  2669. // part of the mouse compatibility events on first tap - the carousel
  2670. // would stop cycling until user tapped out of it;
  2671. // here, we listen for touchend, explicitly pause the carousel
  2672. // (as if it's the second time we tap on it, mouseenter compat event
  2673. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2674. // events to fire) we explicitly restart cycling
  2675. _this3.pause();
  2676. if (_this3.touchTimeout) {
  2677. clearTimeout(_this3.touchTimeout);
  2678. }
  2679. _this3.touchTimeout = setTimeout(function (event) {
  2680. return _this3.cycle(event);
  2681. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2682. }
  2683. };
  2684. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2685. return e.preventDefault();
  2686. });
  2687. if (this._pointerEvent) {
  2688. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2689. return start(event);
  2690. });
  2691. $(this._element).on(Event$2.POINTERUP, function (event) {
  2692. return end(event);
  2693. });
  2694. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2695. } else {
  2696. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2697. return start(event);
  2698. });
  2699. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2700. return move(event);
  2701. });
  2702. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2703. return end(event);
  2704. });
  2705. }
  2706. };
  2707. _proto._keydown = function _keydown(event) {
  2708. if (/input|textarea/i.test(event.target.tagName)) {
  2709. return;
  2710. }
  2711. switch (event.which) {
  2712. case ARROW_LEFT_KEYCODE:
  2713. event.preventDefault();
  2714. this.prev();
  2715. break;
  2716. case ARROW_RIGHT_KEYCODE:
  2717. event.preventDefault();
  2718. this.next();
  2719. break;
  2720. }
  2721. };
  2722. _proto._getItemIndex = function _getItemIndex(element) {
  2723. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2724. return this._items.indexOf(element);
  2725. };
  2726. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2727. var isNextDirection = direction === Direction.NEXT;
  2728. var isPrevDirection = direction === Direction.PREV;
  2729. var activeIndex = this._getItemIndex(activeElement);
  2730. var lastItemIndex = this._items.length - 1;
  2731. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2732. if (isGoingToWrap && !this._config.wrap) {
  2733. return activeElement;
  2734. }
  2735. var delta = direction === Direction.PREV ? -1 : 1;
  2736. var itemIndex = (activeIndex + delta) % this._items.length;
  2737. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2738. };
  2739. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2740. var targetIndex = this._getItemIndex(relatedTarget);
  2741. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2742. var slideEvent = $.Event(Event$2.SLIDE, {
  2743. relatedTarget: relatedTarget,
  2744. direction: eventDirectionName,
  2745. from: fromIndex,
  2746. to: targetIndex
  2747. });
  2748. $(this._element).trigger(slideEvent);
  2749. return slideEvent;
  2750. };
  2751. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2752. if (this._indicatorsElement) {
  2753. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2754. $(indicators).removeClass(ClassName$2.ACTIVE);
  2755. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2756. if (nextIndicator) {
  2757. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2758. }
  2759. }
  2760. };
  2761. _proto._slide = function _slide(direction, element) {
  2762. var _this4 = this;
  2763. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2764. var activeElementIndex = this._getItemIndex(activeElement);
  2765. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2766. var nextElementIndex = this._getItemIndex(nextElement);
  2767. var isCycling = Boolean(this._interval);
  2768. var directionalClassName;
  2769. var orderClassName;
  2770. var eventDirectionName;
  2771. if (direction === Direction.NEXT) {
  2772. directionalClassName = ClassName$2.LEFT;
  2773. orderClassName = ClassName$2.NEXT;
  2774. eventDirectionName = Direction.LEFT;
  2775. } else {
  2776. directionalClassName = ClassName$2.RIGHT;
  2777. orderClassName = ClassName$2.PREV;
  2778. eventDirectionName = Direction.RIGHT;
  2779. }
  2780. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2781. this._isSliding = false;
  2782. return;
  2783. }
  2784. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2785. if (slideEvent.isDefaultPrevented()) {
  2786. return;
  2787. }
  2788. if (!activeElement || !nextElement) {
  2789. // Some weirdness is happening, so we bail
  2790. return;
  2791. }
  2792. this._isSliding = true;
  2793. if (isCycling) {
  2794. this.pause();
  2795. }
  2796. this._setActiveIndicatorElement(nextElement);
  2797. var slidEvent = $.Event(Event$2.SLID, {
  2798. relatedTarget: nextElement,
  2799. direction: eventDirectionName,
  2800. from: activeElementIndex,
  2801. to: nextElementIndex
  2802. });
  2803. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2804. $(nextElement).addClass(orderClassName);
  2805. Util.reflow(nextElement);
  2806. $(activeElement).addClass(directionalClassName);
  2807. $(nextElement).addClass(directionalClassName);
  2808. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2809. if (nextElementInterval) {
  2810. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2811. this._config.interval = nextElementInterval;
  2812. } else {
  2813. this._config.interval = this._config.defaultInterval || this._config.interval;
  2814. }
  2815. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2816. $(activeElement).one(Util.TRANSITION_END, function () {
  2817. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2818. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2819. _this4._isSliding = false;
  2820. setTimeout(function () {
  2821. return $(_this4._element).trigger(slidEvent);
  2822. }, 0);
  2823. }).emulateTransitionEnd(transitionDuration);
  2824. } else {
  2825. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2826. $(nextElement).addClass(ClassName$2.ACTIVE);
  2827. this._isSliding = false;
  2828. $(this._element).trigger(slidEvent);
  2829. }
  2830. if (isCycling) {
  2831. this.cycle();
  2832. }
  2833. } // Static
  2834. ;
  2835. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2836. return this.each(function () {
  2837. var data = $(this).data(DATA_KEY$2);
  2838. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2839. if (typeof config === 'object') {
  2840. _config = _objectSpread2({}, _config, {}, config);
  2841. }
  2842. var action = typeof config === 'string' ? config : _config.slide;
  2843. if (!data) {
  2844. data = new Carousel(this, _config);
  2845. $(this).data(DATA_KEY$2, data);
  2846. }
  2847. if (typeof config === 'number') {
  2848. data.to(config);
  2849. } else if (typeof action === 'string') {
  2850. if (typeof data[action] === 'undefined') {
  2851. throw new TypeError("No method named \"" + action + "\"");
  2852. }
  2853. data[action]();
  2854. } else if (_config.interval && _config.ride) {
  2855. data.pause();
  2856. data.cycle();
  2857. }
  2858. });
  2859. };
  2860. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2861. var selector = Util.getSelectorFromElement(this);
  2862. if (!selector) {
  2863. return;
  2864. }
  2865. var target = $(selector)[0];
  2866. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2867. return;
  2868. }
  2869. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2870. var slideIndex = this.getAttribute('data-slide-to');
  2871. if (slideIndex) {
  2872. config.interval = false;
  2873. }
  2874. Carousel._jQueryInterface.call($(target), config);
  2875. if (slideIndex) {
  2876. $(target).data(DATA_KEY$2).to(slideIndex);
  2877. }
  2878. event.preventDefault();
  2879. };
  2880. _createClass(Carousel, null, [{
  2881. key: "VERSION",
  2882. get: function get() {
  2883. return VERSION$2;
  2884. }
  2885. }, {
  2886. key: "Default",
  2887. get: function get() {
  2888. return Default;
  2889. }
  2890. }]);
  2891. return Carousel;
  2892. }();
  2893. /**
  2894. * ------------------------------------------------------------------------
  2895. * Data Api implementation
  2896. * ------------------------------------------------------------------------
  2897. */
  2898. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2899. $(window).on(Event$2.LOAD_DATA_API, function () {
  2900. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2901. for (var i = 0, len = carousels.length; i < len; i++) {
  2902. var $carousel = $(carousels[i]);
  2903. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2904. }
  2905. });
  2906. /**
  2907. * ------------------------------------------------------------------------
  2908. * jQuery
  2909. * ------------------------------------------------------------------------
  2910. */
  2911. $.fn[NAME$2] = Carousel._jQueryInterface;
  2912. $.fn[NAME$2].Constructor = Carousel;
  2913. $.fn[NAME$2].noConflict = function () {
  2914. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2915. return Carousel._jQueryInterface;
  2916. };
  2917. /**
  2918. * ------------------------------------------------------------------------
  2919. * Constants
  2920. * ------------------------------------------------------------------------
  2921. */
  2922. var NAME$3 = 'collapse';
  2923. var VERSION$3 = '4.4.1';
  2924. var DATA_KEY$3 = 'bs.collapse';
  2925. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2926. var DATA_API_KEY$3 = '.data-api';
  2927. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2928. var Default$1 = {
  2929. toggle: true,
  2930. parent: ''
  2931. };
  2932. var DefaultType$1 = {
  2933. toggle: 'boolean',
  2934. parent: '(string|element)'
  2935. };
  2936. var Event$3 = {
  2937. SHOW: "show" + EVENT_KEY$3,
  2938. SHOWN: "shown" + EVENT_KEY$3,
  2939. HIDE: "hide" + EVENT_KEY$3,
  2940. HIDDEN: "hidden" + EVENT_KEY$3,
  2941. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2942. };
  2943. var ClassName$3 = {
  2944. SHOW: 'show',
  2945. COLLAPSE: 'collapse',
  2946. COLLAPSING: 'collapsing',
  2947. COLLAPSED: 'collapsed'
  2948. };
  2949. var Dimension = {
  2950. WIDTH: 'width',
  2951. HEIGHT: 'height'
  2952. };
  2953. var Selector$3 = {
  2954. ACTIVES: '.show, .collapsing',
  2955. DATA_TOGGLE: '[data-toggle="collapse"]'
  2956. };
  2957. /**
  2958. * ------------------------------------------------------------------------
  2959. * Class Definition
  2960. * ------------------------------------------------------------------------
  2961. */
  2962. var Collapse =
  2963. /*#__PURE__*/
  2964. function () {
  2965. function Collapse(element, config) {
  2966. this._isTransitioning = false;
  2967. this._element = element;
  2968. this._config = this._getConfig(config);
  2969. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2970. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2971. for (var i = 0, len = toggleList.length; i < len; i++) {
  2972. var elem = toggleList[i];
  2973. var selector = Util.getSelectorFromElement(elem);
  2974. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2975. return foundElem === element;
  2976. });
  2977. if (selector !== null && filterElement.length > 0) {
  2978. this._selector = selector;
  2979. this._triggerArray.push(elem);
  2980. }
  2981. }
  2982. this._parent = this._config.parent ? this._getParent() : null;
  2983. if (!this._config.parent) {
  2984. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2985. }
  2986. if (this._config.toggle) {
  2987. this.toggle();
  2988. }
  2989. } // Getters
  2990. var _proto = Collapse.prototype;
  2991. // Public
  2992. _proto.toggle = function toggle() {
  2993. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2994. this.hide();
  2995. } else {
  2996. this.show();
  2997. }
  2998. };
  2999. _proto.show = function show() {
  3000. var _this = this;
  3001. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  3002. return;
  3003. }
  3004. var actives;
  3005. var activesData;
  3006. if (this._parent) {
  3007. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  3008. if (typeof _this._config.parent === 'string') {
  3009. return elem.getAttribute('data-parent') === _this._config.parent;
  3010. }
  3011. return elem.classList.contains(ClassName$3.COLLAPSE);
  3012. });
  3013. if (actives.length === 0) {
  3014. actives = null;
  3015. }
  3016. }
  3017. if (actives) {
  3018. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  3019. if (activesData && activesData._isTransitioning) {
  3020. return;
  3021. }
  3022. }
  3023. var startEvent = $.Event(Event$3.SHOW);
  3024. $(this._element).trigger(startEvent);
  3025. if (startEvent.isDefaultPrevented()) {
  3026. return;
  3027. }
  3028. if (actives) {
  3029. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  3030. if (!activesData) {
  3031. $(actives).data(DATA_KEY$3, null);
  3032. }
  3033. }
  3034. var dimension = this._getDimension();
  3035. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  3036. this._element.style[dimension] = 0;
  3037. if (this._triggerArray.length) {
  3038. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  3039. }
  3040. this.setTransitioning(true);
  3041. var complete = function complete() {
  3042. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  3043. _this._element.style[dimension] = '';
  3044. _this.setTransitioning(false);
  3045. $(_this._element).trigger(Event$3.SHOWN);
  3046. };
  3047. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  3048. var scrollSize = "scroll" + capitalizedDimension;
  3049. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3050. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3051. this._element.style[dimension] = this._element[scrollSize] + "px";
  3052. };
  3053. _proto.hide = function hide() {
  3054. var _this2 = this;
  3055. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  3056. return;
  3057. }
  3058. var startEvent = $.Event(Event$3.HIDE);
  3059. $(this._element).trigger(startEvent);
  3060. if (startEvent.isDefaultPrevented()) {
  3061. return;
  3062. }
  3063. var dimension = this._getDimension();
  3064. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  3065. Util.reflow(this._element);
  3066. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  3067. var triggerArrayLength = this._triggerArray.length;
  3068. if (triggerArrayLength > 0) {
  3069. for (var i = 0; i < triggerArrayLength; i++) {
  3070. var trigger = this._triggerArray[i];
  3071. var selector = Util.getSelectorFromElement(trigger);
  3072. if (selector !== null) {
  3073. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  3074. if (!$elem.hasClass(ClassName$3.SHOW)) {
  3075. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  3076. }
  3077. }
  3078. }
  3079. }
  3080. this.setTransitioning(true);
  3081. var complete = function complete() {
  3082. _this2.setTransitioning(false);
  3083. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  3084. };
  3085. this._element.style[dimension] = '';
  3086. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3087. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3088. };
  3089. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  3090. this._isTransitioning = isTransitioning;
  3091. };
  3092. _proto.dispose = function dispose() {
  3093. $.removeData(this._element, DATA_KEY$3);
  3094. this._config = null;
  3095. this._parent = null;
  3096. this._element = null;
  3097. this._triggerArray = null;
  3098. this._isTransitioning = null;
  3099. } // Private
  3100. ;
  3101. _proto._getConfig = function _getConfig(config) {
  3102. config = _objectSpread2({}, Default$1, {}, config);
  3103. config.toggle = Boolean(config.toggle); // Coerce string values
  3104. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3105. return config;
  3106. };
  3107. _proto._getDimension = function _getDimension() {
  3108. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3109. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3110. };
  3111. _proto._getParent = function _getParent() {
  3112. var _this3 = this;
  3113. var parent;
  3114. if (Util.isElement(this._config.parent)) {
  3115. parent = this._config.parent; // It's a jQuery object
  3116. if (typeof this._config.parent.jquery !== 'undefined') {
  3117. parent = this._config.parent[0];
  3118. }
  3119. } else {
  3120. parent = document.querySelector(this._config.parent);
  3121. }
  3122. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3123. var children = [].slice.call(parent.querySelectorAll(selector));
  3124. $(children).each(function (i, element) {
  3125. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3126. });
  3127. return parent;
  3128. };
  3129. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3130. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3131. if (triggerArray.length) {
  3132. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3133. }
  3134. } // Static
  3135. ;
  3136. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3137. var selector = Util.getSelectorFromElement(element);
  3138. return selector ? document.querySelector(selector) : null;
  3139. };
  3140. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3141. return this.each(function () {
  3142. var $this = $(this);
  3143. var data = $this.data(DATA_KEY$3);
  3144. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3145. if (!data && _config.toggle && /show|hide/.test(config)) {
  3146. _config.toggle = false;
  3147. }
  3148. if (!data) {
  3149. data = new Collapse(this, _config);
  3150. $this.data(DATA_KEY$3, data);
  3151. }
  3152. if (typeof config === 'string') {
  3153. if (typeof data[config] === 'undefined') {
  3154. throw new TypeError("No method named \"" + config + "\"");
  3155. }
  3156. data[config]();
  3157. }
  3158. });
  3159. };
  3160. _createClass(Collapse, null, [{
  3161. key: "VERSION",
  3162. get: function get() {
  3163. return VERSION$3;
  3164. }
  3165. }, {
  3166. key: "Default",
  3167. get: function get() {
  3168. return Default$1;
  3169. }
  3170. }]);
  3171. return Collapse;
  3172. }();
  3173. /**
  3174. * ------------------------------------------------------------------------
  3175. * Data Api implementation
  3176. * ------------------------------------------------------------------------
  3177. */
  3178. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3179. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3180. if (event.currentTarget.tagName === 'A') {
  3181. event.preventDefault();
  3182. }
  3183. var $trigger = $(this);
  3184. var selector = Util.getSelectorFromElement(this);
  3185. var selectors = [].slice.call(document.querySelectorAll(selector));
  3186. $(selectors).each(function () {
  3187. var $target = $(this);
  3188. var data = $target.data(DATA_KEY$3);
  3189. var config = data ? 'toggle' : $trigger.data();
  3190. Collapse._jQueryInterface.call($target, config);
  3191. });
  3192. });
  3193. /**
  3194. * ------------------------------------------------------------------------
  3195. * jQuery
  3196. * ------------------------------------------------------------------------
  3197. */
  3198. $.fn[NAME$3] = Collapse._jQueryInterface;
  3199. $.fn[NAME$3].Constructor = Collapse;
  3200. $.fn[NAME$3].noConflict = function () {
  3201. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3202. return Collapse._jQueryInterface;
  3203. };
  3204. /**
  3205. * ------------------------------------------------------------------------
  3206. * Constants
  3207. * ------------------------------------------------------------------------
  3208. */
  3209. var NAME$4 = 'dropdown';
  3210. var VERSION$4 = '4.4.1';
  3211. var DATA_KEY$4 = 'bs.dropdown';
  3212. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3213. var DATA_API_KEY$4 = '.data-api';
  3214. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3215. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3216. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3217. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3218. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3219. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3220. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3221. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3222. var Event$4 = {
  3223. HIDE: "hide" + EVENT_KEY$4,
  3224. HIDDEN: "hidden" + EVENT_KEY$4,
  3225. SHOW: "show" + EVENT_KEY$4,
  3226. SHOWN: "shown" + EVENT_KEY$4,
  3227. CLICK: "click" + EVENT_KEY$4,
  3228. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3229. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3230. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3231. };
  3232. var ClassName$4 = {
  3233. DISABLED: 'disabled',
  3234. SHOW: 'show',
  3235. DROPUP: 'dropup',
  3236. DROPRIGHT: 'dropright',
  3237. DROPLEFT: 'dropleft',
  3238. MENURIGHT: 'dropdown-menu-right',
  3239. MENULEFT: 'dropdown-menu-left',
  3240. POSITION_STATIC: 'position-static'
  3241. };
  3242. var Selector$4 = {
  3243. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3244. FORM_CHILD: '.dropdown form',
  3245. MENU: '.dropdown-menu',
  3246. NAVBAR_NAV: '.navbar-nav',
  3247. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3248. };
  3249. var AttachmentMap = {
  3250. TOP: 'top-start',
  3251. TOPEND: 'top-end',
  3252. BOTTOM: 'bottom-start',
  3253. BOTTOMEND: 'bottom-end',
  3254. RIGHT: 'right-start',
  3255. RIGHTEND: 'right-end',
  3256. LEFT: 'left-start',
  3257. LEFTEND: 'left-end'
  3258. };
  3259. var Default$2 = {
  3260. offset: 0,
  3261. flip: true,
  3262. boundary: 'scrollParent',
  3263. reference: 'toggle',
  3264. display: 'dynamic',
  3265. popperConfig: null
  3266. };
  3267. var DefaultType$2 = {
  3268. offset: '(number|string|function)',
  3269. flip: 'boolean',
  3270. boundary: '(string|element)',
  3271. reference: '(string|element)',
  3272. display: 'string',
  3273. popperConfig: '(null|object)'
  3274. };
  3275. /**
  3276. * ------------------------------------------------------------------------
  3277. * Class Definition
  3278. * ------------------------------------------------------------------------
  3279. */
  3280. var Dropdown =
  3281. /*#__PURE__*/
  3282. function () {
  3283. function Dropdown(element, config) {
  3284. this._element = element;
  3285. this._popper = null;
  3286. this._config = this._getConfig(config);
  3287. this._menu = this._getMenuElement();
  3288. this._inNavbar = this._detectNavbar();
  3289. this._addEventListeners();
  3290. } // Getters
  3291. var _proto = Dropdown.prototype;
  3292. // Public
  3293. _proto.toggle = function toggle() {
  3294. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3295. return;
  3296. }
  3297. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3298. Dropdown._clearMenus();
  3299. if (isActive) {
  3300. return;
  3301. }
  3302. this.show(true);
  3303. };
  3304. _proto.show = function show(usePopper) {
  3305. if (usePopper === void 0) {
  3306. usePopper = false;
  3307. }
  3308. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3309. return;
  3310. }
  3311. var relatedTarget = {
  3312. relatedTarget: this._element
  3313. };
  3314. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3315. var parent = Dropdown._getParentFromElement(this._element);
  3316. $(parent).trigger(showEvent);
  3317. if (showEvent.isDefaultPrevented()) {
  3318. return;
  3319. } // Disable totally Popper.js for Dropdown in Navbar
  3320. if (!this._inNavbar && usePopper) {
  3321. /**
  3322. * Check for Popper dependency
  3323. * Popper - https://popper.js.org
  3324. */
  3325. if (typeof Popper === 'undefined') {
  3326. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3327. }
  3328. var referenceElement = this._element;
  3329. if (this._config.reference === 'parent') {
  3330. referenceElement = parent;
  3331. } else if (Util.isElement(this._config.reference)) {
  3332. referenceElement = this._config.reference; // Check if it's jQuery element
  3333. if (typeof this._config.reference.jquery !== 'undefined') {
  3334. referenceElement = this._config.reference[0];
  3335. }
  3336. } // If boundary is not `scrollParent`, then set position to `static`
  3337. // to allow the menu to "escape" the scroll parent's boundaries
  3338. // https://github.com/twbs/bootstrap/issues/24251
  3339. if (this._config.boundary !== 'scrollParent') {
  3340. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3341. }
  3342. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3343. } // If this is a touch-enabled device we add extra
  3344. // empty mouseover listeners to the body's immediate children;
  3345. // only needed because of broken event delegation on iOS
  3346. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3347. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3348. $(document.body).children().on('mouseover', null, $.noop);
  3349. }
  3350. this._element.focus();
  3351. this._element.setAttribute('aria-expanded', true);
  3352. $(this._menu).toggleClass(ClassName$4.SHOW);
  3353. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3354. };
  3355. _proto.hide = function hide() {
  3356. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3357. return;
  3358. }
  3359. var relatedTarget = {
  3360. relatedTarget: this._element
  3361. };
  3362. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3363. var parent = Dropdown._getParentFromElement(this._element);
  3364. $(parent).trigger(hideEvent);
  3365. if (hideEvent.isDefaultPrevented()) {
  3366. return;
  3367. }
  3368. if (this._popper) {
  3369. this._popper.destroy();
  3370. }
  3371. $(this._menu).toggleClass(ClassName$4.SHOW);
  3372. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3373. };
  3374. _proto.dispose = function dispose() {
  3375. $.removeData(this._element, DATA_KEY$4);
  3376. $(this._element).off(EVENT_KEY$4);
  3377. this._element = null;
  3378. this._menu = null;
  3379. if (this._popper !== null) {
  3380. this._popper.destroy();
  3381. this._popper = null;
  3382. }
  3383. };
  3384. _proto.update = function update() {
  3385. this._inNavbar = this._detectNavbar();
  3386. if (this._popper !== null) {
  3387. this._popper.scheduleUpdate();
  3388. }
  3389. } // Private
  3390. ;
  3391. _proto._addEventListeners = function _addEventListeners() {
  3392. var _this = this;
  3393. $(this._element).on(Event$4.CLICK, function (event) {
  3394. event.preventDefault();
  3395. event.stopPropagation();
  3396. _this.toggle();
  3397. });
  3398. };
  3399. _proto._getConfig = function _getConfig(config) {
  3400. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3401. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3402. return config;
  3403. };
  3404. _proto._getMenuElement = function _getMenuElement() {
  3405. if (!this._menu) {
  3406. var parent = Dropdown._getParentFromElement(this._element);
  3407. if (parent) {
  3408. this._menu = parent.querySelector(Selector$4.MENU);
  3409. }
  3410. }
  3411. return this._menu;
  3412. };
  3413. _proto._getPlacement = function _getPlacement() {
  3414. var $parentDropdown = $(this._element.parentNode);
  3415. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3416. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3417. placement = AttachmentMap.TOP;
  3418. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3419. placement = AttachmentMap.TOPEND;
  3420. }
  3421. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3422. placement = AttachmentMap.RIGHT;
  3423. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3424. placement = AttachmentMap.LEFT;
  3425. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3426. placement = AttachmentMap.BOTTOMEND;
  3427. }
  3428. return placement;
  3429. };
  3430. _proto._detectNavbar = function _detectNavbar() {
  3431. return $(this._element).closest('.navbar').length > 0;
  3432. };
  3433. _proto._getOffset = function _getOffset() {
  3434. var _this2 = this;
  3435. var offset = {};
  3436. if (typeof this._config.offset === 'function') {
  3437. offset.fn = function (data) {
  3438. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3439. return data;
  3440. };
  3441. } else {
  3442. offset.offset = this._config.offset;
  3443. }
  3444. return offset;
  3445. };
  3446. _proto._getPopperConfig = function _getPopperConfig() {
  3447. var popperConfig = {
  3448. placement: this._getPlacement(),
  3449. modifiers: {
  3450. offset: this._getOffset(),
  3451. flip: {
  3452. enabled: this._config.flip
  3453. },
  3454. preventOverflow: {
  3455. boundariesElement: this._config.boundary
  3456. }
  3457. }
  3458. }; // Disable Popper.js if we have a static display
  3459. if (this._config.display === 'static') {
  3460. popperConfig.modifiers.applyStyle = {
  3461. enabled: false
  3462. };
  3463. }
  3464. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3465. } // Static
  3466. ;
  3467. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3468. return this.each(function () {
  3469. var data = $(this).data(DATA_KEY$4);
  3470. var _config = typeof config === 'object' ? config : null;
  3471. if (!data) {
  3472. data = new Dropdown(this, _config);
  3473. $(this).data(DATA_KEY$4, data);
  3474. }
  3475. if (typeof config === 'string') {
  3476. if (typeof data[config] === 'undefined') {
  3477. throw new TypeError("No method named \"" + config + "\"");
  3478. }
  3479. data[config]();
  3480. }
  3481. });
  3482. };
  3483. Dropdown._clearMenus = function _clearMenus(event) {
  3484. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3485. return;
  3486. }
  3487. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3488. for (var i = 0, len = toggles.length; i < len; i++) {
  3489. var parent = Dropdown._getParentFromElement(toggles[i]);
  3490. var context = $(toggles[i]).data(DATA_KEY$4);
  3491. var relatedTarget = {
  3492. relatedTarget: toggles[i]
  3493. };
  3494. if (event && event.type === 'click') {
  3495. relatedTarget.clickEvent = event;
  3496. }
  3497. if (!context) {
  3498. continue;
  3499. }
  3500. var dropdownMenu = context._menu;
  3501. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3502. continue;
  3503. }
  3504. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3505. continue;
  3506. }
  3507. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3508. $(parent).trigger(hideEvent);
  3509. if (hideEvent.isDefaultPrevented()) {
  3510. continue;
  3511. } // If this is a touch-enabled device we remove the extra
  3512. // empty mouseover listeners we added for iOS support
  3513. if ('ontouchstart' in document.documentElement) {
  3514. $(document.body).children().off('mouseover', null, $.noop);
  3515. }
  3516. toggles[i].setAttribute('aria-expanded', 'false');
  3517. if (context._popper) {
  3518. context._popper.destroy();
  3519. }
  3520. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3521. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3522. }
  3523. };
  3524. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3525. var parent;
  3526. var selector = Util.getSelectorFromElement(element);
  3527. if (selector) {
  3528. parent = document.querySelector(selector);
  3529. }
  3530. return parent || element.parentNode;
  3531. } // eslint-disable-next-line complexity
  3532. ;
  3533. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3534. // If not input/textarea:
  3535. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3536. // If input/textarea:
  3537. // - If space key => not a dropdown command
  3538. // - If key is other than escape
  3539. // - If key is not up or down => not a dropdown command
  3540. // - If trigger inside the menu => not a dropdown command
  3541. 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)) {
  3542. return;
  3543. }
  3544. event.preventDefault();
  3545. event.stopPropagation();
  3546. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3547. return;
  3548. }
  3549. var parent = Dropdown._getParentFromElement(this);
  3550. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3551. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3552. return;
  3553. }
  3554. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3555. if (event.which === ESCAPE_KEYCODE) {
  3556. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3557. $(toggle).trigger('focus');
  3558. }
  3559. $(this).trigger('click');
  3560. return;
  3561. }
  3562. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3563. return $(item).is(':visible');
  3564. });
  3565. if (items.length === 0) {
  3566. return;
  3567. }
  3568. var index = items.indexOf(event.target);
  3569. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3570. // Up
  3571. index--;
  3572. }
  3573. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3574. // Down
  3575. index++;
  3576. }
  3577. if (index < 0) {
  3578. index = 0;
  3579. }
  3580. items[index].focus();
  3581. };
  3582. _createClass(Dropdown, null, [{
  3583. key: "VERSION",
  3584. get: function get() {
  3585. return VERSION$4;
  3586. }
  3587. }, {
  3588. key: "Default",
  3589. get: function get() {
  3590. return Default$2;
  3591. }
  3592. }, {
  3593. key: "DefaultType",
  3594. get: function get() {
  3595. return DefaultType$2;
  3596. }
  3597. }]);
  3598. return Dropdown;
  3599. }();
  3600. /**
  3601. * ------------------------------------------------------------------------
  3602. * Data Api implementation
  3603. * ------------------------------------------------------------------------
  3604. */
  3605. $(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) {
  3606. event.preventDefault();
  3607. event.stopPropagation();
  3608. Dropdown._jQueryInterface.call($(this), 'toggle');
  3609. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3610. e.stopPropagation();
  3611. });
  3612. /**
  3613. * ------------------------------------------------------------------------
  3614. * jQuery
  3615. * ------------------------------------------------------------------------
  3616. */
  3617. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3618. $.fn[NAME$4].Constructor = Dropdown;
  3619. $.fn[NAME$4].noConflict = function () {
  3620. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3621. return Dropdown._jQueryInterface;
  3622. };
  3623. /**
  3624. * ------------------------------------------------------------------------
  3625. * Constants
  3626. * ------------------------------------------------------------------------
  3627. */
  3628. var NAME$5 = 'modal';
  3629. var VERSION$5 = '4.4.1';
  3630. var DATA_KEY$5 = 'bs.modal';
  3631. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3632. var DATA_API_KEY$5 = '.data-api';
  3633. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3634. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3635. var Default$3 = {
  3636. backdrop: true,
  3637. keyboard: true,
  3638. focus: true,
  3639. show: true
  3640. };
  3641. var DefaultType$3 = {
  3642. backdrop: '(boolean|string)',
  3643. keyboard: 'boolean',
  3644. focus: 'boolean',
  3645. show: 'boolean'
  3646. };
  3647. var Event$5 = {
  3648. HIDE: "hide" + EVENT_KEY$5,
  3649. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3650. HIDDEN: "hidden" + EVENT_KEY$5,
  3651. SHOW: "show" + EVENT_KEY$5,
  3652. SHOWN: "shown" + EVENT_KEY$5,
  3653. FOCUSIN: "focusin" + EVENT_KEY$5,
  3654. RESIZE: "resize" + EVENT_KEY$5,
  3655. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3656. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3657. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3658. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3659. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3660. };
  3661. var ClassName$5 = {
  3662. SCROLLABLE: 'modal-dialog-scrollable',
  3663. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3664. BACKDROP: 'modal-backdrop',
  3665. OPEN: 'modal-open',
  3666. FADE: 'fade',
  3667. SHOW: 'show',
  3668. STATIC: 'modal-static'
  3669. };
  3670. var Selector$5 = {
  3671. DIALOG: '.modal-dialog',
  3672. MODAL_BODY: '.modal-body',
  3673. DATA_TOGGLE: '[data-toggle="modal"]',
  3674. DATA_DISMISS: '[data-dismiss="modal"]',
  3675. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3676. STICKY_CONTENT: '.sticky-top'
  3677. };
  3678. /**
  3679. * ------------------------------------------------------------------------
  3680. * Class Definition
  3681. * ------------------------------------------------------------------------
  3682. */
  3683. var Modal =
  3684. /*#__PURE__*/
  3685. function () {
  3686. function Modal(element, config) {
  3687. this._config = this._getConfig(config);
  3688. this._element = element;
  3689. this._dialog = element.querySelector(Selector$5.DIALOG);
  3690. this._backdrop = null;
  3691. this._isShown = false;
  3692. this._isBodyOverflowing = false;
  3693. this._ignoreBackdropClick = false;
  3694. this._isTransitioning = false;
  3695. this._scrollbarWidth = 0;
  3696. } // Getters
  3697. var _proto = Modal.prototype;
  3698. // Public
  3699. _proto.toggle = function toggle(relatedTarget) {
  3700. return this._isShown ? this.hide() : this.show(relatedTarget);
  3701. };
  3702. _proto.show = function show(relatedTarget) {
  3703. var _this = this;
  3704. if (this._isShown || this._isTransitioning) {
  3705. return;
  3706. }
  3707. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3708. this._isTransitioning = true;
  3709. }
  3710. var showEvent = $.Event(Event$5.SHOW, {
  3711. relatedTarget: relatedTarget
  3712. });
  3713. $(this._element).trigger(showEvent);
  3714. if (this._isShown || showEvent.isDefaultPrevented()) {
  3715. return;
  3716. }
  3717. this._isShown = true;
  3718. this._checkScrollbar();
  3719. this._setScrollbar();
  3720. this._adjustDialog();
  3721. this._setEscapeEvent();
  3722. this._setResizeEvent();
  3723. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3724. return _this.hide(event);
  3725. });
  3726. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3727. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3728. if ($(event.target).is(_this._element)) {
  3729. _this._ignoreBackdropClick = true;
  3730. }
  3731. });
  3732. });
  3733. this._showBackdrop(function () {
  3734. return _this._showElement(relatedTarget);
  3735. });
  3736. };
  3737. _proto.hide = function hide(event) {
  3738. var _this2 = this;
  3739. if (event) {
  3740. event.preventDefault();
  3741. }
  3742. if (!this._isShown || this._isTransitioning) {
  3743. return;
  3744. }
  3745. var hideEvent = $.Event(Event$5.HIDE);
  3746. $(this._element).trigger(hideEvent);
  3747. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3748. return;
  3749. }
  3750. this._isShown = false;
  3751. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3752. if (transition) {
  3753. this._isTransitioning = true;
  3754. }
  3755. this._setEscapeEvent();
  3756. this._setResizeEvent();
  3757. $(document).off(Event$5.FOCUSIN);
  3758. $(this._element).removeClass(ClassName$5.SHOW);
  3759. $(this._element).off(Event$5.CLICK_DISMISS);
  3760. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3761. if (transition) {
  3762. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3763. $(this._element).one(Util.TRANSITION_END, function (event) {
  3764. return _this2._hideModal(event);
  3765. }).emulateTransitionEnd(transitionDuration);
  3766. } else {
  3767. this._hideModal();
  3768. }
  3769. };
  3770. _proto.dispose = function dispose() {
  3771. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3772. return $(htmlElement).off(EVENT_KEY$5);
  3773. });
  3774. /**
  3775. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3776. * Do not move `document` in `htmlElements` array
  3777. * It will remove `Event.CLICK_DATA_API` event that should remain
  3778. */
  3779. $(document).off(Event$5.FOCUSIN);
  3780. $.removeData(this._element, DATA_KEY$5);
  3781. this._config = null;
  3782. this._element = null;
  3783. this._dialog = null;
  3784. this._backdrop = null;
  3785. this._isShown = null;
  3786. this._isBodyOverflowing = null;
  3787. this._ignoreBackdropClick = null;
  3788. this._isTransitioning = null;
  3789. this._scrollbarWidth = null;
  3790. };
  3791. _proto.handleUpdate = function handleUpdate() {
  3792. this._adjustDialog();
  3793. } // Private
  3794. ;
  3795. _proto._getConfig = function _getConfig(config) {
  3796. config = _objectSpread2({}, Default$3, {}, config);
  3797. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3798. return config;
  3799. };
  3800. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3801. var _this3 = this;
  3802. if (this._config.backdrop === 'static') {
  3803. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3804. $(this._element).trigger(hideEventPrevented);
  3805. if (hideEventPrevented.defaultPrevented) {
  3806. return;
  3807. }
  3808. this._element.classList.add(ClassName$5.STATIC);
  3809. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3810. $(this._element).one(Util.TRANSITION_END, function () {
  3811. _this3._element.classList.remove(ClassName$5.STATIC);
  3812. }).emulateTransitionEnd(modalTransitionDuration);
  3813. this._element.focus();
  3814. } else {
  3815. this.hide();
  3816. }
  3817. };
  3818. _proto._showElement = function _showElement(relatedTarget) {
  3819. var _this4 = this;
  3820. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3821. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3822. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3823. // Don't move modal's DOM position
  3824. document.body.appendChild(this._element);
  3825. }
  3826. this._element.style.display = 'block';
  3827. this._element.removeAttribute('aria-hidden');
  3828. this._element.setAttribute('aria-modal', true);
  3829. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3830. modalBody.scrollTop = 0;
  3831. } else {
  3832. this._element.scrollTop = 0;
  3833. }
  3834. if (transition) {
  3835. Util.reflow(this._element);
  3836. }
  3837. $(this._element).addClass(ClassName$5.SHOW);
  3838. if (this._config.focus) {
  3839. this._enforceFocus();
  3840. }
  3841. var shownEvent = $.Event(Event$5.SHOWN, {
  3842. relatedTarget: relatedTarget
  3843. });
  3844. var transitionComplete = function transitionComplete() {
  3845. if (_this4._config.focus) {
  3846. _this4._element.focus();
  3847. }
  3848. _this4._isTransitioning = false;
  3849. $(_this4._element).trigger(shownEvent);
  3850. };
  3851. if (transition) {
  3852. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3853. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3854. } else {
  3855. transitionComplete();
  3856. }
  3857. };
  3858. _proto._enforceFocus = function _enforceFocus() {
  3859. var _this5 = this;
  3860. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3861. .on(Event$5.FOCUSIN, function (event) {
  3862. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3863. _this5._element.focus();
  3864. }
  3865. });
  3866. };
  3867. _proto._setEscapeEvent = function _setEscapeEvent() {
  3868. var _this6 = this;
  3869. if (this._isShown && this._config.keyboard) {
  3870. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3871. if (event.which === ESCAPE_KEYCODE$1) {
  3872. _this6._triggerBackdropTransition();
  3873. }
  3874. });
  3875. } else if (!this._isShown) {
  3876. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3877. }
  3878. };
  3879. _proto._setResizeEvent = function _setResizeEvent() {
  3880. var _this7 = this;
  3881. if (this._isShown) {
  3882. $(window).on(Event$5.RESIZE, function (event) {
  3883. return _this7.handleUpdate(event);
  3884. });
  3885. } else {
  3886. $(window).off(Event$5.RESIZE);
  3887. }
  3888. };
  3889. _proto._hideModal = function _hideModal() {
  3890. var _this8 = this;
  3891. this._element.style.display = 'none';
  3892. this._element.setAttribute('aria-hidden', true);
  3893. this._element.removeAttribute('aria-modal');
  3894. this._isTransitioning = false;
  3895. this._showBackdrop(function () {
  3896. $(document.body).removeClass(ClassName$5.OPEN);
  3897. _this8._resetAdjustments();
  3898. _this8._resetScrollbar();
  3899. $(_this8._element).trigger(Event$5.HIDDEN);
  3900. });
  3901. };
  3902. _proto._removeBackdrop = function _removeBackdrop() {
  3903. if (this._backdrop) {
  3904. $(this._backdrop).remove();
  3905. this._backdrop = null;
  3906. }
  3907. };
  3908. _proto._showBackdrop = function _showBackdrop(callback) {
  3909. var _this9 = this;
  3910. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3911. if (this._isShown && this._config.backdrop) {
  3912. this._backdrop = document.createElement('div');
  3913. this._backdrop.className = ClassName$5.BACKDROP;
  3914. if (animate) {
  3915. this._backdrop.classList.add(animate);
  3916. }
  3917. $(this._backdrop).appendTo(document.body);
  3918. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3919. if (_this9._ignoreBackdropClick) {
  3920. _this9._ignoreBackdropClick = false;
  3921. return;
  3922. }
  3923. if (event.target !== event.currentTarget) {
  3924. return;
  3925. }
  3926. _this9._triggerBackdropTransition();
  3927. });
  3928. if (animate) {
  3929. Util.reflow(this._backdrop);
  3930. }
  3931. $(this._backdrop).addClass(ClassName$5.SHOW);
  3932. if (!callback) {
  3933. return;
  3934. }
  3935. if (!animate) {
  3936. callback();
  3937. return;
  3938. }
  3939. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3940. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3941. } else if (!this._isShown && this._backdrop) {
  3942. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3943. var callbackRemove = function callbackRemove() {
  3944. _this9._removeBackdrop();
  3945. if (callback) {
  3946. callback();
  3947. }
  3948. };
  3949. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3950. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3951. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3952. } else {
  3953. callbackRemove();
  3954. }
  3955. } else if (callback) {
  3956. callback();
  3957. }
  3958. } // ----------------------------------------------------------------------
  3959. // the following methods are used to handle overflowing modals
  3960. // todo (fat): these should probably be refactored out of modal.js
  3961. // ----------------------------------------------------------------------
  3962. ;
  3963. _proto._adjustDialog = function _adjustDialog() {
  3964. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3965. if (!this._isBodyOverflowing && isModalOverflowing) {
  3966. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3967. }
  3968. if (this._isBodyOverflowing && !isModalOverflowing) {
  3969. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3970. }
  3971. };
  3972. _proto._resetAdjustments = function _resetAdjustments() {
  3973. this._element.style.paddingLeft = '';
  3974. this._element.style.paddingRight = '';
  3975. };
  3976. _proto._checkScrollbar = function _checkScrollbar() {
  3977. var rect = document.body.getBoundingClientRect();
  3978. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3979. this._scrollbarWidth = this._getScrollbarWidth();
  3980. };
  3981. _proto._setScrollbar = function _setScrollbar() {
  3982. var _this10 = this;
  3983. if (this._isBodyOverflowing) {
  3984. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3985. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3986. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3987. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3988. $(fixedContent).each(function (index, element) {
  3989. var actualPadding = element.style.paddingRight;
  3990. var calculatedPadding = $(element).css('padding-right');
  3991. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3992. }); // Adjust sticky content margin
  3993. $(stickyContent).each(function (index, element) {
  3994. var actualMargin = element.style.marginRight;
  3995. var calculatedMargin = $(element).css('margin-right');
  3996. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3997. }); // Adjust body padding
  3998. var actualPadding = document.body.style.paddingRight;
  3999. var calculatedPadding = $(document.body).css('padding-right');
  4000. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  4001. }
  4002. $(document.body).addClass(ClassName$5.OPEN);
  4003. };
  4004. _proto._resetScrollbar = function _resetScrollbar() {
  4005. // Restore fixed content padding
  4006. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  4007. $(fixedContent).each(function (index, element) {
  4008. var padding = $(element).data('padding-right');
  4009. $(element).removeData('padding-right');
  4010. element.style.paddingRight = padding ? padding : '';
  4011. }); // Restore sticky content
  4012. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  4013. $(elements).each(function (index, element) {
  4014. var margin = $(element).data('margin-right');
  4015. if (typeof margin !== 'undefined') {
  4016. $(element).css('margin-right', margin).removeData('margin-right');
  4017. }
  4018. }); // Restore body padding
  4019. var padding = $(document.body).data('padding-right');
  4020. $(document.body).removeData('padding-right');
  4021. document.body.style.paddingRight = padding ? padding : '';
  4022. };
  4023. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  4024. // thx d.walsh
  4025. var scrollDiv = document.createElement('div');
  4026. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  4027. document.body.appendChild(scrollDiv);
  4028. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  4029. document.body.removeChild(scrollDiv);
  4030. return scrollbarWidth;
  4031. } // Static
  4032. ;
  4033. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  4034. return this.each(function () {
  4035. var data = $(this).data(DATA_KEY$5);
  4036. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  4037. if (!data) {
  4038. data = new Modal(this, _config);
  4039. $(this).data(DATA_KEY$5, data);
  4040. }
  4041. if (typeof config === 'string') {
  4042. if (typeof data[config] === 'undefined') {
  4043. throw new TypeError("No method named \"" + config + "\"");
  4044. }
  4045. data[config](relatedTarget);
  4046. } else if (_config.show) {
  4047. data.show(relatedTarget);
  4048. }
  4049. });
  4050. };
  4051. _createClass(Modal, null, [{
  4052. key: "VERSION",
  4053. get: function get() {
  4054. return VERSION$5;
  4055. }
  4056. }, {
  4057. key: "Default",
  4058. get: function get() {
  4059. return Default$3;
  4060. }
  4061. }]);
  4062. return Modal;
  4063. }();
  4064. /**
  4065. * ------------------------------------------------------------------------
  4066. * Data Api implementation
  4067. * ------------------------------------------------------------------------
  4068. */
  4069. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  4070. var _this11 = this;
  4071. var target;
  4072. var selector = Util.getSelectorFromElement(this);
  4073. if (selector) {
  4074. target = document.querySelector(selector);
  4075. }
  4076. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  4077. if (this.tagName === 'A' || this.tagName === 'AREA') {
  4078. event.preventDefault();
  4079. }
  4080. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  4081. if (showEvent.isDefaultPrevented()) {
  4082. // Only register focus restorer if modal will actually get shown
  4083. return;
  4084. }
  4085. $target.one(Event$5.HIDDEN, function () {
  4086. if ($(_this11).is(':visible')) {
  4087. _this11.focus();
  4088. }
  4089. });
  4090. });
  4091. Modal._jQueryInterface.call($(target), config, this);
  4092. });
  4093. /**
  4094. * ------------------------------------------------------------------------
  4095. * jQuery
  4096. * ------------------------------------------------------------------------
  4097. */
  4098. $.fn[NAME$5] = Modal._jQueryInterface;
  4099. $.fn[NAME$5].Constructor = Modal;
  4100. $.fn[NAME$5].noConflict = function () {
  4101. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4102. return Modal._jQueryInterface;
  4103. };
  4104. /**
  4105. * --------------------------------------------------------------------------
  4106. * Bootstrap (v4.4.1): tools/sanitizer.js
  4107. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4108. * --------------------------------------------------------------------------
  4109. */
  4110. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4111. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4112. var DefaultWhitelist = {
  4113. // Global attributes allowed on any supplied element below.
  4114. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4115. a: ['target', 'href', 'title', 'rel'],
  4116. area: [],
  4117. b: [],
  4118. br: [],
  4119. col: [],
  4120. code: [],
  4121. div: [],
  4122. em: [],
  4123. hr: [],
  4124. h1: [],
  4125. h2: [],
  4126. h3: [],
  4127. h4: [],
  4128. h5: [],
  4129. h6: [],
  4130. i: [],
  4131. img: ['src', 'alt', 'title', 'width', 'height'],
  4132. li: [],
  4133. ol: [],
  4134. p: [],
  4135. pre: [],
  4136. s: [],
  4137. small: [],
  4138. span: [],
  4139. sub: [],
  4140. sup: [],
  4141. strong: [],
  4142. u: [],
  4143. ul: []
  4144. };
  4145. /**
  4146. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4147. *
  4148. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4149. */
  4150. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4151. /**
  4152. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4153. *
  4154. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4155. */
  4156. 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;
  4157. function allowedAttribute(attr, allowedAttributeList) {
  4158. var attrName = attr.nodeName.toLowerCase();
  4159. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4160. if (uriAttrs.indexOf(attrName) !== -1) {
  4161. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4162. }
  4163. return true;
  4164. }
  4165. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4166. return attrRegex instanceof RegExp;
  4167. }); // Check if a regular expression validates the attribute.
  4168. for (var i = 0, l = regExp.length; i < l; i++) {
  4169. if (attrName.match(regExp[i])) {
  4170. return true;
  4171. }
  4172. }
  4173. return false;
  4174. }
  4175. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4176. if (unsafeHtml.length === 0) {
  4177. return unsafeHtml;
  4178. }
  4179. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4180. return sanitizeFn(unsafeHtml);
  4181. }
  4182. var domParser = new window.DOMParser();
  4183. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4184. var whitelistKeys = Object.keys(whiteList);
  4185. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4186. var _loop = function _loop(i, len) {
  4187. var el = elements[i];
  4188. var elName = el.nodeName.toLowerCase();
  4189. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4190. el.parentNode.removeChild(el);
  4191. return "continue";
  4192. }
  4193. var attributeList = [].slice.call(el.attributes);
  4194. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4195. attributeList.forEach(function (attr) {
  4196. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4197. el.removeAttribute(attr.nodeName);
  4198. }
  4199. });
  4200. };
  4201. for (var i = 0, len = elements.length; i < len; i++) {
  4202. var _ret = _loop(i);
  4203. if (_ret === "continue") continue;
  4204. }
  4205. return createdDocument.body.innerHTML;
  4206. }
  4207. /**
  4208. * ------------------------------------------------------------------------
  4209. * Constants
  4210. * ------------------------------------------------------------------------
  4211. */
  4212. var NAME$6 = 'tooltip';
  4213. var VERSION$6 = '4.4.1';
  4214. var DATA_KEY$6 = 'bs.tooltip';
  4215. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4216. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4217. var CLASS_PREFIX = 'bs-tooltip';
  4218. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4219. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4220. var DefaultType$4 = {
  4221. animation: 'boolean',
  4222. template: 'string',
  4223. title: '(string|element|function)',
  4224. trigger: 'string',
  4225. delay: '(number|object)',
  4226. html: 'boolean',
  4227. selector: '(string|boolean)',
  4228. placement: '(string|function)',
  4229. offset: '(number|string|function)',
  4230. container: '(string|element|boolean)',
  4231. fallbackPlacement: '(string|array)',
  4232. boundary: '(string|element)',
  4233. sanitize: 'boolean',
  4234. sanitizeFn: '(null|function)',
  4235. whiteList: 'object',
  4236. popperConfig: '(null|object)'
  4237. };
  4238. var AttachmentMap$1 = {
  4239. AUTO: 'auto',
  4240. TOP: 'top',
  4241. RIGHT: 'right',
  4242. BOTTOM: 'bottom',
  4243. LEFT: 'left'
  4244. };
  4245. var Default$4 = {
  4246. animation: true,
  4247. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4248. trigger: 'hover focus',
  4249. title: '',
  4250. delay: 0,
  4251. html: false,
  4252. selector: false,
  4253. placement: 'top',
  4254. offset: 0,
  4255. container: false,
  4256. fallbackPlacement: 'flip',
  4257. boundary: 'scrollParent',
  4258. sanitize: true,
  4259. sanitizeFn: null,
  4260. whiteList: DefaultWhitelist,
  4261. popperConfig: null
  4262. };
  4263. var HoverState = {
  4264. SHOW: 'show',
  4265. OUT: 'out'
  4266. };
  4267. var Event$6 = {
  4268. HIDE: "hide" + EVENT_KEY$6,
  4269. HIDDEN: "hidden" + EVENT_KEY$6,
  4270. SHOW: "show" + EVENT_KEY$6,
  4271. SHOWN: "shown" + EVENT_KEY$6,
  4272. INSERTED: "inserted" + EVENT_KEY$6,
  4273. CLICK: "click" + EVENT_KEY$6,
  4274. FOCUSIN: "focusin" + EVENT_KEY$6,
  4275. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4276. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4277. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4278. };
  4279. var ClassName$6 = {
  4280. FADE: 'fade',
  4281. SHOW: 'show'
  4282. };
  4283. var Selector$6 = {
  4284. TOOLTIP: '.tooltip',
  4285. TOOLTIP_INNER: '.tooltip-inner',
  4286. ARROW: '.arrow'
  4287. };
  4288. var Trigger = {
  4289. HOVER: 'hover',
  4290. FOCUS: 'focus',
  4291. CLICK: 'click',
  4292. MANUAL: 'manual'
  4293. };
  4294. /**
  4295. * ------------------------------------------------------------------------
  4296. * Class Definition
  4297. * ------------------------------------------------------------------------
  4298. */
  4299. var Tooltip =
  4300. /*#__PURE__*/
  4301. function () {
  4302. function Tooltip(element, config) {
  4303. if (typeof Popper === 'undefined') {
  4304. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4305. } // private
  4306. this._isEnabled = true;
  4307. this._timeout = 0;
  4308. this._hoverState = '';
  4309. this._activeTrigger = {};
  4310. this._popper = null; // Protected
  4311. this.element = element;
  4312. this.config = this._getConfig(config);
  4313. this.tip = null;
  4314. this._setListeners();
  4315. } // Getters
  4316. var _proto = Tooltip.prototype;
  4317. // Public
  4318. _proto.enable = function enable() {
  4319. this._isEnabled = true;
  4320. };
  4321. _proto.disable = function disable() {
  4322. this._isEnabled = false;
  4323. };
  4324. _proto.toggleEnabled = function toggleEnabled() {
  4325. this._isEnabled = !this._isEnabled;
  4326. };
  4327. _proto.toggle = function toggle(event) {
  4328. if (!this._isEnabled) {
  4329. return;
  4330. }
  4331. if (event) {
  4332. var dataKey = this.constructor.DATA_KEY;
  4333. var context = $(event.currentTarget).data(dataKey);
  4334. if (!context) {
  4335. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4336. $(event.currentTarget).data(dataKey, context);
  4337. }
  4338. context._activeTrigger.click = !context._activeTrigger.click;
  4339. if (context._isWithActiveTrigger()) {
  4340. context._enter(null, context);
  4341. } else {
  4342. context._leave(null, context);
  4343. }
  4344. } else {
  4345. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4346. this._leave(null, this);
  4347. return;
  4348. }
  4349. this._enter(null, this);
  4350. }
  4351. };
  4352. _proto.dispose = function dispose() {
  4353. clearTimeout(this._timeout);
  4354. $.removeData(this.element, this.constructor.DATA_KEY);
  4355. $(this.element).off(this.constructor.EVENT_KEY);
  4356. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4357. if (this.tip) {
  4358. $(this.tip).remove();
  4359. }
  4360. this._isEnabled = null;
  4361. this._timeout = null;
  4362. this._hoverState = null;
  4363. this._activeTrigger = null;
  4364. if (this._popper) {
  4365. this._popper.destroy();
  4366. }
  4367. this._popper = null;
  4368. this.element = null;
  4369. this.config = null;
  4370. this.tip = null;
  4371. };
  4372. _proto.show = function show() {
  4373. var _this = this;
  4374. if ($(this.element).css('display') === 'none') {
  4375. throw new Error('Please use show on visible elements');
  4376. }
  4377. var showEvent = $.Event(this.constructor.Event.SHOW);
  4378. if (this.isWithContent() && this._isEnabled) {
  4379. $(this.element).trigger(showEvent);
  4380. var shadowRoot = Util.findShadowRoot(this.element);
  4381. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4382. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4383. return;
  4384. }
  4385. var tip = this.getTipElement();
  4386. var tipId = Util.getUID(this.constructor.NAME);
  4387. tip.setAttribute('id', tipId);
  4388. this.element.setAttribute('aria-describedby', tipId);
  4389. this.setContent();
  4390. if (this.config.animation) {
  4391. $(tip).addClass(ClassName$6.FADE);
  4392. }
  4393. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4394. var attachment = this._getAttachment(placement);
  4395. this.addAttachmentClass(attachment);
  4396. var container = this._getContainer();
  4397. $(tip).data(this.constructor.DATA_KEY, this);
  4398. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4399. $(tip).appendTo(container);
  4400. }
  4401. $(this.element).trigger(this.constructor.Event.INSERTED);
  4402. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4403. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4404. // empty mouseover listeners to the body's immediate children;
  4405. // only needed because of broken event delegation on iOS
  4406. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4407. if ('ontouchstart' in document.documentElement) {
  4408. $(document.body).children().on('mouseover', null, $.noop);
  4409. }
  4410. var complete = function complete() {
  4411. if (_this.config.animation) {
  4412. _this._fixTransition();
  4413. }
  4414. var prevHoverState = _this._hoverState;
  4415. _this._hoverState = null;
  4416. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4417. if (prevHoverState === HoverState.OUT) {
  4418. _this._leave(null, _this);
  4419. }
  4420. };
  4421. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4422. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4423. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4424. } else {
  4425. complete();
  4426. }
  4427. }
  4428. };
  4429. _proto.hide = function hide(callback) {
  4430. var _this2 = this;
  4431. var tip = this.getTipElement();
  4432. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4433. var complete = function complete() {
  4434. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4435. tip.parentNode.removeChild(tip);
  4436. }
  4437. _this2._cleanTipClass();
  4438. _this2.element.removeAttribute('aria-describedby');
  4439. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4440. if (_this2._popper !== null) {
  4441. _this2._popper.destroy();
  4442. }
  4443. if (callback) {
  4444. callback();
  4445. }
  4446. };
  4447. $(this.element).trigger(hideEvent);
  4448. if (hideEvent.isDefaultPrevented()) {
  4449. return;
  4450. }
  4451. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4452. // empty mouseover listeners we added for iOS support
  4453. if ('ontouchstart' in document.documentElement) {
  4454. $(document.body).children().off('mouseover', null, $.noop);
  4455. }
  4456. this._activeTrigger[Trigger.CLICK] = false;
  4457. this._activeTrigger[Trigger.FOCUS] = false;
  4458. this._activeTrigger[Trigger.HOVER] = false;
  4459. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4460. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4461. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4462. } else {
  4463. complete();
  4464. }
  4465. this._hoverState = '';
  4466. };
  4467. _proto.update = function update() {
  4468. if (this._popper !== null) {
  4469. this._popper.scheduleUpdate();
  4470. }
  4471. } // Protected
  4472. ;
  4473. _proto.isWithContent = function isWithContent() {
  4474. return Boolean(this.getTitle());
  4475. };
  4476. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4477. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4478. };
  4479. _proto.getTipElement = function getTipElement() {
  4480. this.tip = this.tip || $(this.config.template)[0];
  4481. return this.tip;
  4482. };
  4483. _proto.setContent = function setContent() {
  4484. var tip = this.getTipElement();
  4485. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4486. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4487. };
  4488. _proto.setElementContent = function setElementContent($element, content) {
  4489. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4490. // Content is a DOM node or a jQuery
  4491. if (this.config.html) {
  4492. if (!$(content).parent().is($element)) {
  4493. $element.empty().append(content);
  4494. }
  4495. } else {
  4496. $element.text($(content).text());
  4497. }
  4498. return;
  4499. }
  4500. if (this.config.html) {
  4501. if (this.config.sanitize) {
  4502. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4503. }
  4504. $element.html(content);
  4505. } else {
  4506. $element.text(content);
  4507. }
  4508. };
  4509. _proto.getTitle = function getTitle() {
  4510. var title = this.element.getAttribute('data-original-title');
  4511. if (!title) {
  4512. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4513. }
  4514. return title;
  4515. } // Private
  4516. ;
  4517. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4518. var _this3 = this;
  4519. var defaultBsConfig = {
  4520. placement: attachment,
  4521. modifiers: {
  4522. offset: this._getOffset(),
  4523. flip: {
  4524. behavior: this.config.fallbackPlacement
  4525. },
  4526. arrow: {
  4527. element: Selector$6.ARROW
  4528. },
  4529. preventOverflow: {
  4530. boundariesElement: this.config.boundary
  4531. }
  4532. },
  4533. onCreate: function onCreate(data) {
  4534. if (data.originalPlacement !== data.placement) {
  4535. _this3._handlePopperPlacementChange(data);
  4536. }
  4537. },
  4538. onUpdate: function onUpdate(data) {
  4539. return _this3._handlePopperPlacementChange(data);
  4540. }
  4541. };
  4542. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4543. };
  4544. _proto._getOffset = function _getOffset() {
  4545. var _this4 = this;
  4546. var offset = {};
  4547. if (typeof this.config.offset === 'function') {
  4548. offset.fn = function (data) {
  4549. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4550. return data;
  4551. };
  4552. } else {
  4553. offset.offset = this.config.offset;
  4554. }
  4555. return offset;
  4556. };
  4557. _proto._getContainer = function _getContainer() {
  4558. if (this.config.container === false) {
  4559. return document.body;
  4560. }
  4561. if (Util.isElement(this.config.container)) {
  4562. return $(this.config.container);
  4563. }
  4564. return $(document).find(this.config.container);
  4565. };
  4566. _proto._getAttachment = function _getAttachment(placement) {
  4567. return AttachmentMap$1[placement.toUpperCase()];
  4568. };
  4569. _proto._setListeners = function _setListeners() {
  4570. var _this5 = this;
  4571. var triggers = this.config.trigger.split(' ');
  4572. triggers.forEach(function (trigger) {
  4573. if (trigger === 'click') {
  4574. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4575. return _this5.toggle(event);
  4576. });
  4577. } else if (trigger !== Trigger.MANUAL) {
  4578. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4579. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4580. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4581. return _this5._enter(event);
  4582. }).on(eventOut, _this5.config.selector, function (event) {
  4583. return _this5._leave(event);
  4584. });
  4585. }
  4586. });
  4587. this._hideModalHandler = function () {
  4588. if (_this5.element) {
  4589. _this5.hide();
  4590. }
  4591. };
  4592. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4593. if (this.config.selector) {
  4594. this.config = _objectSpread2({}, this.config, {
  4595. trigger: 'manual',
  4596. selector: ''
  4597. });
  4598. } else {
  4599. this._fixTitle();
  4600. }
  4601. };
  4602. _proto._fixTitle = function _fixTitle() {
  4603. var titleType = typeof this.element.getAttribute('data-original-title');
  4604. if (this.element.getAttribute('title') || titleType !== 'string') {
  4605. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4606. this.element.setAttribute('title', '');
  4607. }
  4608. };
  4609. _proto._enter = function _enter(event, context) {
  4610. var dataKey = this.constructor.DATA_KEY;
  4611. context = context || $(event.currentTarget).data(dataKey);
  4612. if (!context) {
  4613. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4614. $(event.currentTarget).data(dataKey, context);
  4615. }
  4616. if (event) {
  4617. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4618. }
  4619. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4620. context._hoverState = HoverState.SHOW;
  4621. return;
  4622. }
  4623. clearTimeout(context._timeout);
  4624. context._hoverState = HoverState.SHOW;
  4625. if (!context.config.delay || !context.config.delay.show) {
  4626. context.show();
  4627. return;
  4628. }
  4629. context._timeout = setTimeout(function () {
  4630. if (context._hoverState === HoverState.SHOW) {
  4631. context.show();
  4632. }
  4633. }, context.config.delay.show);
  4634. };
  4635. _proto._leave = function _leave(event, context) {
  4636. var dataKey = this.constructor.DATA_KEY;
  4637. context = context || $(event.currentTarget).data(dataKey);
  4638. if (!context) {
  4639. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4640. $(event.currentTarget).data(dataKey, context);
  4641. }
  4642. if (event) {
  4643. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4644. }
  4645. if (context._isWithActiveTrigger()) {
  4646. return;
  4647. }
  4648. clearTimeout(context._timeout);
  4649. context._hoverState = HoverState.OUT;
  4650. if (!context.config.delay || !context.config.delay.hide) {
  4651. context.hide();
  4652. return;
  4653. }
  4654. context._timeout = setTimeout(function () {
  4655. if (context._hoverState === HoverState.OUT) {
  4656. context.hide();
  4657. }
  4658. }, context.config.delay.hide);
  4659. };
  4660. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4661. for (var trigger in this._activeTrigger) {
  4662. if (this._activeTrigger[trigger]) {
  4663. return true;
  4664. }
  4665. }
  4666. return false;
  4667. };
  4668. _proto._getConfig = function _getConfig(config) {
  4669. var dataAttributes = $(this.element).data();
  4670. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4671. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4672. delete dataAttributes[dataAttr];
  4673. }
  4674. });
  4675. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4676. if (typeof config.delay === 'number') {
  4677. config.delay = {
  4678. show: config.delay,
  4679. hide: config.delay
  4680. };
  4681. }
  4682. if (typeof config.title === 'number') {
  4683. config.title = config.title.toString();
  4684. }
  4685. if (typeof config.content === 'number') {
  4686. config.content = config.content.toString();
  4687. }
  4688. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4689. if (config.sanitize) {
  4690. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4691. }
  4692. return config;
  4693. };
  4694. _proto._getDelegateConfig = function _getDelegateConfig() {
  4695. var config = {};
  4696. if (this.config) {
  4697. for (var key in this.config) {
  4698. if (this.constructor.Default[key] !== this.config[key]) {
  4699. config[key] = this.config[key];
  4700. }
  4701. }
  4702. }
  4703. return config;
  4704. };
  4705. _proto._cleanTipClass = function _cleanTipClass() {
  4706. var $tip = $(this.getTipElement());
  4707. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4708. if (tabClass !== null && tabClass.length) {
  4709. $tip.removeClass(tabClass.join(''));
  4710. }
  4711. };
  4712. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4713. var popperInstance = popperData.instance;
  4714. this.tip = popperInstance.popper;
  4715. this._cleanTipClass();
  4716. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4717. };
  4718. _proto._fixTransition = function _fixTransition() {
  4719. var tip = this.getTipElement();
  4720. var initConfigAnimation = this.config.animation;
  4721. if (tip.getAttribute('x-placement') !== null) {
  4722. return;
  4723. }
  4724. $(tip).removeClass(ClassName$6.FADE);
  4725. this.config.animation = false;
  4726. this.hide();
  4727. this.show();
  4728. this.config.animation = initConfigAnimation;
  4729. } // Static
  4730. ;
  4731. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4732. return this.each(function () {
  4733. var data = $(this).data(DATA_KEY$6);
  4734. var _config = typeof config === 'object' && config;
  4735. if (!data && /dispose|hide/.test(config)) {
  4736. return;
  4737. }
  4738. if (!data) {
  4739. data = new Tooltip(this, _config);
  4740. $(this).data(DATA_KEY$6, data);
  4741. }
  4742. if (typeof config === 'string') {
  4743. if (typeof data[config] === 'undefined') {
  4744. throw new TypeError("No method named \"" + config + "\"");
  4745. }
  4746. data[config]();
  4747. }
  4748. });
  4749. };
  4750. _createClass(Tooltip, null, [{
  4751. key: "VERSION",
  4752. get: function get() {
  4753. return VERSION$6;
  4754. }
  4755. }, {
  4756. key: "Default",
  4757. get: function get() {
  4758. return Default$4;
  4759. }
  4760. }, {
  4761. key: "NAME",
  4762. get: function get() {
  4763. return NAME$6;
  4764. }
  4765. }, {
  4766. key: "DATA_KEY",
  4767. get: function get() {
  4768. return DATA_KEY$6;
  4769. }
  4770. }, {
  4771. key: "Event",
  4772. get: function get() {
  4773. return Event$6;
  4774. }
  4775. }, {
  4776. key: "EVENT_KEY",
  4777. get: function get() {
  4778. return EVENT_KEY$6;
  4779. }
  4780. }, {
  4781. key: "DefaultType",
  4782. get: function get() {
  4783. return DefaultType$4;
  4784. }
  4785. }]);
  4786. return Tooltip;
  4787. }();
  4788. /**
  4789. * ------------------------------------------------------------------------
  4790. * jQuery
  4791. * ------------------------------------------------------------------------
  4792. */
  4793. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4794. $.fn[NAME$6].Constructor = Tooltip;
  4795. $.fn[NAME$6].noConflict = function () {
  4796. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4797. return Tooltip._jQueryInterface;
  4798. };
  4799. /**
  4800. * ------------------------------------------------------------------------
  4801. * Constants
  4802. * ------------------------------------------------------------------------
  4803. */
  4804. var NAME$7 = 'popover';
  4805. var VERSION$7 = '4.4.1';
  4806. var DATA_KEY$7 = 'bs.popover';
  4807. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4808. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4809. var CLASS_PREFIX$1 = 'bs-popover';
  4810. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4811. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4812. placement: 'right',
  4813. trigger: 'click',
  4814. content: '',
  4815. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4816. });
  4817. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4818. content: '(string|element|function)'
  4819. });
  4820. var ClassName$7 = {
  4821. FADE: 'fade',
  4822. SHOW: 'show'
  4823. };
  4824. var Selector$7 = {
  4825. TITLE: '.popover-header',
  4826. CONTENT: '.popover-body'
  4827. };
  4828. var Event$7 = {
  4829. HIDE: "hide" + EVENT_KEY$7,
  4830. HIDDEN: "hidden" + EVENT_KEY$7,
  4831. SHOW: "show" + EVENT_KEY$7,
  4832. SHOWN: "shown" + EVENT_KEY$7,
  4833. INSERTED: "inserted" + EVENT_KEY$7,
  4834. CLICK: "click" + EVENT_KEY$7,
  4835. FOCUSIN: "focusin" + EVENT_KEY$7,
  4836. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4837. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4838. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4839. };
  4840. /**
  4841. * ------------------------------------------------------------------------
  4842. * Class Definition
  4843. * ------------------------------------------------------------------------
  4844. */
  4845. var Popover =
  4846. /*#__PURE__*/
  4847. function (_Tooltip) {
  4848. _inheritsLoose(Popover, _Tooltip);
  4849. function Popover() {
  4850. return _Tooltip.apply(this, arguments) || this;
  4851. }
  4852. var _proto = Popover.prototype;
  4853. // Overrides
  4854. _proto.isWithContent = function isWithContent() {
  4855. return this.getTitle() || this._getContent();
  4856. };
  4857. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4858. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4859. };
  4860. _proto.getTipElement = function getTipElement() {
  4861. this.tip = this.tip || $(this.config.template)[0];
  4862. return this.tip;
  4863. };
  4864. _proto.setContent = function setContent() {
  4865. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4866. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4867. var content = this._getContent();
  4868. if (typeof content === 'function') {
  4869. content = content.call(this.element);
  4870. }
  4871. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4872. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4873. } // Private
  4874. ;
  4875. _proto._getContent = function _getContent() {
  4876. return this.element.getAttribute('data-content') || this.config.content;
  4877. };
  4878. _proto._cleanTipClass = function _cleanTipClass() {
  4879. var $tip = $(this.getTipElement());
  4880. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4881. if (tabClass !== null && tabClass.length > 0) {
  4882. $tip.removeClass(tabClass.join(''));
  4883. }
  4884. } // Static
  4885. ;
  4886. Popover._jQueryInterface = function _jQueryInterface(config) {
  4887. return this.each(function () {
  4888. var data = $(this).data(DATA_KEY$7);
  4889. var _config = typeof config === 'object' ? config : null;
  4890. if (!data && /dispose|hide/.test(config)) {
  4891. return;
  4892. }
  4893. if (!data) {
  4894. data = new Popover(this, _config);
  4895. $(this).data(DATA_KEY$7, data);
  4896. }
  4897. if (typeof config === 'string') {
  4898. if (typeof data[config] === 'undefined') {
  4899. throw new TypeError("No method named \"" + config + "\"");
  4900. }
  4901. data[config]();
  4902. }
  4903. });
  4904. };
  4905. _createClass(Popover, null, [{
  4906. key: "VERSION",
  4907. // Getters
  4908. get: function get() {
  4909. return VERSION$7;
  4910. }
  4911. }, {
  4912. key: "Default",
  4913. get: function get() {
  4914. return Default$5;
  4915. }
  4916. }, {
  4917. key: "NAME",
  4918. get: function get() {
  4919. return NAME$7;
  4920. }
  4921. }, {
  4922. key: "DATA_KEY",
  4923. get: function get() {
  4924. return DATA_KEY$7;
  4925. }
  4926. }, {
  4927. key: "Event",
  4928. get: function get() {
  4929. return Event$7;
  4930. }
  4931. }, {
  4932. key: "EVENT_KEY",
  4933. get: function get() {
  4934. return EVENT_KEY$7;
  4935. }
  4936. }, {
  4937. key: "DefaultType",
  4938. get: function get() {
  4939. return DefaultType$5;
  4940. }
  4941. }]);
  4942. return Popover;
  4943. }(Tooltip);
  4944. /**
  4945. * ------------------------------------------------------------------------
  4946. * jQuery
  4947. * ------------------------------------------------------------------------
  4948. */
  4949. $.fn[NAME$7] = Popover._jQueryInterface;
  4950. $.fn[NAME$7].Constructor = Popover;
  4951. $.fn[NAME$7].noConflict = function () {
  4952. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4953. return Popover._jQueryInterface;
  4954. };
  4955. /**
  4956. * ------------------------------------------------------------------------
  4957. * Constants
  4958. * ------------------------------------------------------------------------
  4959. */
  4960. var NAME$8 = 'scrollspy';
  4961. var VERSION$8 = '4.4.1';
  4962. var DATA_KEY$8 = 'bs.scrollspy';
  4963. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4964. var DATA_API_KEY$6 = '.data-api';
  4965. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4966. var Default$6 = {
  4967. offset: 10,
  4968. method: 'auto',
  4969. target: ''
  4970. };
  4971. var DefaultType$6 = {
  4972. offset: 'number',
  4973. method: 'string',
  4974. target: '(string|element)'
  4975. };
  4976. var Event$8 = {
  4977. ACTIVATE: "activate" + EVENT_KEY$8,
  4978. SCROLL: "scroll" + EVENT_KEY$8,
  4979. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4980. };
  4981. var ClassName$8 = {
  4982. DROPDOWN_ITEM: 'dropdown-item',
  4983. DROPDOWN_MENU: 'dropdown-menu',
  4984. ACTIVE: 'active'
  4985. };
  4986. var Selector$8 = {
  4987. DATA_SPY: '[data-spy="scroll"]',
  4988. ACTIVE: '.active',
  4989. NAV_LIST_GROUP: '.nav, .list-group',
  4990. NAV_LINKS: '.nav-link',
  4991. NAV_ITEMS: '.nav-item',
  4992. LIST_ITEMS: '.list-group-item',
  4993. DROPDOWN: '.dropdown',
  4994. DROPDOWN_ITEMS: '.dropdown-item',
  4995. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4996. };
  4997. var OffsetMethod = {
  4998. OFFSET: 'offset',
  4999. POSITION: 'position'
  5000. };
  5001. /**
  5002. * ------------------------------------------------------------------------
  5003. * Class Definition
  5004. * ------------------------------------------------------------------------
  5005. */
  5006. var ScrollSpy =
  5007. /*#__PURE__*/
  5008. function () {
  5009. function ScrollSpy(element, config) {
  5010. var _this = this;
  5011. this._element = element;
  5012. this._scrollElement = element.tagName === 'BODY' ? window : element;
  5013. this._config = this._getConfig(config);
  5014. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  5015. this._offsets = [];
  5016. this._targets = [];
  5017. this._activeTarget = null;
  5018. this._scrollHeight = 0;
  5019. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  5020. return _this._process(event);
  5021. });
  5022. this.refresh();
  5023. this._process();
  5024. } // Getters
  5025. var _proto = ScrollSpy.prototype;
  5026. // Public
  5027. _proto.refresh = function refresh() {
  5028. var _this2 = this;
  5029. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  5030. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  5031. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  5032. this._offsets = [];
  5033. this._targets = [];
  5034. this._scrollHeight = this._getScrollHeight();
  5035. var targets = [].slice.call(document.querySelectorAll(this._selector));
  5036. targets.map(function (element) {
  5037. var target;
  5038. var targetSelector = Util.getSelectorFromElement(element);
  5039. if (targetSelector) {
  5040. target = document.querySelector(targetSelector);
  5041. }
  5042. if (target) {
  5043. var targetBCR = target.getBoundingClientRect();
  5044. if (targetBCR.width || targetBCR.height) {
  5045. // TODO (fat): remove sketch reliance on jQuery position/offset
  5046. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  5047. }
  5048. }
  5049. return null;
  5050. }).filter(function (item) {
  5051. return item;
  5052. }).sort(function (a, b) {
  5053. return a[0] - b[0];
  5054. }).forEach(function (item) {
  5055. _this2._offsets.push(item[0]);
  5056. _this2._targets.push(item[1]);
  5057. });
  5058. };
  5059. _proto.dispose = function dispose() {
  5060. $.removeData(this._element, DATA_KEY$8);
  5061. $(this._scrollElement).off(EVENT_KEY$8);
  5062. this._element = null;
  5063. this._scrollElement = null;
  5064. this._config = null;
  5065. this._selector = null;
  5066. this._offsets = null;
  5067. this._targets = null;
  5068. this._activeTarget = null;
  5069. this._scrollHeight = null;
  5070. } // Private
  5071. ;
  5072. _proto._getConfig = function _getConfig(config) {
  5073. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  5074. if (typeof config.target !== 'string') {
  5075. var id = $(config.target).attr('id');
  5076. if (!id) {
  5077. id = Util.getUID(NAME$8);
  5078. $(config.target).attr('id', id);
  5079. }
  5080. config.target = "#" + id;
  5081. }
  5082. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  5083. return config;
  5084. };
  5085. _proto._getScrollTop = function _getScrollTop() {
  5086. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  5087. };
  5088. _proto._getScrollHeight = function _getScrollHeight() {
  5089. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  5090. };
  5091. _proto._getOffsetHeight = function _getOffsetHeight() {
  5092. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  5093. };
  5094. _proto._process = function _process() {
  5095. var scrollTop = this._getScrollTop() + this._config.offset;
  5096. var scrollHeight = this._getScrollHeight();
  5097. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5098. if (this._scrollHeight !== scrollHeight) {
  5099. this.refresh();
  5100. }
  5101. if (scrollTop >= maxScroll) {
  5102. var target = this._targets[this._targets.length - 1];
  5103. if (this._activeTarget !== target) {
  5104. this._activate(target);
  5105. }
  5106. return;
  5107. }
  5108. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5109. this._activeTarget = null;
  5110. this._clear();
  5111. return;
  5112. }
  5113. var offsetLength = this._offsets.length;
  5114. for (var i = offsetLength; i--;) {
  5115. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5116. if (isActiveTarget) {
  5117. this._activate(this._targets[i]);
  5118. }
  5119. }
  5120. };
  5121. _proto._activate = function _activate(target) {
  5122. this._activeTarget = target;
  5123. this._clear();
  5124. var queries = this._selector.split(',').map(function (selector) {
  5125. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5126. });
  5127. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5128. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5129. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5130. $link.addClass(ClassName$8.ACTIVE);
  5131. } else {
  5132. // Set triggered link as active
  5133. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5134. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5135. $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
  5136. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5137. }
  5138. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5139. relatedTarget: target
  5140. });
  5141. };
  5142. _proto._clear = function _clear() {
  5143. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5144. return node.classList.contains(ClassName$8.ACTIVE);
  5145. }).forEach(function (node) {
  5146. return node.classList.remove(ClassName$8.ACTIVE);
  5147. });
  5148. } // Static
  5149. ;
  5150. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5151. return this.each(function () {
  5152. var data = $(this).data(DATA_KEY$8);
  5153. var _config = typeof config === 'object' && config;
  5154. if (!data) {
  5155. data = new ScrollSpy(this, _config);
  5156. $(this).data(DATA_KEY$8, data);
  5157. }
  5158. if (typeof config === 'string') {
  5159. if (typeof data[config] === 'undefined') {
  5160. throw new TypeError("No method named \"" + config + "\"");
  5161. }
  5162. data[config]();
  5163. }
  5164. });
  5165. };
  5166. _createClass(ScrollSpy, null, [{
  5167. key: "VERSION",
  5168. get: function get() {
  5169. return VERSION$8;
  5170. }
  5171. }, {
  5172. key: "Default",
  5173. get: function get() {
  5174. return Default$6;
  5175. }
  5176. }]);
  5177. return ScrollSpy;
  5178. }();
  5179. /**
  5180. * ------------------------------------------------------------------------
  5181. * Data Api implementation
  5182. * ------------------------------------------------------------------------
  5183. */
  5184. $(window).on(Event$8.LOAD_DATA_API, function () {
  5185. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5186. var scrollSpysLength = scrollSpys.length;
  5187. for (var i = scrollSpysLength; i--;) {
  5188. var $spy = $(scrollSpys[i]);
  5189. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5190. }
  5191. });
  5192. /**
  5193. * ------------------------------------------------------------------------
  5194. * jQuery
  5195. * ------------------------------------------------------------------------
  5196. */
  5197. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5198. $.fn[NAME$8].Constructor = ScrollSpy;
  5199. $.fn[NAME$8].noConflict = function () {
  5200. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5201. return ScrollSpy._jQueryInterface;
  5202. };
  5203. /**
  5204. * ------------------------------------------------------------------------
  5205. * Constants
  5206. * ------------------------------------------------------------------------
  5207. */
  5208. var NAME$9 = 'tab';
  5209. var VERSION$9 = '4.4.1';
  5210. var DATA_KEY$9 = 'bs.tab';
  5211. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5212. var DATA_API_KEY$7 = '.data-api';
  5213. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5214. var Event$9 = {
  5215. HIDE: "hide" + EVENT_KEY$9,
  5216. HIDDEN: "hidden" + EVENT_KEY$9,
  5217. SHOW: "show" + EVENT_KEY$9,
  5218. SHOWN: "shown" + EVENT_KEY$9,
  5219. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5220. };
  5221. var ClassName$9 = {
  5222. DROPDOWN_MENU: 'dropdown-menu',
  5223. ACTIVE: 'active',
  5224. DISABLED: 'disabled',
  5225. FADE: 'fade',
  5226. SHOW: 'show'
  5227. };
  5228. var Selector$9 = {
  5229. DROPDOWN: '.dropdown',
  5230. NAV_LIST_GROUP: '.nav, .list-group',
  5231. ACTIVE: '.active',
  5232. ACTIVE_UL: '> li > .active',
  5233. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5234. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5235. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5236. };
  5237. /**
  5238. * ------------------------------------------------------------------------
  5239. * Class Definition
  5240. * ------------------------------------------------------------------------
  5241. */
  5242. var Tab =
  5243. /*#__PURE__*/
  5244. function () {
  5245. function Tab(element) {
  5246. this._element = element;
  5247. } // Getters
  5248. var _proto = Tab.prototype;
  5249. // Public
  5250. _proto.show = function show() {
  5251. var _this = this;
  5252. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5253. return;
  5254. }
  5255. var target;
  5256. var previous;
  5257. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5258. var selector = Util.getSelectorFromElement(this._element);
  5259. if (listElement) {
  5260. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5261. previous = $.makeArray($(listElement).find(itemSelector));
  5262. previous = previous[previous.length - 1];
  5263. }
  5264. var hideEvent = $.Event(Event$9.HIDE, {
  5265. relatedTarget: this._element
  5266. });
  5267. var showEvent = $.Event(Event$9.SHOW, {
  5268. relatedTarget: previous
  5269. });
  5270. if (previous) {
  5271. $(previous).trigger(hideEvent);
  5272. }
  5273. $(this._element).trigger(showEvent);
  5274. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5275. return;
  5276. }
  5277. if (selector) {
  5278. target = document.querySelector(selector);
  5279. }
  5280. this._activate(this._element, listElement);
  5281. var complete = function complete() {
  5282. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5283. relatedTarget: _this._element
  5284. });
  5285. var shownEvent = $.Event(Event$9.SHOWN, {
  5286. relatedTarget: previous
  5287. });
  5288. $(previous).trigger(hiddenEvent);
  5289. $(_this._element).trigger(shownEvent);
  5290. };
  5291. if (target) {
  5292. this._activate(target, target.parentNode, complete);
  5293. } else {
  5294. complete();
  5295. }
  5296. };
  5297. _proto.dispose = function dispose() {
  5298. $.removeData(this._element, DATA_KEY$9);
  5299. this._element = null;
  5300. } // Private
  5301. ;
  5302. _proto._activate = function _activate(element, container, callback) {
  5303. var _this2 = this;
  5304. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5305. var active = activeElements[0];
  5306. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5307. var complete = function complete() {
  5308. return _this2._transitionComplete(element, active, callback);
  5309. };
  5310. if (active && isTransitioning) {
  5311. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5312. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5313. } else {
  5314. complete();
  5315. }
  5316. };
  5317. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5318. if (active) {
  5319. $(active).removeClass(ClassName$9.ACTIVE);
  5320. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5321. if (dropdownChild) {
  5322. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5323. }
  5324. if (active.getAttribute('role') === 'tab') {
  5325. active.setAttribute('aria-selected', false);
  5326. }
  5327. }
  5328. $(element).addClass(ClassName$9.ACTIVE);
  5329. if (element.getAttribute('role') === 'tab') {
  5330. element.setAttribute('aria-selected', true);
  5331. }
  5332. Util.reflow(element);
  5333. if (element.classList.contains(ClassName$9.FADE)) {
  5334. element.classList.add(ClassName$9.SHOW);
  5335. }
  5336. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5337. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5338. if (dropdownElement) {
  5339. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5340. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5341. }
  5342. element.setAttribute('aria-expanded', true);
  5343. }
  5344. if (callback) {
  5345. callback();
  5346. }
  5347. } // Static
  5348. ;
  5349. Tab._jQueryInterface = function _jQueryInterface(config) {
  5350. return this.each(function () {
  5351. var $this = $(this);
  5352. var data = $this.data(DATA_KEY$9);
  5353. if (!data) {
  5354. data = new Tab(this);
  5355. $this.data(DATA_KEY$9, data);
  5356. }
  5357. if (typeof config === 'string') {
  5358. if (typeof data[config] === 'undefined') {
  5359. throw new TypeError("No method named \"" + config + "\"");
  5360. }
  5361. data[config]();
  5362. }
  5363. });
  5364. };
  5365. _createClass(Tab, null, [{
  5366. key: "VERSION",
  5367. get: function get() {
  5368. return VERSION$9;
  5369. }
  5370. }]);
  5371. return Tab;
  5372. }();
  5373. /**
  5374. * ------------------------------------------------------------------------
  5375. * Data Api implementation
  5376. * ------------------------------------------------------------------------
  5377. */
  5378. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5379. event.preventDefault();
  5380. Tab._jQueryInterface.call($(this), 'show');
  5381. });
  5382. /**
  5383. * ------------------------------------------------------------------------
  5384. * jQuery
  5385. * ------------------------------------------------------------------------
  5386. */
  5387. $.fn[NAME$9] = Tab._jQueryInterface;
  5388. $.fn[NAME$9].Constructor = Tab;
  5389. $.fn[NAME$9].noConflict = function () {
  5390. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5391. return Tab._jQueryInterface;
  5392. };
  5393. /**
  5394. * ------------------------------------------------------------------------
  5395. * Constants
  5396. * ------------------------------------------------------------------------
  5397. */
  5398. var NAME$a = 'toast';
  5399. var VERSION$a = '4.4.1';
  5400. var DATA_KEY$a = 'bs.toast';
  5401. var EVENT_KEY$a = "." + DATA_KEY$a;
  5402. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5403. var Event$a = {
  5404. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5405. HIDE: "hide" + EVENT_KEY$a,
  5406. HIDDEN: "hidden" + EVENT_KEY$a,
  5407. SHOW: "show" + EVENT_KEY$a,
  5408. SHOWN: "shown" + EVENT_KEY$a
  5409. };
  5410. var ClassName$a = {
  5411. FADE: 'fade',
  5412. HIDE: 'hide',
  5413. SHOW: 'show',
  5414. SHOWING: 'showing'
  5415. };
  5416. var DefaultType$7 = {
  5417. animation: 'boolean',
  5418. autohide: 'boolean',
  5419. delay: 'number'
  5420. };
  5421. var Default$7 = {
  5422. animation: true,
  5423. autohide: true,
  5424. delay: 500
  5425. };
  5426. var Selector$a = {
  5427. DATA_DISMISS: '[data-dismiss="toast"]'
  5428. };
  5429. /**
  5430. * ------------------------------------------------------------------------
  5431. * Class Definition
  5432. * ------------------------------------------------------------------------
  5433. */
  5434. var Toast =
  5435. /*#__PURE__*/
  5436. function () {
  5437. function Toast(element, config) {
  5438. this._element = element;
  5439. this._config = this._getConfig(config);
  5440. this._timeout = null;
  5441. this._setListeners();
  5442. } // Getters
  5443. var _proto = Toast.prototype;
  5444. // Public
  5445. _proto.show = function show() {
  5446. var _this = this;
  5447. var showEvent = $.Event(Event$a.SHOW);
  5448. $(this._element).trigger(showEvent);
  5449. if (showEvent.isDefaultPrevented()) {
  5450. return;
  5451. }
  5452. if (this._config.animation) {
  5453. this._element.classList.add(ClassName$a.FADE);
  5454. }
  5455. var complete = function complete() {
  5456. _this._element.classList.remove(ClassName$a.SHOWING);
  5457. _this._element.classList.add(ClassName$a.SHOW);
  5458. $(_this._element).trigger(Event$a.SHOWN);
  5459. if (_this._config.autohide) {
  5460. _this._timeout = setTimeout(function () {
  5461. _this.hide();
  5462. }, _this._config.delay);
  5463. }
  5464. };
  5465. this._element.classList.remove(ClassName$a.HIDE);
  5466. Util.reflow(this._element);
  5467. this._element.classList.add(ClassName$a.SHOWING);
  5468. if (this._config.animation) {
  5469. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5470. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5471. } else {
  5472. complete();
  5473. }
  5474. };
  5475. _proto.hide = function hide() {
  5476. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5477. return;
  5478. }
  5479. var hideEvent = $.Event(Event$a.HIDE);
  5480. $(this._element).trigger(hideEvent);
  5481. if (hideEvent.isDefaultPrevented()) {
  5482. return;
  5483. }
  5484. this._close();
  5485. };
  5486. _proto.dispose = function dispose() {
  5487. clearTimeout(this._timeout);
  5488. this._timeout = null;
  5489. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5490. this._element.classList.remove(ClassName$a.SHOW);
  5491. }
  5492. $(this._element).off(Event$a.CLICK_DISMISS);
  5493. $.removeData(this._element, DATA_KEY$a);
  5494. this._element = null;
  5495. this._config = null;
  5496. } // Private
  5497. ;
  5498. _proto._getConfig = function _getConfig(config) {
  5499. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5500. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5501. return config;
  5502. };
  5503. _proto._setListeners = function _setListeners() {
  5504. var _this2 = this;
  5505. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5506. return _this2.hide();
  5507. });
  5508. };
  5509. _proto._close = function _close() {
  5510. var _this3 = this;
  5511. var complete = function complete() {
  5512. _this3._element.classList.add(ClassName$a.HIDE);
  5513. $(_this3._element).trigger(Event$a.HIDDEN);
  5514. };
  5515. this._element.classList.remove(ClassName$a.SHOW);
  5516. if (this._config.animation) {
  5517. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5518. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5519. } else {
  5520. complete();
  5521. }
  5522. } // Static
  5523. ;
  5524. Toast._jQueryInterface = function _jQueryInterface(config) {
  5525. return this.each(function () {
  5526. var $element = $(this);
  5527. var data = $element.data(DATA_KEY$a);
  5528. var _config = typeof config === 'object' && config;
  5529. if (!data) {
  5530. data = new Toast(this, _config);
  5531. $element.data(DATA_KEY$a, data);
  5532. }
  5533. if (typeof config === 'string') {
  5534. if (typeof data[config] === 'undefined') {
  5535. throw new TypeError("No method named \"" + config + "\"");
  5536. }
  5537. data[config](this);
  5538. }
  5539. });
  5540. };
  5541. _createClass(Toast, null, [{
  5542. key: "VERSION",
  5543. get: function get() {
  5544. return VERSION$a;
  5545. }
  5546. }, {
  5547. key: "DefaultType",
  5548. get: function get() {
  5549. return DefaultType$7;
  5550. }
  5551. }, {
  5552. key: "Default",
  5553. get: function get() {
  5554. return Default$7;
  5555. }
  5556. }]);
  5557. return Toast;
  5558. }();
  5559. /**
  5560. * ------------------------------------------------------------------------
  5561. * jQuery
  5562. * ------------------------------------------------------------------------
  5563. */
  5564. $.fn[NAME$a] = Toast._jQueryInterface;
  5565. $.fn[NAME$a].Constructor = Toast;
  5566. $.fn[NAME$a].noConflict = function () {
  5567. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5568. return Toast._jQueryInterface;
  5569. };
  5570. exports.Alert = Alert;
  5571. exports.Button = Button;
  5572. exports.Carousel = Carousel;
  5573. exports.Collapse = Collapse;
  5574. exports.Dropdown = Dropdown;
  5575. exports.Modal = Modal;
  5576. exports.Popover = Popover;
  5577. exports.Scrollspy = ScrollSpy;
  5578. exports.Tab = Tab;
  5579. exports.Toast = Toast;
  5580. exports.Tooltip = Tooltip;
  5581. exports.Util = Util;
  5582. Object.defineProperty(exports, '__esModule', { value: true });
  5583. })));
  5584. //# sourceMappingURL=bootstrap.js.map
  5585. /***/ }),
  5586. /***/ "./node_modules/buffer/index.js":
  5587. /*!**************************************!*\
  5588. !*** ./node_modules/buffer/index.js ***!
  5589. \**************************************/
  5590. /*! no static exports found */
  5591. /***/ (function(module, exports, __webpack_require__) {
  5592. "use strict";
  5593. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5594. * The buffer module from node.js, for the browser.
  5595. *
  5596. * @author Feross Aboukhadijeh <http://feross.org>
  5597. * @license MIT
  5598. */
  5599. /* eslint-disable no-proto */
  5600. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5601. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5602. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5603. exports.Buffer = Buffer
  5604. exports.SlowBuffer = SlowBuffer
  5605. exports.INSPECT_MAX_BYTES = 50
  5606. /**
  5607. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5608. * === true Use Uint8Array implementation (fastest)
  5609. * === false Use Object implementation (most compatible, even IE6)
  5610. *
  5611. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5612. * Opera 11.6+, iOS 4.2+.
  5613. *
  5614. * Due to various browser bugs, sometimes the Object implementation will be used even
  5615. * when the browser supports typed arrays.
  5616. *
  5617. * Note:
  5618. *
  5619. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5620. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5621. *
  5622. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5623. *
  5624. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5625. * incorrect length in some situations.
  5626. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5627. * get the Object implementation, which is slower but behaves correctly.
  5628. */
  5629. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5630. ? global.TYPED_ARRAY_SUPPORT
  5631. : typedArraySupport()
  5632. /*
  5633. * Export kMaxLength after typed array support is determined.
  5634. */
  5635. exports.kMaxLength = kMaxLength()
  5636. function typedArraySupport () {
  5637. try {
  5638. var arr = new Uint8Array(1)
  5639. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5640. return arr.foo() === 42 && // typed array instances can be augmented
  5641. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5642. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5643. } catch (e) {
  5644. return false
  5645. }
  5646. }
  5647. function kMaxLength () {
  5648. return Buffer.TYPED_ARRAY_SUPPORT
  5649. ? 0x7fffffff
  5650. : 0x3fffffff
  5651. }
  5652. function createBuffer (that, length) {
  5653. if (kMaxLength() < length) {
  5654. throw new RangeError('Invalid typed array length')
  5655. }
  5656. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5657. // Return an augmented `Uint8Array` instance, for best performance
  5658. that = new Uint8Array(length)
  5659. that.__proto__ = Buffer.prototype
  5660. } else {
  5661. // Fallback: Return an object instance of the Buffer class
  5662. if (that === null) {
  5663. that = new Buffer(length)
  5664. }
  5665. that.length = length
  5666. }
  5667. return that
  5668. }
  5669. /**
  5670. * The Buffer constructor returns instances of `Uint8Array` that have their
  5671. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5672. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5673. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5674. * returns a single octet.
  5675. *
  5676. * The `Uint8Array` prototype remains unmodified.
  5677. */
  5678. function Buffer (arg, encodingOrOffset, length) {
  5679. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5680. return new Buffer(arg, encodingOrOffset, length)
  5681. }
  5682. // Common case.
  5683. if (typeof arg === 'number') {
  5684. if (typeof encodingOrOffset === 'string') {
  5685. throw new Error(
  5686. 'If encoding is specified then the first argument must be a string'
  5687. )
  5688. }
  5689. return allocUnsafe(this, arg)
  5690. }
  5691. return from(this, arg, encodingOrOffset, length)
  5692. }
  5693. Buffer.poolSize = 8192 // not used by this implementation
  5694. // TODO: Legacy, not needed anymore. Remove in next major version.
  5695. Buffer._augment = function (arr) {
  5696. arr.__proto__ = Buffer.prototype
  5697. return arr
  5698. }
  5699. function from (that, value, encodingOrOffset, length) {
  5700. if (typeof value === 'number') {
  5701. throw new TypeError('"value" argument must not be a number')
  5702. }
  5703. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5704. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5705. }
  5706. if (typeof value === 'string') {
  5707. return fromString(that, value, encodingOrOffset)
  5708. }
  5709. return fromObject(that, value)
  5710. }
  5711. /**
  5712. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5713. * if value is a number.
  5714. * Buffer.from(str[, encoding])
  5715. * Buffer.from(array)
  5716. * Buffer.from(buffer)
  5717. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5718. **/
  5719. Buffer.from = function (value, encodingOrOffset, length) {
  5720. return from(null, value, encodingOrOffset, length)
  5721. }
  5722. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5723. Buffer.prototype.__proto__ = Uint8Array.prototype
  5724. Buffer.__proto__ = Uint8Array
  5725. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5726. Buffer[Symbol.species] === Buffer) {
  5727. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5728. Object.defineProperty(Buffer, Symbol.species, {
  5729. value: null,
  5730. configurable: true
  5731. })
  5732. }
  5733. }
  5734. function assertSize (size) {
  5735. if (typeof size !== 'number') {
  5736. throw new TypeError('"size" argument must be a number')
  5737. } else if (size < 0) {
  5738. throw new RangeError('"size" argument must not be negative')
  5739. }
  5740. }
  5741. function alloc (that, size, fill, encoding) {
  5742. assertSize(size)
  5743. if (size <= 0) {
  5744. return createBuffer(that, size)
  5745. }
  5746. if (fill !== undefined) {
  5747. // Only pay attention to encoding if it's a string. This
  5748. // prevents accidentally sending in a number that would
  5749. // be interpretted as a start offset.
  5750. return typeof encoding === 'string'
  5751. ? createBuffer(that, size).fill(fill, encoding)
  5752. : createBuffer(that, size).fill(fill)
  5753. }
  5754. return createBuffer(that, size)
  5755. }
  5756. /**
  5757. * Creates a new filled Buffer instance.
  5758. * alloc(size[, fill[, encoding]])
  5759. **/
  5760. Buffer.alloc = function (size, fill, encoding) {
  5761. return alloc(null, size, fill, encoding)
  5762. }
  5763. function allocUnsafe (that, size) {
  5764. assertSize(size)
  5765. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5766. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5767. for (var i = 0; i < size; ++i) {
  5768. that[i] = 0
  5769. }
  5770. }
  5771. return that
  5772. }
  5773. /**
  5774. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5775. * */
  5776. Buffer.allocUnsafe = function (size) {
  5777. return allocUnsafe(null, size)
  5778. }
  5779. /**
  5780. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5781. */
  5782. Buffer.allocUnsafeSlow = function (size) {
  5783. return allocUnsafe(null, size)
  5784. }
  5785. function fromString (that, string, encoding) {
  5786. if (typeof encoding !== 'string' || encoding === '') {
  5787. encoding = 'utf8'
  5788. }
  5789. if (!Buffer.isEncoding(encoding)) {
  5790. throw new TypeError('"encoding" must be a valid string encoding')
  5791. }
  5792. var length = byteLength(string, encoding) | 0
  5793. that = createBuffer(that, length)
  5794. var actual = that.write(string, encoding)
  5795. if (actual !== length) {
  5796. // Writing a hex string, for example, that contains invalid characters will
  5797. // cause everything after the first invalid character to be ignored. (e.g.
  5798. // 'abxxcd' will be treated as 'ab')
  5799. that = that.slice(0, actual)
  5800. }
  5801. return that
  5802. }
  5803. function fromArrayLike (that, array) {
  5804. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5805. that = createBuffer(that, length)
  5806. for (var i = 0; i < length; i += 1) {
  5807. that[i] = array[i] & 255
  5808. }
  5809. return that
  5810. }
  5811. function fromArrayBuffer (that, array, byteOffset, length) {
  5812. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5813. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5814. throw new RangeError('\'offset\' is out of bounds')
  5815. }
  5816. if (array.byteLength < byteOffset + (length || 0)) {
  5817. throw new RangeError('\'length\' is out of bounds')
  5818. }
  5819. if (byteOffset === undefined && length === undefined) {
  5820. array = new Uint8Array(array)
  5821. } else if (length === undefined) {
  5822. array = new Uint8Array(array, byteOffset)
  5823. } else {
  5824. array = new Uint8Array(array, byteOffset, length)
  5825. }
  5826. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5827. // Return an augmented `Uint8Array` instance, for best performance
  5828. that = array
  5829. that.__proto__ = Buffer.prototype
  5830. } else {
  5831. // Fallback: Return an object instance of the Buffer class
  5832. that = fromArrayLike(that, array)
  5833. }
  5834. return that
  5835. }
  5836. function fromObject (that, obj) {
  5837. if (Buffer.isBuffer(obj)) {
  5838. var len = checked(obj.length) | 0
  5839. that = createBuffer(that, len)
  5840. if (that.length === 0) {
  5841. return that
  5842. }
  5843. obj.copy(that, 0, 0, len)
  5844. return that
  5845. }
  5846. if (obj) {
  5847. if ((typeof ArrayBuffer !== 'undefined' &&
  5848. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5849. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5850. return createBuffer(that, 0)
  5851. }
  5852. return fromArrayLike(that, obj)
  5853. }
  5854. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5855. return fromArrayLike(that, obj.data)
  5856. }
  5857. }
  5858. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5859. }
  5860. function checked (length) {
  5861. // Note: cannot use `length < kMaxLength()` here because that fails when
  5862. // length is NaN (which is otherwise coerced to zero.)
  5863. if (length >= kMaxLength()) {
  5864. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5865. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5866. }
  5867. return length | 0
  5868. }
  5869. function SlowBuffer (length) {
  5870. if (+length != length) { // eslint-disable-line eqeqeq
  5871. length = 0
  5872. }
  5873. return Buffer.alloc(+length)
  5874. }
  5875. Buffer.isBuffer = function isBuffer (b) {
  5876. return !!(b != null && b._isBuffer)
  5877. }
  5878. Buffer.compare = function compare (a, b) {
  5879. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5880. throw new TypeError('Arguments must be Buffers')
  5881. }
  5882. if (a === b) return 0
  5883. var x = a.length
  5884. var y = b.length
  5885. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5886. if (a[i] !== b[i]) {
  5887. x = a[i]
  5888. y = b[i]
  5889. break
  5890. }
  5891. }
  5892. if (x < y) return -1
  5893. if (y < x) return 1
  5894. return 0
  5895. }
  5896. Buffer.isEncoding = function isEncoding (encoding) {
  5897. switch (String(encoding).toLowerCase()) {
  5898. case 'hex':
  5899. case 'utf8':
  5900. case 'utf-8':
  5901. case 'ascii':
  5902. case 'latin1':
  5903. case 'binary':
  5904. case 'base64':
  5905. case 'ucs2':
  5906. case 'ucs-2':
  5907. case 'utf16le':
  5908. case 'utf-16le':
  5909. return true
  5910. default:
  5911. return false
  5912. }
  5913. }
  5914. Buffer.concat = function concat (list, length) {
  5915. if (!isArray(list)) {
  5916. throw new TypeError('"list" argument must be an Array of Buffers')
  5917. }
  5918. if (list.length === 0) {
  5919. return Buffer.alloc(0)
  5920. }
  5921. var i
  5922. if (length === undefined) {
  5923. length = 0
  5924. for (i = 0; i < list.length; ++i) {
  5925. length += list[i].length
  5926. }
  5927. }
  5928. var buffer = Buffer.allocUnsafe(length)
  5929. var pos = 0
  5930. for (i = 0; i < list.length; ++i) {
  5931. var buf = list[i]
  5932. if (!Buffer.isBuffer(buf)) {
  5933. throw new TypeError('"list" argument must be an Array of Buffers')
  5934. }
  5935. buf.copy(buffer, pos)
  5936. pos += buf.length
  5937. }
  5938. return buffer
  5939. }
  5940. function byteLength (string, encoding) {
  5941. if (Buffer.isBuffer(string)) {
  5942. return string.length
  5943. }
  5944. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5945. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5946. return string.byteLength
  5947. }
  5948. if (typeof string !== 'string') {
  5949. string = '' + string
  5950. }
  5951. var len = string.length
  5952. if (len === 0) return 0
  5953. // Use a for loop to avoid recursion
  5954. var loweredCase = false
  5955. for (;;) {
  5956. switch (encoding) {
  5957. case 'ascii':
  5958. case 'latin1':
  5959. case 'binary':
  5960. return len
  5961. case 'utf8':
  5962. case 'utf-8':
  5963. case undefined:
  5964. return utf8ToBytes(string).length
  5965. case 'ucs2':
  5966. case 'ucs-2':
  5967. case 'utf16le':
  5968. case 'utf-16le':
  5969. return len * 2
  5970. case 'hex':
  5971. return len >>> 1
  5972. case 'base64':
  5973. return base64ToBytes(string).length
  5974. default:
  5975. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5976. encoding = ('' + encoding).toLowerCase()
  5977. loweredCase = true
  5978. }
  5979. }
  5980. }
  5981. Buffer.byteLength = byteLength
  5982. function slowToString (encoding, start, end) {
  5983. var loweredCase = false
  5984. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5985. // property of a typed array.
  5986. // This behaves neither like String nor Uint8Array in that we set start/end
  5987. // to their upper/lower bounds if the value passed is out of range.
  5988. // undefined is handled specially as per ECMA-262 6th Edition,
  5989. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5990. if (start === undefined || start < 0) {
  5991. start = 0
  5992. }
  5993. // Return early if start > this.length. Done here to prevent potential uint32
  5994. // coercion fail below.
  5995. if (start > this.length) {
  5996. return ''
  5997. }
  5998. if (end === undefined || end > this.length) {
  5999. end = this.length
  6000. }
  6001. if (end <= 0) {
  6002. return ''
  6003. }
  6004. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  6005. end >>>= 0
  6006. start >>>= 0
  6007. if (end <= start) {
  6008. return ''
  6009. }
  6010. if (!encoding) encoding = 'utf8'
  6011. while (true) {
  6012. switch (encoding) {
  6013. case 'hex':
  6014. return hexSlice(this, start, end)
  6015. case 'utf8':
  6016. case 'utf-8':
  6017. return utf8Slice(this, start, end)
  6018. case 'ascii':
  6019. return asciiSlice(this, start, end)
  6020. case 'latin1':
  6021. case 'binary':
  6022. return latin1Slice(this, start, end)
  6023. case 'base64':
  6024. return base64Slice(this, start, end)
  6025. case 'ucs2':
  6026. case 'ucs-2':
  6027. case 'utf16le':
  6028. case 'utf-16le':
  6029. return utf16leSlice(this, start, end)
  6030. default:
  6031. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6032. encoding = (encoding + '').toLowerCase()
  6033. loweredCase = true
  6034. }
  6035. }
  6036. }
  6037. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  6038. // Buffer instances.
  6039. Buffer.prototype._isBuffer = true
  6040. function swap (b, n, m) {
  6041. var i = b[n]
  6042. b[n] = b[m]
  6043. b[m] = i
  6044. }
  6045. Buffer.prototype.swap16 = function swap16 () {
  6046. var len = this.length
  6047. if (len % 2 !== 0) {
  6048. throw new RangeError('Buffer size must be a multiple of 16-bits')
  6049. }
  6050. for (var i = 0; i < len; i += 2) {
  6051. swap(this, i, i + 1)
  6052. }
  6053. return this
  6054. }
  6055. Buffer.prototype.swap32 = function swap32 () {
  6056. var len = this.length
  6057. if (len % 4 !== 0) {
  6058. throw new RangeError('Buffer size must be a multiple of 32-bits')
  6059. }
  6060. for (var i = 0; i < len; i += 4) {
  6061. swap(this, i, i + 3)
  6062. swap(this, i + 1, i + 2)
  6063. }
  6064. return this
  6065. }
  6066. Buffer.prototype.swap64 = function swap64 () {
  6067. var len = this.length
  6068. if (len % 8 !== 0) {
  6069. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6070. }
  6071. for (var i = 0; i < len; i += 8) {
  6072. swap(this, i, i + 7)
  6073. swap(this, i + 1, i + 6)
  6074. swap(this, i + 2, i + 5)
  6075. swap(this, i + 3, i + 4)
  6076. }
  6077. return this
  6078. }
  6079. Buffer.prototype.toString = function toString () {
  6080. var length = this.length | 0
  6081. if (length === 0) return ''
  6082. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6083. return slowToString.apply(this, arguments)
  6084. }
  6085. Buffer.prototype.equals = function equals (b) {
  6086. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6087. if (this === b) return true
  6088. return Buffer.compare(this, b) === 0
  6089. }
  6090. Buffer.prototype.inspect = function inspect () {
  6091. var str = ''
  6092. var max = exports.INSPECT_MAX_BYTES
  6093. if (this.length > 0) {
  6094. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  6095. if (this.length > max) str += ' ... '
  6096. }
  6097. return '<Buffer ' + str + '>'
  6098. }
  6099. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6100. if (!Buffer.isBuffer(target)) {
  6101. throw new TypeError('Argument must be a Buffer')
  6102. }
  6103. if (start === undefined) {
  6104. start = 0
  6105. }
  6106. if (end === undefined) {
  6107. end = target ? target.length : 0
  6108. }
  6109. if (thisStart === undefined) {
  6110. thisStart = 0
  6111. }
  6112. if (thisEnd === undefined) {
  6113. thisEnd = this.length
  6114. }
  6115. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6116. throw new RangeError('out of range index')
  6117. }
  6118. if (thisStart >= thisEnd && start >= end) {
  6119. return 0
  6120. }
  6121. if (thisStart >= thisEnd) {
  6122. return -1
  6123. }
  6124. if (start >= end) {
  6125. return 1
  6126. }
  6127. start >>>= 0
  6128. end >>>= 0
  6129. thisStart >>>= 0
  6130. thisEnd >>>= 0
  6131. if (this === target) return 0
  6132. var x = thisEnd - thisStart
  6133. var y = end - start
  6134. var len = Math.min(x, y)
  6135. var thisCopy = this.slice(thisStart, thisEnd)
  6136. var targetCopy = target.slice(start, end)
  6137. for (var i = 0; i < len; ++i) {
  6138. if (thisCopy[i] !== targetCopy[i]) {
  6139. x = thisCopy[i]
  6140. y = targetCopy[i]
  6141. break
  6142. }
  6143. }
  6144. if (x < y) return -1
  6145. if (y < x) return 1
  6146. return 0
  6147. }
  6148. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6149. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6150. //
  6151. // Arguments:
  6152. // - buffer - a Buffer to search
  6153. // - val - a string, Buffer, or number
  6154. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6155. // - encoding - an optional encoding, relevant is val is a string
  6156. // - dir - true for indexOf, false for lastIndexOf
  6157. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6158. // Empty buffer means no match
  6159. if (buffer.length === 0) return -1
  6160. // Normalize byteOffset
  6161. if (typeof byteOffset === 'string') {
  6162. encoding = byteOffset
  6163. byteOffset = 0
  6164. } else if (byteOffset > 0x7fffffff) {
  6165. byteOffset = 0x7fffffff
  6166. } else if (byteOffset < -0x80000000) {
  6167. byteOffset = -0x80000000
  6168. }
  6169. byteOffset = +byteOffset // Coerce to Number.
  6170. if (isNaN(byteOffset)) {
  6171. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6172. byteOffset = dir ? 0 : (buffer.length - 1)
  6173. }
  6174. // Normalize byteOffset: negative offsets start from the end of the buffer
  6175. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6176. if (byteOffset >= buffer.length) {
  6177. if (dir) return -1
  6178. else byteOffset = buffer.length - 1
  6179. } else if (byteOffset < 0) {
  6180. if (dir) byteOffset = 0
  6181. else return -1
  6182. }
  6183. // Normalize val
  6184. if (typeof val === 'string') {
  6185. val = Buffer.from(val, encoding)
  6186. }
  6187. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6188. if (Buffer.isBuffer(val)) {
  6189. // Special case: looking for empty string/buffer always fails
  6190. if (val.length === 0) {
  6191. return -1
  6192. }
  6193. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6194. } else if (typeof val === 'number') {
  6195. val = val & 0xFF // Search for a byte value [0-255]
  6196. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6197. typeof Uint8Array.prototype.indexOf === 'function') {
  6198. if (dir) {
  6199. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6200. } else {
  6201. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6202. }
  6203. }
  6204. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6205. }
  6206. throw new TypeError('val must be string, number or Buffer')
  6207. }
  6208. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6209. var indexSize = 1
  6210. var arrLength = arr.length
  6211. var valLength = val.length
  6212. if (encoding !== undefined) {
  6213. encoding = String(encoding).toLowerCase()
  6214. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6215. encoding === 'utf16le' || encoding === 'utf-16le') {
  6216. if (arr.length < 2 || val.length < 2) {
  6217. return -1
  6218. }
  6219. indexSize = 2
  6220. arrLength /= 2
  6221. valLength /= 2
  6222. byteOffset /= 2
  6223. }
  6224. }
  6225. function read (buf, i) {
  6226. if (indexSize === 1) {
  6227. return buf[i]
  6228. } else {
  6229. return buf.readUInt16BE(i * indexSize)
  6230. }
  6231. }
  6232. var i
  6233. if (dir) {
  6234. var foundIndex = -1
  6235. for (i = byteOffset; i < arrLength; i++) {
  6236. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6237. if (foundIndex === -1) foundIndex = i
  6238. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6239. } else {
  6240. if (foundIndex !== -1) i -= i - foundIndex
  6241. foundIndex = -1
  6242. }
  6243. }
  6244. } else {
  6245. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6246. for (i = byteOffset; i >= 0; i--) {
  6247. var found = true
  6248. for (var j = 0; j < valLength; j++) {
  6249. if (read(arr, i + j) !== read(val, j)) {
  6250. found = false
  6251. break
  6252. }
  6253. }
  6254. if (found) return i
  6255. }
  6256. }
  6257. return -1
  6258. }
  6259. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6260. return this.indexOf(val, byteOffset, encoding) !== -1
  6261. }
  6262. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6263. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6264. }
  6265. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6266. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6267. }
  6268. function hexWrite (buf, string, offset, length) {
  6269. offset = Number(offset) || 0
  6270. var remaining = buf.length - offset
  6271. if (!length) {
  6272. length = remaining
  6273. } else {
  6274. length = Number(length)
  6275. if (length > remaining) {
  6276. length = remaining
  6277. }
  6278. }
  6279. // must be an even number of digits
  6280. var strLen = string.length
  6281. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6282. if (length > strLen / 2) {
  6283. length = strLen / 2
  6284. }
  6285. for (var i = 0; i < length; ++i) {
  6286. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6287. if (isNaN(parsed)) return i
  6288. buf[offset + i] = parsed
  6289. }
  6290. return i
  6291. }
  6292. function utf8Write (buf, string, offset, length) {
  6293. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6294. }
  6295. function asciiWrite (buf, string, offset, length) {
  6296. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6297. }
  6298. function latin1Write (buf, string, offset, length) {
  6299. return asciiWrite(buf, string, offset, length)
  6300. }
  6301. function base64Write (buf, string, offset, length) {
  6302. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6303. }
  6304. function ucs2Write (buf, string, offset, length) {
  6305. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6306. }
  6307. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6308. // Buffer#write(string)
  6309. if (offset === undefined) {
  6310. encoding = 'utf8'
  6311. length = this.length
  6312. offset = 0
  6313. // Buffer#write(string, encoding)
  6314. } else if (length === undefined && typeof offset === 'string') {
  6315. encoding = offset
  6316. length = this.length
  6317. offset = 0
  6318. // Buffer#write(string, offset[, length][, encoding])
  6319. } else if (isFinite(offset)) {
  6320. offset = offset | 0
  6321. if (isFinite(length)) {
  6322. length = length | 0
  6323. if (encoding === undefined) encoding = 'utf8'
  6324. } else {
  6325. encoding = length
  6326. length = undefined
  6327. }
  6328. // legacy write(string, encoding, offset, length) - remove in v0.13
  6329. } else {
  6330. throw new Error(
  6331. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6332. )
  6333. }
  6334. var remaining = this.length - offset
  6335. if (length === undefined || length > remaining) length = remaining
  6336. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6337. throw new RangeError('Attempt to write outside buffer bounds')
  6338. }
  6339. if (!encoding) encoding = 'utf8'
  6340. var loweredCase = false
  6341. for (;;) {
  6342. switch (encoding) {
  6343. case 'hex':
  6344. return hexWrite(this, string, offset, length)
  6345. case 'utf8':
  6346. case 'utf-8':
  6347. return utf8Write(this, string, offset, length)
  6348. case 'ascii':
  6349. return asciiWrite(this, string, offset, length)
  6350. case 'latin1':
  6351. case 'binary':
  6352. return latin1Write(this, string, offset, length)
  6353. case 'base64':
  6354. // Warning: maxLength not taken into account in base64Write
  6355. return base64Write(this, string, offset, length)
  6356. case 'ucs2':
  6357. case 'ucs-2':
  6358. case 'utf16le':
  6359. case 'utf-16le':
  6360. return ucs2Write(this, string, offset, length)
  6361. default:
  6362. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6363. encoding = ('' + encoding).toLowerCase()
  6364. loweredCase = true
  6365. }
  6366. }
  6367. }
  6368. Buffer.prototype.toJSON = function toJSON () {
  6369. return {
  6370. type: 'Buffer',
  6371. data: Array.prototype.slice.call(this._arr || this, 0)
  6372. }
  6373. }
  6374. function base64Slice (buf, start, end) {
  6375. if (start === 0 && end === buf.length) {
  6376. return base64.fromByteArray(buf)
  6377. } else {
  6378. return base64.fromByteArray(buf.slice(start, end))
  6379. }
  6380. }
  6381. function utf8Slice (buf, start, end) {
  6382. end = Math.min(buf.length, end)
  6383. var res = []
  6384. var i = start
  6385. while (i < end) {
  6386. var firstByte = buf[i]
  6387. var codePoint = null
  6388. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6389. : (firstByte > 0xDF) ? 3
  6390. : (firstByte > 0xBF) ? 2
  6391. : 1
  6392. if (i + bytesPerSequence <= end) {
  6393. var secondByte, thirdByte, fourthByte, tempCodePoint
  6394. switch (bytesPerSequence) {
  6395. case 1:
  6396. if (firstByte < 0x80) {
  6397. codePoint = firstByte
  6398. }
  6399. break
  6400. case 2:
  6401. secondByte = buf[i + 1]
  6402. if ((secondByte & 0xC0) === 0x80) {
  6403. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6404. if (tempCodePoint > 0x7F) {
  6405. codePoint = tempCodePoint
  6406. }
  6407. }
  6408. break
  6409. case 3:
  6410. secondByte = buf[i + 1]
  6411. thirdByte = buf[i + 2]
  6412. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6413. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6414. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6415. codePoint = tempCodePoint
  6416. }
  6417. }
  6418. break
  6419. case 4:
  6420. secondByte = buf[i + 1]
  6421. thirdByte = buf[i + 2]
  6422. fourthByte = buf[i + 3]
  6423. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6424. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6425. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6426. codePoint = tempCodePoint
  6427. }
  6428. }
  6429. }
  6430. }
  6431. if (codePoint === null) {
  6432. // we did not generate a valid codePoint so insert a
  6433. // replacement char (U+FFFD) and advance only 1 byte
  6434. codePoint = 0xFFFD
  6435. bytesPerSequence = 1
  6436. } else if (codePoint > 0xFFFF) {
  6437. // encode to utf16 (surrogate pair dance)
  6438. codePoint -= 0x10000
  6439. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6440. codePoint = 0xDC00 | codePoint & 0x3FF
  6441. }
  6442. res.push(codePoint)
  6443. i += bytesPerSequence
  6444. }
  6445. return decodeCodePointsArray(res)
  6446. }
  6447. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6448. // the lowest limit is Chrome, with 0x10000 args.
  6449. // We go 1 magnitude less, for safety
  6450. var MAX_ARGUMENTS_LENGTH = 0x1000
  6451. function decodeCodePointsArray (codePoints) {
  6452. var len = codePoints.length
  6453. if (len <= MAX_ARGUMENTS_LENGTH) {
  6454. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6455. }
  6456. // Decode in chunks to avoid "call stack size exceeded".
  6457. var res = ''
  6458. var i = 0
  6459. while (i < len) {
  6460. res += String.fromCharCode.apply(
  6461. String,
  6462. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6463. )
  6464. }
  6465. return res
  6466. }
  6467. function asciiSlice (buf, start, end) {
  6468. var ret = ''
  6469. end = Math.min(buf.length, end)
  6470. for (var i = start; i < end; ++i) {
  6471. ret += String.fromCharCode(buf[i] & 0x7F)
  6472. }
  6473. return ret
  6474. }
  6475. function latin1Slice (buf, start, end) {
  6476. var ret = ''
  6477. end = Math.min(buf.length, end)
  6478. for (var i = start; i < end; ++i) {
  6479. ret += String.fromCharCode(buf[i])
  6480. }
  6481. return ret
  6482. }
  6483. function hexSlice (buf, start, end) {
  6484. var len = buf.length
  6485. if (!start || start < 0) start = 0
  6486. if (!end || end < 0 || end > len) end = len
  6487. var out = ''
  6488. for (var i = start; i < end; ++i) {
  6489. out += toHex(buf[i])
  6490. }
  6491. return out
  6492. }
  6493. function utf16leSlice (buf, start, end) {
  6494. var bytes = buf.slice(start, end)
  6495. var res = ''
  6496. for (var i = 0; i < bytes.length; i += 2) {
  6497. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6498. }
  6499. return res
  6500. }
  6501. Buffer.prototype.slice = function slice (start, end) {
  6502. var len = this.length
  6503. start = ~~start
  6504. end = end === undefined ? len : ~~end
  6505. if (start < 0) {
  6506. start += len
  6507. if (start < 0) start = 0
  6508. } else if (start > len) {
  6509. start = len
  6510. }
  6511. if (end < 0) {
  6512. end += len
  6513. if (end < 0) end = 0
  6514. } else if (end > len) {
  6515. end = len
  6516. }
  6517. if (end < start) end = start
  6518. var newBuf
  6519. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6520. newBuf = this.subarray(start, end)
  6521. newBuf.__proto__ = Buffer.prototype
  6522. } else {
  6523. var sliceLen = end - start
  6524. newBuf = new Buffer(sliceLen, undefined)
  6525. for (var i = 0; i < sliceLen; ++i) {
  6526. newBuf[i] = this[i + start]
  6527. }
  6528. }
  6529. return newBuf
  6530. }
  6531. /*
  6532. * Need to make sure that buffer isn't trying to write out of bounds.
  6533. */
  6534. function checkOffset (offset, ext, length) {
  6535. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6536. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6537. }
  6538. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6539. offset = offset | 0
  6540. byteLength = byteLength | 0
  6541. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6542. var val = this[offset]
  6543. var mul = 1
  6544. var i = 0
  6545. while (++i < byteLength && (mul *= 0x100)) {
  6546. val += this[offset + i] * mul
  6547. }
  6548. return val
  6549. }
  6550. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6551. offset = offset | 0
  6552. byteLength = byteLength | 0
  6553. if (!noAssert) {
  6554. checkOffset(offset, byteLength, this.length)
  6555. }
  6556. var val = this[offset + --byteLength]
  6557. var mul = 1
  6558. while (byteLength > 0 && (mul *= 0x100)) {
  6559. val += this[offset + --byteLength] * mul
  6560. }
  6561. return val
  6562. }
  6563. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6564. if (!noAssert) checkOffset(offset, 1, this.length)
  6565. return this[offset]
  6566. }
  6567. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6568. if (!noAssert) checkOffset(offset, 2, this.length)
  6569. return this[offset] | (this[offset + 1] << 8)
  6570. }
  6571. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6572. if (!noAssert) checkOffset(offset, 2, this.length)
  6573. return (this[offset] << 8) | this[offset + 1]
  6574. }
  6575. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6576. if (!noAssert) checkOffset(offset, 4, this.length)
  6577. return ((this[offset]) |
  6578. (this[offset + 1] << 8) |
  6579. (this[offset + 2] << 16)) +
  6580. (this[offset + 3] * 0x1000000)
  6581. }
  6582. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6583. if (!noAssert) checkOffset(offset, 4, this.length)
  6584. return (this[offset] * 0x1000000) +
  6585. ((this[offset + 1] << 16) |
  6586. (this[offset + 2] << 8) |
  6587. this[offset + 3])
  6588. }
  6589. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6590. offset = offset | 0
  6591. byteLength = byteLength | 0
  6592. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6593. var val = this[offset]
  6594. var mul = 1
  6595. var i = 0
  6596. while (++i < byteLength && (mul *= 0x100)) {
  6597. val += this[offset + i] * mul
  6598. }
  6599. mul *= 0x80
  6600. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6601. return val
  6602. }
  6603. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6604. offset = offset | 0
  6605. byteLength = byteLength | 0
  6606. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6607. var i = byteLength
  6608. var mul = 1
  6609. var val = this[offset + --i]
  6610. while (i > 0 && (mul *= 0x100)) {
  6611. val += this[offset + --i] * mul
  6612. }
  6613. mul *= 0x80
  6614. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6615. return val
  6616. }
  6617. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6618. if (!noAssert) checkOffset(offset, 1, this.length)
  6619. if (!(this[offset] & 0x80)) return (this[offset])
  6620. return ((0xff - this[offset] + 1) * -1)
  6621. }
  6622. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6623. if (!noAssert) checkOffset(offset, 2, this.length)
  6624. var val = this[offset] | (this[offset + 1] << 8)
  6625. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6626. }
  6627. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6628. if (!noAssert) checkOffset(offset, 2, this.length)
  6629. var val = this[offset + 1] | (this[offset] << 8)
  6630. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6631. }
  6632. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6633. if (!noAssert) checkOffset(offset, 4, this.length)
  6634. return (this[offset]) |
  6635. (this[offset + 1] << 8) |
  6636. (this[offset + 2] << 16) |
  6637. (this[offset + 3] << 24)
  6638. }
  6639. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6640. if (!noAssert) checkOffset(offset, 4, this.length)
  6641. return (this[offset] << 24) |
  6642. (this[offset + 1] << 16) |
  6643. (this[offset + 2] << 8) |
  6644. (this[offset + 3])
  6645. }
  6646. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6647. if (!noAssert) checkOffset(offset, 4, this.length)
  6648. return ieee754.read(this, offset, true, 23, 4)
  6649. }
  6650. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6651. if (!noAssert) checkOffset(offset, 4, this.length)
  6652. return ieee754.read(this, offset, false, 23, 4)
  6653. }
  6654. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6655. if (!noAssert) checkOffset(offset, 8, this.length)
  6656. return ieee754.read(this, offset, true, 52, 8)
  6657. }
  6658. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6659. if (!noAssert) checkOffset(offset, 8, this.length)
  6660. return ieee754.read(this, offset, false, 52, 8)
  6661. }
  6662. function checkInt (buf, value, offset, ext, max, min) {
  6663. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6664. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6665. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6666. }
  6667. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6668. value = +value
  6669. offset = offset | 0
  6670. byteLength = byteLength | 0
  6671. if (!noAssert) {
  6672. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6673. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6674. }
  6675. var mul = 1
  6676. var i = 0
  6677. this[offset] = value & 0xFF
  6678. while (++i < byteLength && (mul *= 0x100)) {
  6679. this[offset + i] = (value / mul) & 0xFF
  6680. }
  6681. return offset + byteLength
  6682. }
  6683. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6684. value = +value
  6685. offset = offset | 0
  6686. byteLength = byteLength | 0
  6687. if (!noAssert) {
  6688. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6689. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6690. }
  6691. var i = byteLength - 1
  6692. var mul = 1
  6693. this[offset + i] = value & 0xFF
  6694. while (--i >= 0 && (mul *= 0x100)) {
  6695. this[offset + i] = (value / mul) & 0xFF
  6696. }
  6697. return offset + byteLength
  6698. }
  6699. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6700. value = +value
  6701. offset = offset | 0
  6702. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6703. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6704. this[offset] = (value & 0xff)
  6705. return offset + 1
  6706. }
  6707. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6708. if (value < 0) value = 0xffff + value + 1
  6709. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6710. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6711. (littleEndian ? i : 1 - i) * 8
  6712. }
  6713. }
  6714. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6715. value = +value
  6716. offset = offset | 0
  6717. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6718. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6719. this[offset] = (value & 0xff)
  6720. this[offset + 1] = (value >>> 8)
  6721. } else {
  6722. objectWriteUInt16(this, value, offset, true)
  6723. }
  6724. return offset + 2
  6725. }
  6726. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6727. value = +value
  6728. offset = offset | 0
  6729. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6730. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6731. this[offset] = (value >>> 8)
  6732. this[offset + 1] = (value & 0xff)
  6733. } else {
  6734. objectWriteUInt16(this, value, offset, false)
  6735. }
  6736. return offset + 2
  6737. }
  6738. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6739. if (value < 0) value = 0xffffffff + value + 1
  6740. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6741. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6742. }
  6743. }
  6744. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6745. value = +value
  6746. offset = offset | 0
  6747. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6748. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6749. this[offset + 3] = (value >>> 24)
  6750. this[offset + 2] = (value >>> 16)
  6751. this[offset + 1] = (value >>> 8)
  6752. this[offset] = (value & 0xff)
  6753. } else {
  6754. objectWriteUInt32(this, value, offset, true)
  6755. }
  6756. return offset + 4
  6757. }
  6758. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6759. value = +value
  6760. offset = offset | 0
  6761. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6762. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6763. this[offset] = (value >>> 24)
  6764. this[offset + 1] = (value >>> 16)
  6765. this[offset + 2] = (value >>> 8)
  6766. this[offset + 3] = (value & 0xff)
  6767. } else {
  6768. objectWriteUInt32(this, value, offset, false)
  6769. }
  6770. return offset + 4
  6771. }
  6772. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6773. value = +value
  6774. offset = offset | 0
  6775. if (!noAssert) {
  6776. var limit = Math.pow(2, 8 * byteLength - 1)
  6777. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6778. }
  6779. var i = 0
  6780. var mul = 1
  6781. var sub = 0
  6782. this[offset] = value & 0xFF
  6783. while (++i < byteLength && (mul *= 0x100)) {
  6784. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6785. sub = 1
  6786. }
  6787. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6788. }
  6789. return offset + byteLength
  6790. }
  6791. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6792. value = +value
  6793. offset = offset | 0
  6794. if (!noAssert) {
  6795. var limit = Math.pow(2, 8 * byteLength - 1)
  6796. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6797. }
  6798. var i = byteLength - 1
  6799. var mul = 1
  6800. var sub = 0
  6801. this[offset + i] = value & 0xFF
  6802. while (--i >= 0 && (mul *= 0x100)) {
  6803. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6804. sub = 1
  6805. }
  6806. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6807. }
  6808. return offset + byteLength
  6809. }
  6810. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6811. value = +value
  6812. offset = offset | 0
  6813. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6814. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6815. if (value < 0) value = 0xff + value + 1
  6816. this[offset] = (value & 0xff)
  6817. return offset + 1
  6818. }
  6819. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6820. value = +value
  6821. offset = offset | 0
  6822. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6823. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6824. this[offset] = (value & 0xff)
  6825. this[offset + 1] = (value >>> 8)
  6826. } else {
  6827. objectWriteUInt16(this, value, offset, true)
  6828. }
  6829. return offset + 2
  6830. }
  6831. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6832. value = +value
  6833. offset = offset | 0
  6834. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6835. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6836. this[offset] = (value >>> 8)
  6837. this[offset + 1] = (value & 0xff)
  6838. } else {
  6839. objectWriteUInt16(this, value, offset, false)
  6840. }
  6841. return offset + 2
  6842. }
  6843. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6844. value = +value
  6845. offset = offset | 0
  6846. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6847. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6848. this[offset] = (value & 0xff)
  6849. this[offset + 1] = (value >>> 8)
  6850. this[offset + 2] = (value >>> 16)
  6851. this[offset + 3] = (value >>> 24)
  6852. } else {
  6853. objectWriteUInt32(this, value, offset, true)
  6854. }
  6855. return offset + 4
  6856. }
  6857. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6858. value = +value
  6859. offset = offset | 0
  6860. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6861. if (value < 0) value = 0xffffffff + value + 1
  6862. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6863. this[offset] = (value >>> 24)
  6864. this[offset + 1] = (value >>> 16)
  6865. this[offset + 2] = (value >>> 8)
  6866. this[offset + 3] = (value & 0xff)
  6867. } else {
  6868. objectWriteUInt32(this, value, offset, false)
  6869. }
  6870. return offset + 4
  6871. }
  6872. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6873. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6874. if (offset < 0) throw new RangeError('Index out of range')
  6875. }
  6876. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6877. if (!noAssert) {
  6878. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6879. }
  6880. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6881. return offset + 4
  6882. }
  6883. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6884. return writeFloat(this, value, offset, true, noAssert)
  6885. }
  6886. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6887. return writeFloat(this, value, offset, false, noAssert)
  6888. }
  6889. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6890. if (!noAssert) {
  6891. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6892. }
  6893. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6894. return offset + 8
  6895. }
  6896. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6897. return writeDouble(this, value, offset, true, noAssert)
  6898. }
  6899. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6900. return writeDouble(this, value, offset, false, noAssert)
  6901. }
  6902. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6903. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6904. if (!start) start = 0
  6905. if (!end && end !== 0) end = this.length
  6906. if (targetStart >= target.length) targetStart = target.length
  6907. if (!targetStart) targetStart = 0
  6908. if (end > 0 && end < start) end = start
  6909. // Copy 0 bytes; we're done
  6910. if (end === start) return 0
  6911. if (target.length === 0 || this.length === 0) return 0
  6912. // Fatal error conditions
  6913. if (targetStart < 0) {
  6914. throw new RangeError('targetStart out of bounds')
  6915. }
  6916. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6917. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6918. // Are we oob?
  6919. if (end > this.length) end = this.length
  6920. if (target.length - targetStart < end - start) {
  6921. end = target.length - targetStart + start
  6922. }
  6923. var len = end - start
  6924. var i
  6925. if (this === target && start < targetStart && targetStart < end) {
  6926. // descending copy from end
  6927. for (i = len - 1; i >= 0; --i) {
  6928. target[i + targetStart] = this[i + start]
  6929. }
  6930. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6931. // ascending copy from start
  6932. for (i = 0; i < len; ++i) {
  6933. target[i + targetStart] = this[i + start]
  6934. }
  6935. } else {
  6936. Uint8Array.prototype.set.call(
  6937. target,
  6938. this.subarray(start, start + len),
  6939. targetStart
  6940. )
  6941. }
  6942. return len
  6943. }
  6944. // Usage:
  6945. // buffer.fill(number[, offset[, end]])
  6946. // buffer.fill(buffer[, offset[, end]])
  6947. // buffer.fill(string[, offset[, end]][, encoding])
  6948. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6949. // Handle string cases:
  6950. if (typeof val === 'string') {
  6951. if (typeof start === 'string') {
  6952. encoding = start
  6953. start = 0
  6954. end = this.length
  6955. } else if (typeof end === 'string') {
  6956. encoding = end
  6957. end = this.length
  6958. }
  6959. if (val.length === 1) {
  6960. var code = val.charCodeAt(0)
  6961. if (code < 256) {
  6962. val = code
  6963. }
  6964. }
  6965. if (encoding !== undefined && typeof encoding !== 'string') {
  6966. throw new TypeError('encoding must be a string')
  6967. }
  6968. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6969. throw new TypeError('Unknown encoding: ' + encoding)
  6970. }
  6971. } else if (typeof val === 'number') {
  6972. val = val & 255
  6973. }
  6974. // Invalid ranges are not set to a default, so can range check early.
  6975. if (start < 0 || this.length < start || this.length < end) {
  6976. throw new RangeError('Out of range index')
  6977. }
  6978. if (end <= start) {
  6979. return this
  6980. }
  6981. start = start >>> 0
  6982. end = end === undefined ? this.length : end >>> 0
  6983. if (!val) val = 0
  6984. var i
  6985. if (typeof val === 'number') {
  6986. for (i = start; i < end; ++i) {
  6987. this[i] = val
  6988. }
  6989. } else {
  6990. var bytes = Buffer.isBuffer(val)
  6991. ? val
  6992. : utf8ToBytes(new Buffer(val, encoding).toString())
  6993. var len = bytes.length
  6994. for (i = 0; i < end - start; ++i) {
  6995. this[i + start] = bytes[i % len]
  6996. }
  6997. }
  6998. return this
  6999. }
  7000. // HELPER FUNCTIONS
  7001. // ================
  7002. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  7003. function base64clean (str) {
  7004. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  7005. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  7006. // Node converts strings with length < 2 to ''
  7007. if (str.length < 2) return ''
  7008. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  7009. while (str.length % 4 !== 0) {
  7010. str = str + '='
  7011. }
  7012. return str
  7013. }
  7014. function stringtrim (str) {
  7015. if (str.trim) return str.trim()
  7016. return str.replace(/^\s+|\s+$/g, '')
  7017. }
  7018. function toHex (n) {
  7019. if (n < 16) return '0' + n.toString(16)
  7020. return n.toString(16)
  7021. }
  7022. function utf8ToBytes (string, units) {
  7023. units = units || Infinity
  7024. var codePoint
  7025. var length = string.length
  7026. var leadSurrogate = null
  7027. var bytes = []
  7028. for (var i = 0; i < length; ++i) {
  7029. codePoint = string.charCodeAt(i)
  7030. // is surrogate component
  7031. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  7032. // last char was a lead
  7033. if (!leadSurrogate) {
  7034. // no lead yet
  7035. if (codePoint > 0xDBFF) {
  7036. // unexpected trail
  7037. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7038. continue
  7039. } else if (i + 1 === length) {
  7040. // unpaired lead
  7041. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7042. continue
  7043. }
  7044. // valid lead
  7045. leadSurrogate = codePoint
  7046. continue
  7047. }
  7048. // 2 leads in a row
  7049. if (codePoint < 0xDC00) {
  7050. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7051. leadSurrogate = codePoint
  7052. continue
  7053. }
  7054. // valid surrogate pair
  7055. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  7056. } else if (leadSurrogate) {
  7057. // valid bmp char, but last char was a lead
  7058. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7059. }
  7060. leadSurrogate = null
  7061. // encode utf8
  7062. if (codePoint < 0x80) {
  7063. if ((units -= 1) < 0) break
  7064. bytes.push(codePoint)
  7065. } else if (codePoint < 0x800) {
  7066. if ((units -= 2) < 0) break
  7067. bytes.push(
  7068. codePoint >> 0x6 | 0xC0,
  7069. codePoint & 0x3F | 0x80
  7070. )
  7071. } else if (codePoint < 0x10000) {
  7072. if ((units -= 3) < 0) break
  7073. bytes.push(
  7074. codePoint >> 0xC | 0xE0,
  7075. codePoint >> 0x6 & 0x3F | 0x80,
  7076. codePoint & 0x3F | 0x80
  7077. )
  7078. } else if (codePoint < 0x110000) {
  7079. if ((units -= 4) < 0) break
  7080. bytes.push(
  7081. codePoint >> 0x12 | 0xF0,
  7082. codePoint >> 0xC & 0x3F | 0x80,
  7083. codePoint >> 0x6 & 0x3F | 0x80,
  7084. codePoint & 0x3F | 0x80
  7085. )
  7086. } else {
  7087. throw new Error('Invalid code point')
  7088. }
  7089. }
  7090. return bytes
  7091. }
  7092. function asciiToBytes (str) {
  7093. var byteArray = []
  7094. for (var i = 0; i < str.length; ++i) {
  7095. // Node's code seems to be doing this and not & 0x7F..
  7096. byteArray.push(str.charCodeAt(i) & 0xFF)
  7097. }
  7098. return byteArray
  7099. }
  7100. function utf16leToBytes (str, units) {
  7101. var c, hi, lo
  7102. var byteArray = []
  7103. for (var i = 0; i < str.length; ++i) {
  7104. if ((units -= 2) < 0) break
  7105. c = str.charCodeAt(i)
  7106. hi = c >> 8
  7107. lo = c % 256
  7108. byteArray.push(lo)
  7109. byteArray.push(hi)
  7110. }
  7111. return byteArray
  7112. }
  7113. function base64ToBytes (str) {
  7114. return base64.toByteArray(base64clean(str))
  7115. }
  7116. function blitBuffer (src, dst, offset, length) {
  7117. for (var i = 0; i < length; ++i) {
  7118. if ((i + offset >= dst.length) || (i >= src.length)) break
  7119. dst[i + offset] = src[i]
  7120. }
  7121. return i
  7122. }
  7123. function isnan (val) {
  7124. return val !== val // eslint-disable-line no-self-compare
  7125. }
  7126. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7127. /***/ }),
  7128. /***/ "./node_modules/clipboard/dist/clipboard.js":
  7129. /*!**************************************************!*\
  7130. !*** ./node_modules/clipboard/dist/clipboard.js ***!
  7131. \**************************************************/
  7132. /*! no static exports found */
  7133. /***/ (function(module, exports, __webpack_require__) {
  7134. /*!
  7135. * clipboard.js v2.0.4
  7136. * https://zenorocha.github.io/clipboard.js
  7137. *
  7138. * Licensed MIT © Zeno Rocha
  7139. */
  7140. (function webpackUniversalModuleDefinition(root, factory) {
  7141. if(true)
  7142. module.exports = factory();
  7143. else {}
  7144. })(this, function() {
  7145. return /******/ (function(modules) { // webpackBootstrap
  7146. /******/ // The module cache
  7147. /******/ var installedModules = {};
  7148. /******/
  7149. /******/ // The require function
  7150. /******/ function __webpack_require__(moduleId) {
  7151. /******/
  7152. /******/ // Check if module is in cache
  7153. /******/ if(installedModules[moduleId]) {
  7154. /******/ return installedModules[moduleId].exports;
  7155. /******/ }
  7156. /******/ // Create a new module (and put it into the cache)
  7157. /******/ var module = installedModules[moduleId] = {
  7158. /******/ i: moduleId,
  7159. /******/ l: false,
  7160. /******/ exports: {}
  7161. /******/ };
  7162. /******/
  7163. /******/ // Execute the module function
  7164. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  7165. /******/
  7166. /******/ // Flag the module as loaded
  7167. /******/ module.l = true;
  7168. /******/
  7169. /******/ // Return the exports of the module
  7170. /******/ return module.exports;
  7171. /******/ }
  7172. /******/
  7173. /******/
  7174. /******/ // expose the modules object (__webpack_modules__)
  7175. /******/ __webpack_require__.m = modules;
  7176. /******/
  7177. /******/ // expose the module cache
  7178. /******/ __webpack_require__.c = installedModules;
  7179. /******/
  7180. /******/ // define getter function for harmony exports
  7181. /******/ __webpack_require__.d = function(exports, name, getter) {
  7182. /******/ if(!__webpack_require__.o(exports, name)) {
  7183. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  7184. /******/ }
  7185. /******/ };
  7186. /******/
  7187. /******/ // define __esModule on exports
  7188. /******/ __webpack_require__.r = function(exports) {
  7189. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  7190. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  7191. /******/ }
  7192. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  7193. /******/ };
  7194. /******/
  7195. /******/ // create a fake namespace object
  7196. /******/ // mode & 1: value is a module id, require it
  7197. /******/ // mode & 2: merge all properties of value into the ns
  7198. /******/ // mode & 4: return value when already ns object
  7199. /******/ // mode & 8|1: behave like require
  7200. /******/ __webpack_require__.t = function(value, mode) {
  7201. /******/ if(mode & 1) value = __webpack_require__(value);
  7202. /******/ if(mode & 8) return value;
  7203. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  7204. /******/ var ns = Object.create(null);
  7205. /******/ __webpack_require__.r(ns);
  7206. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  7207. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  7208. /******/ return ns;
  7209. /******/ };
  7210. /******/
  7211. /******/ // getDefaultExport function for compatibility with non-harmony modules
  7212. /******/ __webpack_require__.n = function(module) {
  7213. /******/ var getter = module && module.__esModule ?
  7214. /******/ function getDefault() { return module['default']; } :
  7215. /******/ function getModuleExports() { return module; };
  7216. /******/ __webpack_require__.d(getter, 'a', getter);
  7217. /******/ return getter;
  7218. /******/ };
  7219. /******/
  7220. /******/ // Object.prototype.hasOwnProperty.call
  7221. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  7222. /******/
  7223. /******/ // __webpack_public_path__
  7224. /******/ __webpack_require__.p = "";
  7225. /******/
  7226. /******/
  7227. /******/ // Load entry module and return exports
  7228. /******/ return __webpack_require__(__webpack_require__.s = 0);
  7229. /******/ })
  7230. /************************************************************************/
  7231. /******/ ([
  7232. /* 0 */
  7233. /***/ (function(module, exports, __webpack_require__) {
  7234. "use strict";
  7235. 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; };
  7236. 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; }; }();
  7237. var _clipboardAction = __webpack_require__(1);
  7238. var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
  7239. var _tinyEmitter = __webpack_require__(3);
  7240. var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
  7241. var _goodListener = __webpack_require__(4);
  7242. var _goodListener2 = _interopRequireDefault(_goodListener);
  7243. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7244. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7245. 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; }
  7246. 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; }
  7247. /**
  7248. * Base class which takes one or more elements, adds event listeners to them,
  7249. * and instantiates a new `ClipboardAction` on each click.
  7250. */
  7251. var Clipboard = function (_Emitter) {
  7252. _inherits(Clipboard, _Emitter);
  7253. /**
  7254. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7255. * @param {Object} options
  7256. */
  7257. function Clipboard(trigger, options) {
  7258. _classCallCheck(this, Clipboard);
  7259. var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
  7260. _this.resolveOptions(options);
  7261. _this.listenClick(trigger);
  7262. return _this;
  7263. }
  7264. /**
  7265. * Defines if attributes would be resolved using internal setter functions
  7266. * or custom functions that were passed in the constructor.
  7267. * @param {Object} options
  7268. */
  7269. _createClass(Clipboard, [{
  7270. key: 'resolveOptions',
  7271. value: function resolveOptions() {
  7272. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7273. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  7274. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  7275. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  7276. this.container = _typeof(options.container) === 'object' ? options.container : document.body;
  7277. }
  7278. /**
  7279. * Adds a click event listener to the passed trigger.
  7280. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7281. */
  7282. }, {
  7283. key: 'listenClick',
  7284. value: function listenClick(trigger) {
  7285. var _this2 = this;
  7286. this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
  7287. return _this2.onClick(e);
  7288. });
  7289. }
  7290. /**
  7291. * Defines a new `ClipboardAction` on each click event.
  7292. * @param {Event} e
  7293. */
  7294. }, {
  7295. key: 'onClick',
  7296. value: function onClick(e) {
  7297. var trigger = e.delegateTarget || e.currentTarget;
  7298. if (this.clipboardAction) {
  7299. this.clipboardAction = null;
  7300. }
  7301. this.clipboardAction = new _clipboardAction2.default({
  7302. action: this.action(trigger),
  7303. target: this.target(trigger),
  7304. text: this.text(trigger),
  7305. container: this.container,
  7306. trigger: trigger,
  7307. emitter: this
  7308. });
  7309. }
  7310. /**
  7311. * Default `action` lookup function.
  7312. * @param {Element} trigger
  7313. */
  7314. }, {
  7315. key: 'defaultAction',
  7316. value: function defaultAction(trigger) {
  7317. return getAttributeValue('action', trigger);
  7318. }
  7319. /**
  7320. * Default `target` lookup function.
  7321. * @param {Element} trigger
  7322. */
  7323. }, {
  7324. key: 'defaultTarget',
  7325. value: function defaultTarget(trigger) {
  7326. var selector = getAttributeValue('target', trigger);
  7327. if (selector) {
  7328. return document.querySelector(selector);
  7329. }
  7330. }
  7331. /**
  7332. * Returns the support of the given action, or all actions if no action is
  7333. * given.
  7334. * @param {String} [action]
  7335. */
  7336. }, {
  7337. key: 'defaultText',
  7338. /**
  7339. * Default `text` lookup function.
  7340. * @param {Element} trigger
  7341. */
  7342. value: function defaultText(trigger) {
  7343. return getAttributeValue('text', trigger);
  7344. }
  7345. /**
  7346. * Destroy lifecycle.
  7347. */
  7348. }, {
  7349. key: 'destroy',
  7350. value: function destroy() {
  7351. this.listener.destroy();
  7352. if (this.clipboardAction) {
  7353. this.clipboardAction.destroy();
  7354. this.clipboardAction = null;
  7355. }
  7356. }
  7357. }], [{
  7358. key: 'isSupported',
  7359. value: function isSupported() {
  7360. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  7361. var actions = typeof action === 'string' ? [action] : action;
  7362. var support = !!document.queryCommandSupported;
  7363. actions.forEach(function (action) {
  7364. support = support && !!document.queryCommandSupported(action);
  7365. });
  7366. return support;
  7367. }
  7368. }]);
  7369. return Clipboard;
  7370. }(_tinyEmitter2.default);
  7371. /**
  7372. * Helper function to retrieve attribute value.
  7373. * @param {String} suffix
  7374. * @param {Element} element
  7375. */
  7376. function getAttributeValue(suffix, element) {
  7377. var attribute = 'data-clipboard-' + suffix;
  7378. if (!element.hasAttribute(attribute)) {
  7379. return;
  7380. }
  7381. return element.getAttribute(attribute);
  7382. }
  7383. module.exports = Clipboard;
  7384. /***/ }),
  7385. /* 1 */
  7386. /***/ (function(module, exports, __webpack_require__) {
  7387. "use strict";
  7388. 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; };
  7389. 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; }; }();
  7390. var _select = __webpack_require__(2);
  7391. var _select2 = _interopRequireDefault(_select);
  7392. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7393. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7394. /**
  7395. * Inner class which performs selection from either `text` or `target`
  7396. * properties and then executes copy or cut operations.
  7397. */
  7398. var ClipboardAction = function () {
  7399. /**
  7400. * @param {Object} options
  7401. */
  7402. function ClipboardAction(options) {
  7403. _classCallCheck(this, ClipboardAction);
  7404. this.resolveOptions(options);
  7405. this.initSelection();
  7406. }
  7407. /**
  7408. * Defines base properties passed from constructor.
  7409. * @param {Object} options
  7410. */
  7411. _createClass(ClipboardAction, [{
  7412. key: 'resolveOptions',
  7413. value: function resolveOptions() {
  7414. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7415. this.action = options.action;
  7416. this.container = options.container;
  7417. this.emitter = options.emitter;
  7418. this.target = options.target;
  7419. this.text = options.text;
  7420. this.trigger = options.trigger;
  7421. this.selectedText = '';
  7422. }
  7423. /**
  7424. * Decides which selection strategy is going to be applied based
  7425. * on the existence of `text` and `target` properties.
  7426. */
  7427. }, {
  7428. key: 'initSelection',
  7429. value: function initSelection() {
  7430. if (this.text) {
  7431. this.selectFake();
  7432. } else if (this.target) {
  7433. this.selectTarget();
  7434. }
  7435. }
  7436. /**
  7437. * Creates a fake textarea element, sets its value from `text` property,
  7438. * and makes a selection on it.
  7439. */
  7440. }, {
  7441. key: 'selectFake',
  7442. value: function selectFake() {
  7443. var _this = this;
  7444. var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
  7445. this.removeFake();
  7446. this.fakeHandlerCallback = function () {
  7447. return _this.removeFake();
  7448. };
  7449. this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
  7450. this.fakeElem = document.createElement('textarea');
  7451. // Prevent zooming on iOS
  7452. this.fakeElem.style.fontSize = '12pt';
  7453. // Reset box model
  7454. this.fakeElem.style.border = '0';
  7455. this.fakeElem.style.padding = '0';
  7456. this.fakeElem.style.margin = '0';
  7457. // Move element out of screen horizontally
  7458. this.fakeElem.style.position = 'absolute';
  7459. this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
  7460. // Move element to the same position vertically
  7461. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  7462. this.fakeElem.style.top = yPosition + 'px';
  7463. this.fakeElem.setAttribute('readonly', '');
  7464. this.fakeElem.value = this.text;
  7465. this.container.appendChild(this.fakeElem);
  7466. this.selectedText = (0, _select2.default)(this.fakeElem);
  7467. this.copyText();
  7468. }
  7469. /**
  7470. * Only removes the fake element after another click event, that way
  7471. * a user can hit `Ctrl+C` to copy because selection still exists.
  7472. */
  7473. }, {
  7474. key: 'removeFake',
  7475. value: function removeFake() {
  7476. if (this.fakeHandler) {
  7477. this.container.removeEventListener('click', this.fakeHandlerCallback);
  7478. this.fakeHandler = null;
  7479. this.fakeHandlerCallback = null;
  7480. }
  7481. if (this.fakeElem) {
  7482. this.container.removeChild(this.fakeElem);
  7483. this.fakeElem = null;
  7484. }
  7485. }
  7486. /**
  7487. * Selects the content from element passed on `target` property.
  7488. */
  7489. }, {
  7490. key: 'selectTarget',
  7491. value: function selectTarget() {
  7492. this.selectedText = (0, _select2.default)(this.target);
  7493. this.copyText();
  7494. }
  7495. /**
  7496. * Executes the copy operation based on the current selection.
  7497. */
  7498. }, {
  7499. key: 'copyText',
  7500. value: function copyText() {
  7501. var succeeded = void 0;
  7502. try {
  7503. succeeded = document.execCommand(this.action);
  7504. } catch (err) {
  7505. succeeded = false;
  7506. }
  7507. this.handleResult(succeeded);
  7508. }
  7509. /**
  7510. * Fires an event based on the copy operation result.
  7511. * @param {Boolean} succeeded
  7512. */
  7513. }, {
  7514. key: 'handleResult',
  7515. value: function handleResult(succeeded) {
  7516. this.emitter.emit(succeeded ? 'success' : 'error', {
  7517. action: this.action,
  7518. text: this.selectedText,
  7519. trigger: this.trigger,
  7520. clearSelection: this.clearSelection.bind(this)
  7521. });
  7522. }
  7523. /**
  7524. * Moves focus away from `target` and back to the trigger, removes current selection.
  7525. */
  7526. }, {
  7527. key: 'clearSelection',
  7528. value: function clearSelection() {
  7529. if (this.trigger) {
  7530. this.trigger.focus();
  7531. }
  7532. window.getSelection().removeAllRanges();
  7533. }
  7534. /**
  7535. * Sets the `action` to be performed which can be either 'copy' or 'cut'.
  7536. * @param {String} action
  7537. */
  7538. }, {
  7539. key: 'destroy',
  7540. /**
  7541. * Destroy lifecycle.
  7542. */
  7543. value: function destroy() {
  7544. this.removeFake();
  7545. }
  7546. }, {
  7547. key: 'action',
  7548. set: function set() {
  7549. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
  7550. this._action = action;
  7551. if (this._action !== 'copy' && this._action !== 'cut') {
  7552. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  7553. }
  7554. }
  7555. /**
  7556. * Gets the `action` property.
  7557. * @return {String}
  7558. */
  7559. ,
  7560. get: function get() {
  7561. return this._action;
  7562. }
  7563. /**
  7564. * Sets the `target` property using an element
  7565. * that will be have its content copied.
  7566. * @param {Element} target
  7567. */
  7568. }, {
  7569. key: 'target',
  7570. set: function set(target) {
  7571. if (target !== undefined) {
  7572. if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
  7573. if (this.action === 'copy' && target.hasAttribute('disabled')) {
  7574. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  7575. }
  7576. if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  7577. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  7578. }
  7579. this._target = target;
  7580. } else {
  7581. throw new Error('Invalid "target" value, use a valid Element');
  7582. }
  7583. }
  7584. }
  7585. /**
  7586. * Gets the `target` property.
  7587. * @return {String|HTMLElement}
  7588. */
  7589. ,
  7590. get: function get() {
  7591. return this._target;
  7592. }
  7593. }]);
  7594. return ClipboardAction;
  7595. }();
  7596. module.exports = ClipboardAction;
  7597. /***/ }),
  7598. /* 2 */
  7599. /***/ (function(module, exports) {
  7600. function select(element) {
  7601. var selectedText;
  7602. if (element.nodeName === 'SELECT') {
  7603. element.focus();
  7604. selectedText = element.value;
  7605. }
  7606. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  7607. var isReadOnly = element.hasAttribute('readonly');
  7608. if (!isReadOnly) {
  7609. element.setAttribute('readonly', '');
  7610. }
  7611. element.select();
  7612. element.setSelectionRange(0, element.value.length);
  7613. if (!isReadOnly) {
  7614. element.removeAttribute('readonly');
  7615. }
  7616. selectedText = element.value;
  7617. }
  7618. else {
  7619. if (element.hasAttribute('contenteditable')) {
  7620. element.focus();
  7621. }
  7622. var selection = window.getSelection();
  7623. var range = document.createRange();
  7624. range.selectNodeContents(element);
  7625. selection.removeAllRanges();
  7626. selection.addRange(range);
  7627. selectedText = selection.toString();
  7628. }
  7629. return selectedText;
  7630. }
  7631. module.exports = select;
  7632. /***/ }),
  7633. /* 3 */
  7634. /***/ (function(module, exports) {
  7635. function E () {
  7636. // Keep this empty so it's easier to inherit from
  7637. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  7638. }
  7639. E.prototype = {
  7640. on: function (name, callback, ctx) {
  7641. var e = this.e || (this.e = {});
  7642. (e[name] || (e[name] = [])).push({
  7643. fn: callback,
  7644. ctx: ctx
  7645. });
  7646. return this;
  7647. },
  7648. once: function (name, callback, ctx) {
  7649. var self = this;
  7650. function listener () {
  7651. self.off(name, listener);
  7652. callback.apply(ctx, arguments);
  7653. };
  7654. listener._ = callback
  7655. return this.on(name, listener, ctx);
  7656. },
  7657. emit: function (name) {
  7658. var data = [].slice.call(arguments, 1);
  7659. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  7660. var i = 0;
  7661. var len = evtArr.length;
  7662. for (i; i < len; i++) {
  7663. evtArr[i].fn.apply(evtArr[i].ctx, data);
  7664. }
  7665. return this;
  7666. },
  7667. off: function (name, callback) {
  7668. var e = this.e || (this.e = {});
  7669. var evts = e[name];
  7670. var liveEvents = [];
  7671. if (evts && callback) {
  7672. for (var i = 0, len = evts.length; i < len; i++) {
  7673. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  7674. liveEvents.push(evts[i]);
  7675. }
  7676. }
  7677. // Remove event from queue to prevent memory leak
  7678. // Suggested by https://github.com/lazd
  7679. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  7680. (liveEvents.length)
  7681. ? e[name] = liveEvents
  7682. : delete e[name];
  7683. return this;
  7684. }
  7685. };
  7686. module.exports = E;
  7687. /***/ }),
  7688. /* 4 */
  7689. /***/ (function(module, exports, __webpack_require__) {
  7690. var is = __webpack_require__(5);
  7691. var delegate = __webpack_require__(6);
  7692. /**
  7693. * Validates all params and calls the right
  7694. * listener function based on its target type.
  7695. *
  7696. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  7697. * @param {String} type
  7698. * @param {Function} callback
  7699. * @return {Object}
  7700. */
  7701. function listen(target, type, callback) {
  7702. if (!target && !type && !callback) {
  7703. throw new Error('Missing required arguments');
  7704. }
  7705. if (!is.string(type)) {
  7706. throw new TypeError('Second argument must be a String');
  7707. }
  7708. if (!is.fn(callback)) {
  7709. throw new TypeError('Third argument must be a Function');
  7710. }
  7711. if (is.node(target)) {
  7712. return listenNode(target, type, callback);
  7713. }
  7714. else if (is.nodeList(target)) {
  7715. return listenNodeList(target, type, callback);
  7716. }
  7717. else if (is.string(target)) {
  7718. return listenSelector(target, type, callback);
  7719. }
  7720. else {
  7721. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  7722. }
  7723. }
  7724. /**
  7725. * Adds an event listener to a HTML element
  7726. * and returns a remove listener function.
  7727. *
  7728. * @param {HTMLElement} node
  7729. * @param {String} type
  7730. * @param {Function} callback
  7731. * @return {Object}
  7732. */
  7733. function listenNode(node, type, callback) {
  7734. node.addEventListener(type, callback);
  7735. return {
  7736. destroy: function() {
  7737. node.removeEventListener(type, callback);
  7738. }
  7739. }
  7740. }
  7741. /**
  7742. * Add an event listener to a list of HTML elements
  7743. * and returns a remove listener function.
  7744. *
  7745. * @param {NodeList|HTMLCollection} nodeList
  7746. * @param {String} type
  7747. * @param {Function} callback
  7748. * @return {Object}
  7749. */
  7750. function listenNodeList(nodeList, type, callback) {
  7751. Array.prototype.forEach.call(nodeList, function(node) {
  7752. node.addEventListener(type, callback);
  7753. });
  7754. return {
  7755. destroy: function() {
  7756. Array.prototype.forEach.call(nodeList, function(node) {
  7757. node.removeEventListener(type, callback);
  7758. });
  7759. }
  7760. }
  7761. }
  7762. /**
  7763. * Add an event listener to a selector
  7764. * and returns a remove listener function.
  7765. *
  7766. * @param {String} selector
  7767. * @param {String} type
  7768. * @param {Function} callback
  7769. * @return {Object}
  7770. */
  7771. function listenSelector(selector, type, callback) {
  7772. return delegate(document.body, selector, type, callback);
  7773. }
  7774. module.exports = listen;
  7775. /***/ }),
  7776. /* 5 */
  7777. /***/ (function(module, exports) {
  7778. /**
  7779. * Check if argument is a HTML element.
  7780. *
  7781. * @param {Object} value
  7782. * @return {Boolean}
  7783. */
  7784. exports.node = function(value) {
  7785. return value !== undefined
  7786. && value instanceof HTMLElement
  7787. && value.nodeType === 1;
  7788. };
  7789. /**
  7790. * Check if argument is a list of HTML elements.
  7791. *
  7792. * @param {Object} value
  7793. * @return {Boolean}
  7794. */
  7795. exports.nodeList = function(value) {
  7796. var type = Object.prototype.toString.call(value);
  7797. return value !== undefined
  7798. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  7799. && ('length' in value)
  7800. && (value.length === 0 || exports.node(value[0]));
  7801. };
  7802. /**
  7803. * Check if argument is a string.
  7804. *
  7805. * @param {Object} value
  7806. * @return {Boolean}
  7807. */
  7808. exports.string = function(value) {
  7809. return typeof value === 'string'
  7810. || value instanceof String;
  7811. };
  7812. /**
  7813. * Check if argument is a function.
  7814. *
  7815. * @param {Object} value
  7816. * @return {Boolean}
  7817. */
  7818. exports.fn = function(value) {
  7819. var type = Object.prototype.toString.call(value);
  7820. return type === '[object Function]';
  7821. };
  7822. /***/ }),
  7823. /* 6 */
  7824. /***/ (function(module, exports, __webpack_require__) {
  7825. var closest = __webpack_require__(7);
  7826. /**
  7827. * Delegates event to a selector.
  7828. *
  7829. * @param {Element} element
  7830. * @param {String} selector
  7831. * @param {String} type
  7832. * @param {Function} callback
  7833. * @param {Boolean} useCapture
  7834. * @return {Object}
  7835. */
  7836. function _delegate(element, selector, type, callback, useCapture) {
  7837. var listenerFn = listener.apply(this, arguments);
  7838. element.addEventListener(type, listenerFn, useCapture);
  7839. return {
  7840. destroy: function() {
  7841. element.removeEventListener(type, listenerFn, useCapture);
  7842. }
  7843. }
  7844. }
  7845. /**
  7846. * Delegates event to a selector.
  7847. *
  7848. * @param {Element|String|Array} [elements]
  7849. * @param {String} selector
  7850. * @param {String} type
  7851. * @param {Function} callback
  7852. * @param {Boolean} useCapture
  7853. * @return {Object}
  7854. */
  7855. function delegate(elements, selector, type, callback, useCapture) {
  7856. // Handle the regular Element usage
  7857. if (typeof elements.addEventListener === 'function') {
  7858. return _delegate.apply(null, arguments);
  7859. }
  7860. // Handle Element-less usage, it defaults to global delegation
  7861. if (typeof type === 'function') {
  7862. // Use `document` as the first parameter, then apply arguments
  7863. // This is a short way to .unshift `arguments` without running into deoptimizations
  7864. return _delegate.bind(null, document).apply(null, arguments);
  7865. }
  7866. // Handle Selector-based usage
  7867. if (typeof elements === 'string') {
  7868. elements = document.querySelectorAll(elements);
  7869. }
  7870. // Handle Array-like based usage
  7871. return Array.prototype.map.call(elements, function (element) {
  7872. return _delegate(element, selector, type, callback, useCapture);
  7873. });
  7874. }
  7875. /**
  7876. * Finds closest match and invokes callback.
  7877. *
  7878. * @param {Element} element
  7879. * @param {String} selector
  7880. * @param {String} type
  7881. * @param {Function} callback
  7882. * @return {Function}
  7883. */
  7884. function listener(element, selector, type, callback) {
  7885. return function(e) {
  7886. e.delegateTarget = closest(e.target, selector);
  7887. if (e.delegateTarget) {
  7888. callback.call(element, e);
  7889. }
  7890. }
  7891. }
  7892. module.exports = delegate;
  7893. /***/ }),
  7894. /* 7 */
  7895. /***/ (function(module, exports) {
  7896. var DOCUMENT_NODE_TYPE = 9;
  7897. /**
  7898. * A polyfill for Element.matches()
  7899. */
  7900. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  7901. var proto = Element.prototype;
  7902. proto.matches = proto.matchesSelector ||
  7903. proto.mozMatchesSelector ||
  7904. proto.msMatchesSelector ||
  7905. proto.oMatchesSelector ||
  7906. proto.webkitMatchesSelector;
  7907. }
  7908. /**
  7909. * Finds the closest parent that matches a selector.
  7910. *
  7911. * @param {Element} element
  7912. * @param {String} selector
  7913. * @return {Function}
  7914. */
  7915. function closest (element, selector) {
  7916. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  7917. if (typeof element.matches === 'function' &&
  7918. element.matches(selector)) {
  7919. return element;
  7920. }
  7921. element = element.parentNode;
  7922. }
  7923. }
  7924. module.exports = closest;
  7925. /***/ })
  7926. /******/ ]);
  7927. });
  7928. /***/ }),
  7929. /***/ "./node_modules/ieee754/index.js":
  7930. /*!***************************************!*\
  7931. !*** ./node_modules/ieee754/index.js ***!
  7932. \***************************************/
  7933. /*! no static exports found */
  7934. /***/ (function(module, exports) {
  7935. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7936. var e, m
  7937. var eLen = (nBytes * 8) - mLen - 1
  7938. var eMax = (1 << eLen) - 1
  7939. var eBias = eMax >> 1
  7940. var nBits = -7
  7941. var i = isLE ? (nBytes - 1) : 0
  7942. var d = isLE ? -1 : 1
  7943. var s = buffer[offset + i]
  7944. i += d
  7945. e = s & ((1 << (-nBits)) - 1)
  7946. s >>= (-nBits)
  7947. nBits += eLen
  7948. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7949. m = e & ((1 << (-nBits)) - 1)
  7950. e >>= (-nBits)
  7951. nBits += mLen
  7952. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7953. if (e === 0) {
  7954. e = 1 - eBias
  7955. } else if (e === eMax) {
  7956. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7957. } else {
  7958. m = m + Math.pow(2, mLen)
  7959. e = e - eBias
  7960. }
  7961. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7962. }
  7963. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7964. var e, m, c
  7965. var eLen = (nBytes * 8) - mLen - 1
  7966. var eMax = (1 << eLen) - 1
  7967. var eBias = eMax >> 1
  7968. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7969. var i = isLE ? 0 : (nBytes - 1)
  7970. var d = isLE ? 1 : -1
  7971. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7972. value = Math.abs(value)
  7973. if (isNaN(value) || value === Infinity) {
  7974. m = isNaN(value) ? 1 : 0
  7975. e = eMax
  7976. } else {
  7977. e = Math.floor(Math.log(value) / Math.LN2)
  7978. if (value * (c = Math.pow(2, -e)) < 1) {
  7979. e--
  7980. c *= 2
  7981. }
  7982. if (e + eBias >= 1) {
  7983. value += rt / c
  7984. } else {
  7985. value += rt * Math.pow(2, 1 - eBias)
  7986. }
  7987. if (value * c >= 2) {
  7988. e++
  7989. c /= 2
  7990. }
  7991. if (e + eBias >= eMax) {
  7992. m = 0
  7993. e = eMax
  7994. } else if (e + eBias >= 1) {
  7995. m = ((value * c) - 1) * Math.pow(2, mLen)
  7996. e = e + eBias
  7997. } else {
  7998. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7999. e = 0
  8000. }
  8001. }
  8002. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  8003. e = (e << mLen) | m
  8004. eLen += mLen
  8005. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  8006. buffer[offset + i - d] |= s * 128
  8007. }
  8008. /***/ }),
  8009. /***/ "./node_modules/isarray/index.js":
  8010. /*!***************************************!*\
  8011. !*** ./node_modules/isarray/index.js ***!
  8012. \***************************************/
  8013. /*! no static exports found */
  8014. /***/ (function(module, exports) {
  8015. var toString = {}.toString;
  8016. module.exports = Array.isArray || function (arr) {
  8017. return toString.call(arr) == '[object Array]';
  8018. };
  8019. /***/ }),
  8020. /***/ "./node_modules/jquery/dist/jquery.js":
  8021. /*!********************************************!*\
  8022. !*** ./node_modules/jquery/dist/jquery.js ***!
  8023. \********************************************/
  8024. /*! no static exports found */
  8025. /***/ (function(module, exports, __webpack_require__) {
  8026. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  8027. * jQuery JavaScript Library v3.4.1
  8028. * https://jquery.com/
  8029. *
  8030. * Includes Sizzle.js
  8031. * https://sizzlejs.com/
  8032. *
  8033. * Copyright JS Foundation and other contributors
  8034. * Released under the MIT license
  8035. * https://jquery.org/license
  8036. *
  8037. * Date: 2019-05-01T21:04Z
  8038. */
  8039. ( function( global, factory ) {
  8040. "use strict";
  8041. if ( true && typeof module.exports === "object" ) {
  8042. // For CommonJS and CommonJS-like environments where a proper `window`
  8043. // is present, execute the factory and get jQuery.
  8044. // For environments that do not have a `window` with a `document`
  8045. // (such as Node.js), expose a factory as module.exports.
  8046. // This accentuates the need for the creation of a real `window`.
  8047. // e.g. var jQuery = require("jquery")(window);
  8048. // See ticket #14549 for more info.
  8049. module.exports = global.document ?
  8050. factory( global, true ) :
  8051. function( w ) {
  8052. if ( !w.document ) {
  8053. throw new Error( "jQuery requires a window with a document" );
  8054. }
  8055. return factory( w );
  8056. };
  8057. } else {
  8058. factory( global );
  8059. }
  8060. // Pass this if window is not defined yet
  8061. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  8062. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  8063. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  8064. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  8065. // enough that all such attempts are guarded in a try block.
  8066. "use strict";
  8067. var arr = [];
  8068. var document = window.document;
  8069. var getProto = Object.getPrototypeOf;
  8070. var slice = arr.slice;
  8071. var concat = arr.concat;
  8072. var push = arr.push;
  8073. var indexOf = arr.indexOf;
  8074. var class2type = {};
  8075. var toString = class2type.toString;
  8076. var hasOwn = class2type.hasOwnProperty;
  8077. var fnToString = hasOwn.toString;
  8078. var ObjectFunctionString = fnToString.call( Object );
  8079. var support = {};
  8080. var isFunction = function isFunction( obj ) {
  8081. // Support: Chrome <=57, Firefox <=52
  8082. // In some browsers, typeof returns "function" for HTML <object> elements
  8083. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  8084. // We don't want to classify *any* DOM node as a function.
  8085. return typeof obj === "function" && typeof obj.nodeType !== "number";
  8086. };
  8087. var isWindow = function isWindow( obj ) {
  8088. return obj != null && obj === obj.window;
  8089. };
  8090. var preservedScriptAttributes = {
  8091. type: true,
  8092. src: true,
  8093. nonce: true,
  8094. noModule: true
  8095. };
  8096. function DOMEval( code, node, doc ) {
  8097. doc = doc || document;
  8098. var i, val,
  8099. script = doc.createElement( "script" );
  8100. script.text = code;
  8101. if ( node ) {
  8102. for ( i in preservedScriptAttributes ) {
  8103. // Support: Firefox 64+, Edge 18+
  8104. // Some browsers don't support the "nonce" property on scripts.
  8105. // On the other hand, just using `getAttribute` is not enough as
  8106. // the `nonce` attribute is reset to an empty string whenever it
  8107. // becomes browsing-context connected.
  8108. // See https://github.com/whatwg/html/issues/2369
  8109. // See https://html.spec.whatwg.org/#nonce-attributes
  8110. // The `node.getAttribute` check was added for the sake of
  8111. // `jQuery.globalEval` so that it can fake a nonce-containing node
  8112. // via an object.
  8113. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  8114. if ( val ) {
  8115. script.setAttribute( i, val );
  8116. }
  8117. }
  8118. }
  8119. doc.head.appendChild( script ).parentNode.removeChild( script );
  8120. }
  8121. function toType( obj ) {
  8122. if ( obj == null ) {
  8123. return obj + "";
  8124. }
  8125. // Support: Android <=2.3 only (functionish RegExp)
  8126. return typeof obj === "object" || typeof obj === "function" ?
  8127. class2type[ toString.call( obj ) ] || "object" :
  8128. typeof obj;
  8129. }
  8130. /* global Symbol */
  8131. // Defining this global in .eslintrc.json would create a danger of using the global
  8132. // unguarded in another place, it seems safer to define global only for this module
  8133. var
  8134. version = "3.4.1",
  8135. // Define a local copy of jQuery
  8136. jQuery = function( selector, context ) {
  8137. // The jQuery object is actually just the init constructor 'enhanced'
  8138. // Need init if jQuery is called (just allow error to be thrown if not included)
  8139. return new jQuery.fn.init( selector, context );
  8140. },
  8141. // Support: Android <=4.0 only
  8142. // Make sure we trim BOM and NBSP
  8143. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  8144. jQuery.fn = jQuery.prototype = {
  8145. // The current version of jQuery being used
  8146. jquery: version,
  8147. constructor: jQuery,
  8148. // The default length of a jQuery object is 0
  8149. length: 0,
  8150. toArray: function() {
  8151. return slice.call( this );
  8152. },
  8153. // Get the Nth element in the matched element set OR
  8154. // Get the whole matched element set as a clean array
  8155. get: function( num ) {
  8156. // Return all the elements in a clean array
  8157. if ( num == null ) {
  8158. return slice.call( this );
  8159. }
  8160. // Return just the one element from the set
  8161. return num < 0 ? this[ num + this.length ] : this[ num ];
  8162. },
  8163. // Take an array of elements and push it onto the stack
  8164. // (returning the new matched element set)
  8165. pushStack: function( elems ) {
  8166. // Build a new jQuery matched element set
  8167. var ret = jQuery.merge( this.constructor(), elems );
  8168. // Add the old object onto the stack (as a reference)
  8169. ret.prevObject = this;
  8170. // Return the newly-formed element set
  8171. return ret;
  8172. },
  8173. // Execute a callback for every element in the matched set.
  8174. each: function( callback ) {
  8175. return jQuery.each( this, callback );
  8176. },
  8177. map: function( callback ) {
  8178. return this.pushStack( jQuery.map( this, function( elem, i ) {
  8179. return callback.call( elem, i, elem );
  8180. } ) );
  8181. },
  8182. slice: function() {
  8183. return this.pushStack( slice.apply( this, arguments ) );
  8184. },
  8185. first: function() {
  8186. return this.eq( 0 );
  8187. },
  8188. last: function() {
  8189. return this.eq( -1 );
  8190. },
  8191. eq: function( i ) {
  8192. var len = this.length,
  8193. j = +i + ( i < 0 ? len : 0 );
  8194. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  8195. },
  8196. end: function() {
  8197. return this.prevObject || this.constructor();
  8198. },
  8199. // For internal use only.
  8200. // Behaves like an Array's method, not like a jQuery method.
  8201. push: push,
  8202. sort: arr.sort,
  8203. splice: arr.splice
  8204. };
  8205. jQuery.extend = jQuery.fn.extend = function() {
  8206. var options, name, src, copy, copyIsArray, clone,
  8207. target = arguments[ 0 ] || {},
  8208. i = 1,
  8209. length = arguments.length,
  8210. deep = false;
  8211. // Handle a deep copy situation
  8212. if ( typeof target === "boolean" ) {
  8213. deep = target;
  8214. // Skip the boolean and the target
  8215. target = arguments[ i ] || {};
  8216. i++;
  8217. }
  8218. // Handle case when target is a string or something (possible in deep copy)
  8219. if ( typeof target !== "object" && !isFunction( target ) ) {
  8220. target = {};
  8221. }
  8222. // Extend jQuery itself if only one argument is passed
  8223. if ( i === length ) {
  8224. target = this;
  8225. i--;
  8226. }
  8227. for ( ; i < length; i++ ) {
  8228. // Only deal with non-null/undefined values
  8229. if ( ( options = arguments[ i ] ) != null ) {
  8230. // Extend the base object
  8231. for ( name in options ) {
  8232. copy = options[ name ];
  8233. // Prevent Object.prototype pollution
  8234. // Prevent never-ending loop
  8235. if ( name === "__proto__" || target === copy ) {
  8236. continue;
  8237. }
  8238. // Recurse if we're merging plain objects or arrays
  8239. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  8240. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  8241. src = target[ name ];
  8242. // Ensure proper type for the source value
  8243. if ( copyIsArray && !Array.isArray( src ) ) {
  8244. clone = [];
  8245. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  8246. clone = {};
  8247. } else {
  8248. clone = src;
  8249. }
  8250. copyIsArray = false;
  8251. // Never move original objects, clone them
  8252. target[ name ] = jQuery.extend( deep, clone, copy );
  8253. // Don't bring in undefined values
  8254. } else if ( copy !== undefined ) {
  8255. target[ name ] = copy;
  8256. }
  8257. }
  8258. }
  8259. }
  8260. // Return the modified object
  8261. return target;
  8262. };
  8263. jQuery.extend( {
  8264. // Unique for each copy of jQuery on the page
  8265. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  8266. // Assume jQuery is ready without the ready module
  8267. isReady: true,
  8268. error: function( msg ) {
  8269. throw new Error( msg );
  8270. },
  8271. noop: function() {},
  8272. isPlainObject: function( obj ) {
  8273. var proto, Ctor;
  8274. // Detect obvious negatives
  8275. // Use toString instead of jQuery.type to catch host objects
  8276. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  8277. return false;
  8278. }
  8279. proto = getProto( obj );
  8280. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  8281. if ( !proto ) {
  8282. return true;
  8283. }
  8284. // Objects with prototype are plain iff they were constructed by a global Object function
  8285. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  8286. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  8287. },
  8288. isEmptyObject: function( obj ) {
  8289. var name;
  8290. for ( name in obj ) {
  8291. return false;
  8292. }
  8293. return true;
  8294. },
  8295. // Evaluates a script in a global context
  8296. globalEval: function( code, options ) {
  8297. DOMEval( code, { nonce: options && options.nonce } );
  8298. },
  8299. each: function( obj, callback ) {
  8300. var length, i = 0;
  8301. if ( isArrayLike( obj ) ) {
  8302. length = obj.length;
  8303. for ( ; i < length; i++ ) {
  8304. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8305. break;
  8306. }
  8307. }
  8308. } else {
  8309. for ( i in obj ) {
  8310. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8311. break;
  8312. }
  8313. }
  8314. }
  8315. return obj;
  8316. },
  8317. // Support: Android <=4.0 only
  8318. trim: function( text ) {
  8319. return text == null ?
  8320. "" :
  8321. ( text + "" ).replace( rtrim, "" );
  8322. },
  8323. // results is for internal usage only
  8324. makeArray: function( arr, results ) {
  8325. var ret = results || [];
  8326. if ( arr != null ) {
  8327. if ( isArrayLike( Object( arr ) ) ) {
  8328. jQuery.merge( ret,
  8329. typeof arr === "string" ?
  8330. [ arr ] : arr
  8331. );
  8332. } else {
  8333. push.call( ret, arr );
  8334. }
  8335. }
  8336. return ret;
  8337. },
  8338. inArray: function( elem, arr, i ) {
  8339. return arr == null ? -1 : indexOf.call( arr, elem, i );
  8340. },
  8341. // Support: Android <=4.0 only, PhantomJS 1 only
  8342. // push.apply(_, arraylike) throws on ancient WebKit
  8343. merge: function( first, second ) {
  8344. var len = +second.length,
  8345. j = 0,
  8346. i = first.length;
  8347. for ( ; j < len; j++ ) {
  8348. first[ i++ ] = second[ j ];
  8349. }
  8350. first.length = i;
  8351. return first;
  8352. },
  8353. grep: function( elems, callback, invert ) {
  8354. var callbackInverse,
  8355. matches = [],
  8356. i = 0,
  8357. length = elems.length,
  8358. callbackExpect = !invert;
  8359. // Go through the array, only saving the items
  8360. // that pass the validator function
  8361. for ( ; i < length; i++ ) {
  8362. callbackInverse = !callback( elems[ i ], i );
  8363. if ( callbackInverse !== callbackExpect ) {
  8364. matches.push( elems[ i ] );
  8365. }
  8366. }
  8367. return matches;
  8368. },
  8369. // arg is for internal usage only
  8370. map: function( elems, callback, arg ) {
  8371. var length, value,
  8372. i = 0,
  8373. ret = [];
  8374. // Go through the array, translating each of the items to their new values
  8375. if ( isArrayLike( elems ) ) {
  8376. length = elems.length;
  8377. for ( ; i < length; i++ ) {
  8378. value = callback( elems[ i ], i, arg );
  8379. if ( value != null ) {
  8380. ret.push( value );
  8381. }
  8382. }
  8383. // Go through every key on the object,
  8384. } else {
  8385. for ( i in elems ) {
  8386. value = callback( elems[ i ], i, arg );
  8387. if ( value != null ) {
  8388. ret.push( value );
  8389. }
  8390. }
  8391. }
  8392. // Flatten any nested arrays
  8393. return concat.apply( [], ret );
  8394. },
  8395. // A global GUID counter for objects
  8396. guid: 1,
  8397. // jQuery.support is not used in Core but other projects attach their
  8398. // properties to it so it needs to exist.
  8399. support: support
  8400. } );
  8401. if ( typeof Symbol === "function" ) {
  8402. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  8403. }
  8404. // Populate the class2type map
  8405. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  8406. function( i, name ) {
  8407. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  8408. } );
  8409. function isArrayLike( obj ) {
  8410. // Support: real iOS 8.2 only (not reproducible in simulator)
  8411. // `in` check used to prevent JIT error (gh-2145)
  8412. // hasOwn isn't used here due to false negatives
  8413. // regarding Nodelist length in IE
  8414. var length = !!obj && "length" in obj && obj.length,
  8415. type = toType( obj );
  8416. if ( isFunction( obj ) || isWindow( obj ) ) {
  8417. return false;
  8418. }
  8419. return type === "array" || length === 0 ||
  8420. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  8421. }
  8422. var Sizzle =
  8423. /*!
  8424. * Sizzle CSS Selector Engine v2.3.4
  8425. * https://sizzlejs.com/
  8426. *
  8427. * Copyright JS Foundation and other contributors
  8428. * Released under the MIT license
  8429. * https://js.foundation/
  8430. *
  8431. * Date: 2019-04-08
  8432. */
  8433. (function( window ) {
  8434. var i,
  8435. support,
  8436. Expr,
  8437. getText,
  8438. isXML,
  8439. tokenize,
  8440. compile,
  8441. select,
  8442. outermostContext,
  8443. sortInput,
  8444. hasDuplicate,
  8445. // Local document vars
  8446. setDocument,
  8447. document,
  8448. docElem,
  8449. documentIsHTML,
  8450. rbuggyQSA,
  8451. rbuggyMatches,
  8452. matches,
  8453. contains,
  8454. // Instance-specific data
  8455. expando = "sizzle" + 1 * new Date(),
  8456. preferredDoc = window.document,
  8457. dirruns = 0,
  8458. done = 0,
  8459. classCache = createCache(),
  8460. tokenCache = createCache(),
  8461. compilerCache = createCache(),
  8462. nonnativeSelectorCache = createCache(),
  8463. sortOrder = function( a, b ) {
  8464. if ( a === b ) {
  8465. hasDuplicate = true;
  8466. }
  8467. return 0;
  8468. },
  8469. // Instance methods
  8470. hasOwn = ({}).hasOwnProperty,
  8471. arr = [],
  8472. pop = arr.pop,
  8473. push_native = arr.push,
  8474. push = arr.push,
  8475. slice = arr.slice,
  8476. // Use a stripped-down indexOf as it's faster than native
  8477. // https://jsperf.com/thor-indexof-vs-for/5
  8478. indexOf = function( list, elem ) {
  8479. var i = 0,
  8480. len = list.length;
  8481. for ( ; i < len; i++ ) {
  8482. if ( list[i] === elem ) {
  8483. return i;
  8484. }
  8485. }
  8486. return -1;
  8487. },
  8488. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  8489. // Regular expressions
  8490. // http://www.w3.org/TR/css3-selectors/#whitespace
  8491. whitespace = "[\\x20\\t\\r\\n\\f]",
  8492. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  8493. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  8494. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  8495. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  8496. // Operator (capture 2)
  8497. "*([*^$|!~]?=)" + whitespace +
  8498. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  8499. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  8500. "*\\]",
  8501. pseudos = ":(" + identifier + ")(?:\\((" +
  8502. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  8503. // 1. quoted (capture 3; capture 4 or capture 5)
  8504. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  8505. // 2. simple (capture 6)
  8506. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  8507. // 3. anything else (capture 2)
  8508. ".*" +
  8509. ")\\)|)",
  8510. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  8511. rwhitespace = new RegExp( whitespace + "+", "g" ),
  8512. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  8513. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  8514. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  8515. rdescend = new RegExp( whitespace + "|>" ),
  8516. rpseudo = new RegExp( pseudos ),
  8517. ridentifier = new RegExp( "^" + identifier + "$" ),
  8518. matchExpr = {
  8519. "ID": new RegExp( "^#(" + identifier + ")" ),
  8520. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  8521. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  8522. "ATTR": new RegExp( "^" + attributes ),
  8523. "PSEUDO": new RegExp( "^" + pseudos ),
  8524. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  8525. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  8526. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  8527. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  8528. // For use in libraries implementing .is()
  8529. // We use this for POS matching in `select`
  8530. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  8531. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  8532. },
  8533. rhtml = /HTML$/i,
  8534. rinputs = /^(?:input|select|textarea|button)$/i,
  8535. rheader = /^h\d$/i,
  8536. rnative = /^[^{]+\{\s*\[native \w/,
  8537. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  8538. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  8539. rsibling = /[+~]/,
  8540. // CSS escapes
  8541. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  8542. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  8543. funescape = function( _, escaped, escapedWhitespace ) {
  8544. var high = "0x" + escaped - 0x10000;
  8545. // NaN means non-codepoint
  8546. // Support: Firefox<24
  8547. // Workaround erroneous numeric interpretation of +"0x"
  8548. return high !== high || escapedWhitespace ?
  8549. escaped :
  8550. high < 0 ?
  8551. // BMP codepoint
  8552. String.fromCharCode( high + 0x10000 ) :
  8553. // Supplemental Plane codepoint (surrogate pair)
  8554. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  8555. },
  8556. // CSS string/identifier serialization
  8557. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  8558. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  8559. fcssescape = function( ch, asCodePoint ) {
  8560. if ( asCodePoint ) {
  8561. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  8562. if ( ch === "\0" ) {
  8563. return "\uFFFD";
  8564. }
  8565. // Control characters and (dependent upon position) numbers get escaped as code points
  8566. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  8567. }
  8568. // Other potentially-special ASCII characters get backslash-escaped
  8569. return "\\" + ch;
  8570. },
  8571. // Used for iframes
  8572. // See setDocument()
  8573. // Removing the function wrapper causes a "Permission Denied"
  8574. // error in IE
  8575. unloadHandler = function() {
  8576. setDocument();
  8577. },
  8578. inDisabledFieldset = addCombinator(
  8579. function( elem ) {
  8580. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  8581. },
  8582. { dir: "parentNode", next: "legend" }
  8583. );
  8584. // Optimize for push.apply( _, NodeList )
  8585. try {
  8586. push.apply(
  8587. (arr = slice.call( preferredDoc.childNodes )),
  8588. preferredDoc.childNodes
  8589. );
  8590. // Support: Android<4.0
  8591. // Detect silently failing push.apply
  8592. arr[ preferredDoc.childNodes.length ].nodeType;
  8593. } catch ( e ) {
  8594. push = { apply: arr.length ?
  8595. // Leverage slice if possible
  8596. function( target, els ) {
  8597. push_native.apply( target, slice.call(els) );
  8598. } :
  8599. // Support: IE<9
  8600. // Otherwise append directly
  8601. function( target, els ) {
  8602. var j = target.length,
  8603. i = 0;
  8604. // Can't trust NodeList.length
  8605. while ( (target[j++] = els[i++]) ) {}
  8606. target.length = j - 1;
  8607. }
  8608. };
  8609. }
  8610. function Sizzle( selector, context, results, seed ) {
  8611. var m, i, elem, nid, match, groups, newSelector,
  8612. newContext = context && context.ownerDocument,
  8613. // nodeType defaults to 9, since context defaults to document
  8614. nodeType = context ? context.nodeType : 9;
  8615. results = results || [];
  8616. // Return early from calls with invalid selector or context
  8617. if ( typeof selector !== "string" || !selector ||
  8618. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  8619. return results;
  8620. }
  8621. // Try to shortcut find operations (as opposed to filters) in HTML documents
  8622. if ( !seed ) {
  8623. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  8624. setDocument( context );
  8625. }
  8626. context = context || document;
  8627. if ( documentIsHTML ) {
  8628. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  8629. // (excepting DocumentFragment context, where the methods don't exist)
  8630. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  8631. // ID selector
  8632. if ( (m = match[1]) ) {
  8633. // Document context
  8634. if ( nodeType === 9 ) {
  8635. if ( (elem = context.getElementById( m )) ) {
  8636. // Support: IE, Opera, Webkit
  8637. // TODO: identify versions
  8638. // getElementById can match elements by name instead of ID
  8639. if ( elem.id === m ) {
  8640. results.push( elem );
  8641. return results;
  8642. }
  8643. } else {
  8644. return results;
  8645. }
  8646. // Element context
  8647. } else {
  8648. // Support: IE, Opera, Webkit
  8649. // TODO: identify versions
  8650. // getElementById can match elements by name instead of ID
  8651. if ( newContext && (elem = newContext.getElementById( m )) &&
  8652. contains( context, elem ) &&
  8653. elem.id === m ) {
  8654. results.push( elem );
  8655. return results;
  8656. }
  8657. }
  8658. // Type selector
  8659. } else if ( match[2] ) {
  8660. push.apply( results, context.getElementsByTagName( selector ) );
  8661. return results;
  8662. // Class selector
  8663. } else if ( (m = match[3]) && support.getElementsByClassName &&
  8664. context.getElementsByClassName ) {
  8665. push.apply( results, context.getElementsByClassName( m ) );
  8666. return results;
  8667. }
  8668. }
  8669. // Take advantage of querySelectorAll
  8670. if ( support.qsa &&
  8671. !nonnativeSelectorCache[ selector + " " ] &&
  8672. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  8673. // Support: IE 8 only
  8674. // Exclude object elements
  8675. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  8676. newSelector = selector;
  8677. newContext = context;
  8678. // qSA considers elements outside a scoping root when evaluating child or
  8679. // descendant combinators, which is not what we want.
  8680. // In such cases, we work around the behavior by prefixing every selector in the
  8681. // list with an ID selector referencing the scope context.
  8682. // Thanks to Andrew Dupont for this technique.
  8683. if ( nodeType === 1 && rdescend.test( selector ) ) {
  8684. // Capture the context ID, setting it first if necessary
  8685. if ( (nid = context.getAttribute( "id" )) ) {
  8686. nid = nid.replace( rcssescape, fcssescape );
  8687. } else {
  8688. context.setAttribute( "id", (nid = expando) );
  8689. }
  8690. // Prefix every selector in the list
  8691. groups = tokenize( selector );
  8692. i = groups.length;
  8693. while ( i-- ) {
  8694. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  8695. }
  8696. newSelector = groups.join( "," );
  8697. // Expand context for sibling selectors
  8698. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  8699. context;
  8700. }
  8701. try {
  8702. push.apply( results,
  8703. newContext.querySelectorAll( newSelector )
  8704. );
  8705. return results;
  8706. } catch ( qsaError ) {
  8707. nonnativeSelectorCache( selector, true );
  8708. } finally {
  8709. if ( nid === expando ) {
  8710. context.removeAttribute( "id" );
  8711. }
  8712. }
  8713. }
  8714. }
  8715. }
  8716. // All others
  8717. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  8718. }
  8719. /**
  8720. * Create key-value caches of limited size
  8721. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  8722. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  8723. * deleting the oldest entry
  8724. */
  8725. function createCache() {
  8726. var keys = [];
  8727. function cache( key, value ) {
  8728. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  8729. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  8730. // Only keep the most recent entries
  8731. delete cache[ keys.shift() ];
  8732. }
  8733. return (cache[ key + " " ] = value);
  8734. }
  8735. return cache;
  8736. }
  8737. /**
  8738. * Mark a function for special use by Sizzle
  8739. * @param {Function} fn The function to mark
  8740. */
  8741. function markFunction( fn ) {
  8742. fn[ expando ] = true;
  8743. return fn;
  8744. }
  8745. /**
  8746. * Support testing using an element
  8747. * @param {Function} fn Passed the created element and returns a boolean result
  8748. */
  8749. function assert( fn ) {
  8750. var el = document.createElement("fieldset");
  8751. try {
  8752. return !!fn( el );
  8753. } catch (e) {
  8754. return false;
  8755. } finally {
  8756. // Remove from its parent by default
  8757. if ( el.parentNode ) {
  8758. el.parentNode.removeChild( el );
  8759. }
  8760. // release memory in IE
  8761. el = null;
  8762. }
  8763. }
  8764. /**
  8765. * Adds the same handler for all of the specified attrs
  8766. * @param {String} attrs Pipe-separated list of attributes
  8767. * @param {Function} handler The method that will be applied
  8768. */
  8769. function addHandle( attrs, handler ) {
  8770. var arr = attrs.split("|"),
  8771. i = arr.length;
  8772. while ( i-- ) {
  8773. Expr.attrHandle[ arr[i] ] = handler;
  8774. }
  8775. }
  8776. /**
  8777. * Checks document order of two siblings
  8778. * @param {Element} a
  8779. * @param {Element} b
  8780. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  8781. */
  8782. function siblingCheck( a, b ) {
  8783. var cur = b && a,
  8784. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  8785. a.sourceIndex - b.sourceIndex;
  8786. // Use IE sourceIndex if available on both nodes
  8787. if ( diff ) {
  8788. return diff;
  8789. }
  8790. // Check if b follows a
  8791. if ( cur ) {
  8792. while ( (cur = cur.nextSibling) ) {
  8793. if ( cur === b ) {
  8794. return -1;
  8795. }
  8796. }
  8797. }
  8798. return a ? 1 : -1;
  8799. }
  8800. /**
  8801. * Returns a function to use in pseudos for input types
  8802. * @param {String} type
  8803. */
  8804. function createInputPseudo( type ) {
  8805. return function( elem ) {
  8806. var name = elem.nodeName.toLowerCase();
  8807. return name === "input" && elem.type === type;
  8808. };
  8809. }
  8810. /**
  8811. * Returns a function to use in pseudos for buttons
  8812. * @param {String} type
  8813. */
  8814. function createButtonPseudo( type ) {
  8815. return function( elem ) {
  8816. var name = elem.nodeName.toLowerCase();
  8817. return (name === "input" || name === "button") && elem.type === type;
  8818. };
  8819. }
  8820. /**
  8821. * Returns a function to use in pseudos for :enabled/:disabled
  8822. * @param {Boolean} disabled true for :disabled; false for :enabled
  8823. */
  8824. function createDisabledPseudo( disabled ) {
  8825. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  8826. return function( elem ) {
  8827. // Only certain elements can match :enabled or :disabled
  8828. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  8829. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  8830. if ( "form" in elem ) {
  8831. // Check for inherited disabledness on relevant non-disabled elements:
  8832. // * listed form-associated elements in a disabled fieldset
  8833. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  8834. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  8835. // * option elements in a disabled optgroup
  8836. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  8837. // All such elements have a "form" property.
  8838. if ( elem.parentNode && elem.disabled === false ) {
  8839. // Option elements defer to a parent optgroup if present
  8840. if ( "label" in elem ) {
  8841. if ( "label" in elem.parentNode ) {
  8842. return elem.parentNode.disabled === disabled;
  8843. } else {
  8844. return elem.disabled === disabled;
  8845. }
  8846. }
  8847. // Support: IE 6 - 11
  8848. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  8849. return elem.isDisabled === disabled ||
  8850. // Where there is no isDisabled, check manually
  8851. /* jshint -W018 */
  8852. elem.isDisabled !== !disabled &&
  8853. inDisabledFieldset( elem ) === disabled;
  8854. }
  8855. return elem.disabled === disabled;
  8856. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  8857. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  8858. // even exist on them, let alone have a boolean value.
  8859. } else if ( "label" in elem ) {
  8860. return elem.disabled === disabled;
  8861. }
  8862. // Remaining elements are neither :enabled nor :disabled
  8863. return false;
  8864. };
  8865. }
  8866. /**
  8867. * Returns a function to use in pseudos for positionals
  8868. * @param {Function} fn
  8869. */
  8870. function createPositionalPseudo( fn ) {
  8871. return markFunction(function( argument ) {
  8872. argument = +argument;
  8873. return markFunction(function( seed, matches ) {
  8874. var j,
  8875. matchIndexes = fn( [], seed.length, argument ),
  8876. i = matchIndexes.length;
  8877. // Match elements found at the specified indexes
  8878. while ( i-- ) {
  8879. if ( seed[ (j = matchIndexes[i]) ] ) {
  8880. seed[j] = !(matches[j] = seed[j]);
  8881. }
  8882. }
  8883. });
  8884. });
  8885. }
  8886. /**
  8887. * Checks a node for validity as a Sizzle context
  8888. * @param {Element|Object=} context
  8889. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  8890. */
  8891. function testContext( context ) {
  8892. return context && typeof context.getElementsByTagName !== "undefined" && context;
  8893. }
  8894. // Expose support vars for convenience
  8895. support = Sizzle.support = {};
  8896. /**
  8897. * Detects XML nodes
  8898. * @param {Element|Object} elem An element or a document
  8899. * @returns {Boolean} True iff elem is a non-HTML XML node
  8900. */
  8901. isXML = Sizzle.isXML = function( elem ) {
  8902. var namespace = elem.namespaceURI,
  8903. docElem = (elem.ownerDocument || elem).documentElement;
  8904. // Support: IE <=8
  8905. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  8906. // https://bugs.jquery.com/ticket/4833
  8907. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  8908. };
  8909. /**
  8910. * Sets document-related variables once based on the current document
  8911. * @param {Element|Object} [doc] An element or document object to use to set the document
  8912. * @returns {Object} Returns the current document
  8913. */
  8914. setDocument = Sizzle.setDocument = function( node ) {
  8915. var hasCompare, subWindow,
  8916. doc = node ? node.ownerDocument || node : preferredDoc;
  8917. // Return early if doc is invalid or already selected
  8918. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  8919. return document;
  8920. }
  8921. // Update global variables
  8922. document = doc;
  8923. docElem = document.documentElement;
  8924. documentIsHTML = !isXML( document );
  8925. // Support: IE 9-11, Edge
  8926. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  8927. if ( preferredDoc !== document &&
  8928. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  8929. // Support: IE 11, Edge
  8930. if ( subWindow.addEventListener ) {
  8931. subWindow.addEventListener( "unload", unloadHandler, false );
  8932. // Support: IE 9 - 10 only
  8933. } else if ( subWindow.attachEvent ) {
  8934. subWindow.attachEvent( "onunload", unloadHandler );
  8935. }
  8936. }
  8937. /* Attributes
  8938. ---------------------------------------------------------------------- */
  8939. // Support: IE<8
  8940. // Verify that getAttribute really returns attributes and not properties
  8941. // (excepting IE8 booleans)
  8942. support.attributes = assert(function( el ) {
  8943. el.className = "i";
  8944. return !el.getAttribute("className");
  8945. });
  8946. /* getElement(s)By*
  8947. ---------------------------------------------------------------------- */
  8948. // Check if getElementsByTagName("*") returns only elements
  8949. support.getElementsByTagName = assert(function( el ) {
  8950. el.appendChild( document.createComment("") );
  8951. return !el.getElementsByTagName("*").length;
  8952. });
  8953. // Support: IE<9
  8954. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  8955. // Support: IE<10
  8956. // Check if getElementById returns elements by name
  8957. // The broken getElementById methods don't pick up programmatically-set names,
  8958. // so use a roundabout getElementsByName test
  8959. support.getById = assert(function( el ) {
  8960. docElem.appendChild( el ).id = expando;
  8961. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  8962. });
  8963. // ID filter and find
  8964. if ( support.getById ) {
  8965. Expr.filter["ID"] = function( id ) {
  8966. var attrId = id.replace( runescape, funescape );
  8967. return function( elem ) {
  8968. return elem.getAttribute("id") === attrId;
  8969. };
  8970. };
  8971. Expr.find["ID"] = function( id, context ) {
  8972. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8973. var elem = context.getElementById( id );
  8974. return elem ? [ elem ] : [];
  8975. }
  8976. };
  8977. } else {
  8978. Expr.filter["ID"] = function( id ) {
  8979. var attrId = id.replace( runescape, funescape );
  8980. return function( elem ) {
  8981. var node = typeof elem.getAttributeNode !== "undefined" &&
  8982. elem.getAttributeNode("id");
  8983. return node && node.value === attrId;
  8984. };
  8985. };
  8986. // Support: IE 6 - 7 only
  8987. // getElementById is not reliable as a find shortcut
  8988. Expr.find["ID"] = function( id, context ) {
  8989. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8990. var node, i, elems,
  8991. elem = context.getElementById( id );
  8992. if ( elem ) {
  8993. // Verify the id attribute
  8994. node = elem.getAttributeNode("id");
  8995. if ( node && node.value === id ) {
  8996. return [ elem ];
  8997. }
  8998. // Fall back on getElementsByName
  8999. elems = context.getElementsByName( id );
  9000. i = 0;
  9001. while ( (elem = elems[i++]) ) {
  9002. node = elem.getAttributeNode("id");
  9003. if ( node && node.value === id ) {
  9004. return [ elem ];
  9005. }
  9006. }
  9007. }
  9008. return [];
  9009. }
  9010. };
  9011. }
  9012. // Tag
  9013. Expr.find["TAG"] = support.getElementsByTagName ?
  9014. function( tag, context ) {
  9015. if ( typeof context.getElementsByTagName !== "undefined" ) {
  9016. return context.getElementsByTagName( tag );
  9017. // DocumentFragment nodes don't have gEBTN
  9018. } else if ( support.qsa ) {
  9019. return context.querySelectorAll( tag );
  9020. }
  9021. } :
  9022. function( tag, context ) {
  9023. var elem,
  9024. tmp = [],
  9025. i = 0,
  9026. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  9027. results = context.getElementsByTagName( tag );
  9028. // Filter out possible comments
  9029. if ( tag === "*" ) {
  9030. while ( (elem = results[i++]) ) {
  9031. if ( elem.nodeType === 1 ) {
  9032. tmp.push( elem );
  9033. }
  9034. }
  9035. return tmp;
  9036. }
  9037. return results;
  9038. };
  9039. // Class
  9040. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  9041. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  9042. return context.getElementsByClassName( className );
  9043. }
  9044. };
  9045. /* QSA/matchesSelector
  9046. ---------------------------------------------------------------------- */
  9047. // QSA and matchesSelector support
  9048. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  9049. rbuggyMatches = [];
  9050. // qSa(:focus) reports false when true (Chrome 21)
  9051. // We allow this because of a bug in IE8/9 that throws an error
  9052. // whenever `document.activeElement` is accessed on an iframe
  9053. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  9054. // See https://bugs.jquery.com/ticket/13378
  9055. rbuggyQSA = [];
  9056. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  9057. // Build QSA regex
  9058. // Regex strategy adopted from Diego Perini
  9059. assert(function( el ) {
  9060. // Select is set to empty string on purpose
  9061. // This is to test IE's treatment of not explicitly
  9062. // setting a boolean content attribute,
  9063. // since its presence should be enough
  9064. // https://bugs.jquery.com/ticket/12359
  9065. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  9066. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  9067. "<option selected=''></option></select>";
  9068. // Support: IE8, Opera 11-12.16
  9069. // Nothing should be selected when empty strings follow ^= or $= or *=
  9070. // The test attribute must be unknown in Opera but "safe" for WinRT
  9071. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  9072. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  9073. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  9074. }
  9075. // Support: IE8
  9076. // Boolean attributes and "value" are not treated correctly
  9077. if ( !el.querySelectorAll("[selected]").length ) {
  9078. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  9079. }
  9080. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  9081. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  9082. rbuggyQSA.push("~=");
  9083. }
  9084. // Webkit/Opera - :checked should return selected option elements
  9085. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9086. // IE8 throws error here and will not see later tests
  9087. if ( !el.querySelectorAll(":checked").length ) {
  9088. rbuggyQSA.push(":checked");
  9089. }
  9090. // Support: Safari 8+, iOS 8+
  9091. // https://bugs.webkit.org/show_bug.cgi?id=136851
  9092. // In-page `selector#id sibling-combinator selector` fails
  9093. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  9094. rbuggyQSA.push(".#.+[+~]");
  9095. }
  9096. });
  9097. assert(function( el ) {
  9098. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  9099. "<select disabled='disabled'><option/></select>";
  9100. // Support: Windows 8 Native Apps
  9101. // The type and name attributes are restricted during .innerHTML assignment
  9102. var input = document.createElement("input");
  9103. input.setAttribute( "type", "hidden" );
  9104. el.appendChild( input ).setAttribute( "name", "D" );
  9105. // Support: IE8
  9106. // Enforce case-sensitivity of name attribute
  9107. if ( el.querySelectorAll("[name=d]").length ) {
  9108. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  9109. }
  9110. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  9111. // IE8 throws error here and will not see later tests
  9112. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  9113. rbuggyQSA.push( ":enabled", ":disabled" );
  9114. }
  9115. // Support: IE9-11+
  9116. // IE's :disabled selector does not pick up the children of disabled fieldsets
  9117. docElem.appendChild( el ).disabled = true;
  9118. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  9119. rbuggyQSA.push( ":enabled", ":disabled" );
  9120. }
  9121. // Opera 10-11 does not throw on post-comma invalid pseudos
  9122. el.querySelectorAll("*,:x");
  9123. rbuggyQSA.push(",.*:");
  9124. });
  9125. }
  9126. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  9127. docElem.webkitMatchesSelector ||
  9128. docElem.mozMatchesSelector ||
  9129. docElem.oMatchesSelector ||
  9130. docElem.msMatchesSelector) )) ) {
  9131. assert(function( el ) {
  9132. // Check to see if it's possible to do matchesSelector
  9133. // on a disconnected node (IE 9)
  9134. support.disconnectedMatch = matches.call( el, "*" );
  9135. // This should fail with an exception
  9136. // Gecko does not error, returns false instead
  9137. matches.call( el, "[s!='']:x" );
  9138. rbuggyMatches.push( "!=", pseudos );
  9139. });
  9140. }
  9141. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  9142. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  9143. /* Contains
  9144. ---------------------------------------------------------------------- */
  9145. hasCompare = rnative.test( docElem.compareDocumentPosition );
  9146. // Element contains another
  9147. // Purposefully self-exclusive
  9148. // As in, an element does not contain itself
  9149. contains = hasCompare || rnative.test( docElem.contains ) ?
  9150. function( a, b ) {
  9151. var adown = a.nodeType === 9 ? a.documentElement : a,
  9152. bup = b && b.parentNode;
  9153. return a === bup || !!( bup && bup.nodeType === 1 && (
  9154. adown.contains ?
  9155. adown.contains( bup ) :
  9156. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  9157. ));
  9158. } :
  9159. function( a, b ) {
  9160. if ( b ) {
  9161. while ( (b = b.parentNode) ) {
  9162. if ( b === a ) {
  9163. return true;
  9164. }
  9165. }
  9166. }
  9167. return false;
  9168. };
  9169. /* Sorting
  9170. ---------------------------------------------------------------------- */
  9171. // Document order sorting
  9172. sortOrder = hasCompare ?
  9173. function( a, b ) {
  9174. // Flag for duplicate removal
  9175. if ( a === b ) {
  9176. hasDuplicate = true;
  9177. return 0;
  9178. }
  9179. // Sort on method existence if only one input has compareDocumentPosition
  9180. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  9181. if ( compare ) {
  9182. return compare;
  9183. }
  9184. // Calculate position if both inputs belong to the same document
  9185. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  9186. a.compareDocumentPosition( b ) :
  9187. // Otherwise we know they are disconnected
  9188. 1;
  9189. // Disconnected nodes
  9190. if ( compare & 1 ||
  9191. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  9192. // Choose the first element that is related to our preferred document
  9193. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  9194. return -1;
  9195. }
  9196. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  9197. return 1;
  9198. }
  9199. // Maintain original order
  9200. return sortInput ?
  9201. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9202. 0;
  9203. }
  9204. return compare & 4 ? -1 : 1;
  9205. } :
  9206. function( a, b ) {
  9207. // Exit early if the nodes are identical
  9208. if ( a === b ) {
  9209. hasDuplicate = true;
  9210. return 0;
  9211. }
  9212. var cur,
  9213. i = 0,
  9214. aup = a.parentNode,
  9215. bup = b.parentNode,
  9216. ap = [ a ],
  9217. bp = [ b ];
  9218. // Parentless nodes are either documents or disconnected
  9219. if ( !aup || !bup ) {
  9220. return a === document ? -1 :
  9221. b === document ? 1 :
  9222. aup ? -1 :
  9223. bup ? 1 :
  9224. sortInput ?
  9225. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9226. 0;
  9227. // If the nodes are siblings, we can do a quick check
  9228. } else if ( aup === bup ) {
  9229. return siblingCheck( a, b );
  9230. }
  9231. // Otherwise we need full lists of their ancestors for comparison
  9232. cur = a;
  9233. while ( (cur = cur.parentNode) ) {
  9234. ap.unshift( cur );
  9235. }
  9236. cur = b;
  9237. while ( (cur = cur.parentNode) ) {
  9238. bp.unshift( cur );
  9239. }
  9240. // Walk down the tree looking for a discrepancy
  9241. while ( ap[i] === bp[i] ) {
  9242. i++;
  9243. }
  9244. return i ?
  9245. // Do a sibling check if the nodes have a common ancestor
  9246. siblingCheck( ap[i], bp[i] ) :
  9247. // Otherwise nodes in our document sort first
  9248. ap[i] === preferredDoc ? -1 :
  9249. bp[i] === preferredDoc ? 1 :
  9250. 0;
  9251. };
  9252. return document;
  9253. };
  9254. Sizzle.matches = function( expr, elements ) {
  9255. return Sizzle( expr, null, null, elements );
  9256. };
  9257. Sizzle.matchesSelector = function( elem, expr ) {
  9258. // Set document vars if needed
  9259. if ( ( elem.ownerDocument || elem ) !== document ) {
  9260. setDocument( elem );
  9261. }
  9262. if ( support.matchesSelector && documentIsHTML &&
  9263. !nonnativeSelectorCache[ expr + " " ] &&
  9264. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  9265. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  9266. try {
  9267. var ret = matches.call( elem, expr );
  9268. // IE 9's matchesSelector returns false on disconnected nodes
  9269. if ( ret || support.disconnectedMatch ||
  9270. // As well, disconnected nodes are said to be in a document
  9271. // fragment in IE 9
  9272. elem.document && elem.document.nodeType !== 11 ) {
  9273. return ret;
  9274. }
  9275. } catch (e) {
  9276. nonnativeSelectorCache( expr, true );
  9277. }
  9278. }
  9279. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  9280. };
  9281. Sizzle.contains = function( context, elem ) {
  9282. // Set document vars if needed
  9283. if ( ( context.ownerDocument || context ) !== document ) {
  9284. setDocument( context );
  9285. }
  9286. return contains( context, elem );
  9287. };
  9288. Sizzle.attr = function( elem, name ) {
  9289. // Set document vars if needed
  9290. if ( ( elem.ownerDocument || elem ) !== document ) {
  9291. setDocument( elem );
  9292. }
  9293. var fn = Expr.attrHandle[ name.toLowerCase() ],
  9294. // Don't get fooled by Object.prototype properties (jQuery #13807)
  9295. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  9296. fn( elem, name, !documentIsHTML ) :
  9297. undefined;
  9298. return val !== undefined ?
  9299. val :
  9300. support.attributes || !documentIsHTML ?
  9301. elem.getAttribute( name ) :
  9302. (val = elem.getAttributeNode(name)) && val.specified ?
  9303. val.value :
  9304. null;
  9305. };
  9306. Sizzle.escape = function( sel ) {
  9307. return (sel + "").replace( rcssescape, fcssescape );
  9308. };
  9309. Sizzle.error = function( msg ) {
  9310. throw new Error( "Syntax error, unrecognized expression: " + msg );
  9311. };
  9312. /**
  9313. * Document sorting and removing duplicates
  9314. * @param {ArrayLike} results
  9315. */
  9316. Sizzle.uniqueSort = function( results ) {
  9317. var elem,
  9318. duplicates = [],
  9319. j = 0,
  9320. i = 0;
  9321. // Unless we *know* we can detect duplicates, assume their presence
  9322. hasDuplicate = !support.detectDuplicates;
  9323. sortInput = !support.sortStable && results.slice( 0 );
  9324. results.sort( sortOrder );
  9325. if ( hasDuplicate ) {
  9326. while ( (elem = results[i++]) ) {
  9327. if ( elem === results[ i ] ) {
  9328. j = duplicates.push( i );
  9329. }
  9330. }
  9331. while ( j-- ) {
  9332. results.splice( duplicates[ j ], 1 );
  9333. }
  9334. }
  9335. // Clear input after sorting to release objects
  9336. // See https://github.com/jquery/sizzle/pull/225
  9337. sortInput = null;
  9338. return results;
  9339. };
  9340. /**
  9341. * Utility function for retrieving the text value of an array of DOM nodes
  9342. * @param {Array|Element} elem
  9343. */
  9344. getText = Sizzle.getText = function( elem ) {
  9345. var node,
  9346. ret = "",
  9347. i = 0,
  9348. nodeType = elem.nodeType;
  9349. if ( !nodeType ) {
  9350. // If no nodeType, this is expected to be an array
  9351. while ( (node = elem[i++]) ) {
  9352. // Do not traverse comment nodes
  9353. ret += getText( node );
  9354. }
  9355. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  9356. // Use textContent for elements
  9357. // innerText usage removed for consistency of new lines (jQuery #11153)
  9358. if ( typeof elem.textContent === "string" ) {
  9359. return elem.textContent;
  9360. } else {
  9361. // Traverse its children
  9362. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9363. ret += getText( elem );
  9364. }
  9365. }
  9366. } else if ( nodeType === 3 || nodeType === 4 ) {
  9367. return elem.nodeValue;
  9368. }
  9369. // Do not include comment or processing instruction nodes
  9370. return ret;
  9371. };
  9372. Expr = Sizzle.selectors = {
  9373. // Can be adjusted by the user
  9374. cacheLength: 50,
  9375. createPseudo: markFunction,
  9376. match: matchExpr,
  9377. attrHandle: {},
  9378. find: {},
  9379. relative: {
  9380. ">": { dir: "parentNode", first: true },
  9381. " ": { dir: "parentNode" },
  9382. "+": { dir: "previousSibling", first: true },
  9383. "~": { dir: "previousSibling" }
  9384. },
  9385. preFilter: {
  9386. "ATTR": function( match ) {
  9387. match[1] = match[1].replace( runescape, funescape );
  9388. // Move the given value to match[3] whether quoted or unquoted
  9389. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  9390. if ( match[2] === "~=" ) {
  9391. match[3] = " " + match[3] + " ";
  9392. }
  9393. return match.slice( 0, 4 );
  9394. },
  9395. "CHILD": function( match ) {
  9396. /* matches from matchExpr["CHILD"]
  9397. 1 type (only|nth|...)
  9398. 2 what (child|of-type)
  9399. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  9400. 4 xn-component of xn+y argument ([+-]?\d*n|)
  9401. 5 sign of xn-component
  9402. 6 x of xn-component
  9403. 7 sign of y-component
  9404. 8 y of y-component
  9405. */
  9406. match[1] = match[1].toLowerCase();
  9407. if ( match[1].slice( 0, 3 ) === "nth" ) {
  9408. // nth-* requires argument
  9409. if ( !match[3] ) {
  9410. Sizzle.error( match[0] );
  9411. }
  9412. // numeric x and y parameters for Expr.filter.CHILD
  9413. // remember that false/true cast respectively to 0/1
  9414. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  9415. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  9416. // other types prohibit arguments
  9417. } else if ( match[3] ) {
  9418. Sizzle.error( match[0] );
  9419. }
  9420. return match;
  9421. },
  9422. "PSEUDO": function( match ) {
  9423. var excess,
  9424. unquoted = !match[6] && match[2];
  9425. if ( matchExpr["CHILD"].test( match[0] ) ) {
  9426. return null;
  9427. }
  9428. // Accept quoted arguments as-is
  9429. if ( match[3] ) {
  9430. match[2] = match[4] || match[5] || "";
  9431. // Strip excess characters from unquoted arguments
  9432. } else if ( unquoted && rpseudo.test( unquoted ) &&
  9433. // Get excess from tokenize (recursively)
  9434. (excess = tokenize( unquoted, true )) &&
  9435. // advance to the next closing parenthesis
  9436. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  9437. // excess is a negative index
  9438. match[0] = match[0].slice( 0, excess );
  9439. match[2] = unquoted.slice( 0, excess );
  9440. }
  9441. // Return only captures needed by the pseudo filter method (type and argument)
  9442. return match.slice( 0, 3 );
  9443. }
  9444. },
  9445. filter: {
  9446. "TAG": function( nodeNameSelector ) {
  9447. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  9448. return nodeNameSelector === "*" ?
  9449. function() { return true; } :
  9450. function( elem ) {
  9451. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  9452. };
  9453. },
  9454. "CLASS": function( className ) {
  9455. var pattern = classCache[ className + " " ];
  9456. return pattern ||
  9457. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  9458. classCache( className, function( elem ) {
  9459. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  9460. });
  9461. },
  9462. "ATTR": function( name, operator, check ) {
  9463. return function( elem ) {
  9464. var result = Sizzle.attr( elem, name );
  9465. if ( result == null ) {
  9466. return operator === "!=";
  9467. }
  9468. if ( !operator ) {
  9469. return true;
  9470. }
  9471. result += "";
  9472. return operator === "=" ? result === check :
  9473. operator === "!=" ? result !== check :
  9474. operator === "^=" ? check && result.indexOf( check ) === 0 :
  9475. operator === "*=" ? check && result.indexOf( check ) > -1 :
  9476. operator === "$=" ? check && result.slice( -check.length ) === check :
  9477. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  9478. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  9479. false;
  9480. };
  9481. },
  9482. "CHILD": function( type, what, argument, first, last ) {
  9483. var simple = type.slice( 0, 3 ) !== "nth",
  9484. forward = type.slice( -4 ) !== "last",
  9485. ofType = what === "of-type";
  9486. return first === 1 && last === 0 ?
  9487. // Shortcut for :nth-*(n)
  9488. function( elem ) {
  9489. return !!elem.parentNode;
  9490. } :
  9491. function( elem, context, xml ) {
  9492. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  9493. dir = simple !== forward ? "nextSibling" : "previousSibling",
  9494. parent = elem.parentNode,
  9495. name = ofType && elem.nodeName.toLowerCase(),
  9496. useCache = !xml && !ofType,
  9497. diff = false;
  9498. if ( parent ) {
  9499. // :(first|last|only)-(child|of-type)
  9500. if ( simple ) {
  9501. while ( dir ) {
  9502. node = elem;
  9503. while ( (node = node[ dir ]) ) {
  9504. if ( ofType ?
  9505. node.nodeName.toLowerCase() === name :
  9506. node.nodeType === 1 ) {
  9507. return false;
  9508. }
  9509. }
  9510. // Reverse direction for :only-* (if we haven't yet done so)
  9511. start = dir = type === "only" && !start && "nextSibling";
  9512. }
  9513. return true;
  9514. }
  9515. start = [ forward ? parent.firstChild : parent.lastChild ];
  9516. // non-xml :nth-child(...) stores cache data on `parent`
  9517. if ( forward && useCache ) {
  9518. // Seek `elem` from a previously-cached index
  9519. // ...in a gzip-friendly way
  9520. node = parent;
  9521. outerCache = node[ expando ] || (node[ expando ] = {});
  9522. // Support: IE <9 only
  9523. // Defend against cloned attroperties (jQuery gh-1709)
  9524. uniqueCache = outerCache[ node.uniqueID ] ||
  9525. (outerCache[ node.uniqueID ] = {});
  9526. cache = uniqueCache[ type ] || [];
  9527. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9528. diff = nodeIndex && cache[ 2 ];
  9529. node = nodeIndex && parent.childNodes[ nodeIndex ];
  9530. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9531. // Fallback to seeking `elem` from the start
  9532. (diff = nodeIndex = 0) || start.pop()) ) {
  9533. // When found, cache indexes on `parent` and break
  9534. if ( node.nodeType === 1 && ++diff && node === elem ) {
  9535. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  9536. break;
  9537. }
  9538. }
  9539. } else {
  9540. // Use previously-cached element index if available
  9541. if ( useCache ) {
  9542. // ...in a gzip-friendly way
  9543. node = elem;
  9544. outerCache = node[ expando ] || (node[ expando ] = {});
  9545. // Support: IE <9 only
  9546. // Defend against cloned attroperties (jQuery gh-1709)
  9547. uniqueCache = outerCache[ node.uniqueID ] ||
  9548. (outerCache[ node.uniqueID ] = {});
  9549. cache = uniqueCache[ type ] || [];
  9550. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9551. diff = nodeIndex;
  9552. }
  9553. // xml :nth-child(...)
  9554. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  9555. if ( diff === false ) {
  9556. // Use the same loop as above to seek `elem` from the start
  9557. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9558. (diff = nodeIndex = 0) || start.pop()) ) {
  9559. if ( ( ofType ?
  9560. node.nodeName.toLowerCase() === name :
  9561. node.nodeType === 1 ) &&
  9562. ++diff ) {
  9563. // Cache the index of each encountered element
  9564. if ( useCache ) {
  9565. outerCache = node[ expando ] || (node[ expando ] = {});
  9566. // Support: IE <9 only
  9567. // Defend against cloned attroperties (jQuery gh-1709)
  9568. uniqueCache = outerCache[ node.uniqueID ] ||
  9569. (outerCache[ node.uniqueID ] = {});
  9570. uniqueCache[ type ] = [ dirruns, diff ];
  9571. }
  9572. if ( node === elem ) {
  9573. break;
  9574. }
  9575. }
  9576. }
  9577. }
  9578. }
  9579. // Incorporate the offset, then check against cycle size
  9580. diff -= last;
  9581. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  9582. }
  9583. };
  9584. },
  9585. "PSEUDO": function( pseudo, argument ) {
  9586. // pseudo-class names are case-insensitive
  9587. // http://www.w3.org/TR/selectors/#pseudo-classes
  9588. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  9589. // Remember that setFilters inherits from pseudos
  9590. var args,
  9591. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  9592. Sizzle.error( "unsupported pseudo: " + pseudo );
  9593. // The user may use createPseudo to indicate that
  9594. // arguments are needed to create the filter function
  9595. // just as Sizzle does
  9596. if ( fn[ expando ] ) {
  9597. return fn( argument );
  9598. }
  9599. // But maintain support for old signatures
  9600. if ( fn.length > 1 ) {
  9601. args = [ pseudo, pseudo, "", argument ];
  9602. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  9603. markFunction(function( seed, matches ) {
  9604. var idx,
  9605. matched = fn( seed, argument ),
  9606. i = matched.length;
  9607. while ( i-- ) {
  9608. idx = indexOf( seed, matched[i] );
  9609. seed[ idx ] = !( matches[ idx ] = matched[i] );
  9610. }
  9611. }) :
  9612. function( elem ) {
  9613. return fn( elem, 0, args );
  9614. };
  9615. }
  9616. return fn;
  9617. }
  9618. },
  9619. pseudos: {
  9620. // Potentially complex pseudos
  9621. "not": markFunction(function( selector ) {
  9622. // Trim the selector passed to compile
  9623. // to avoid treating leading and trailing
  9624. // spaces as combinators
  9625. var input = [],
  9626. results = [],
  9627. matcher = compile( selector.replace( rtrim, "$1" ) );
  9628. return matcher[ expando ] ?
  9629. markFunction(function( seed, matches, context, xml ) {
  9630. var elem,
  9631. unmatched = matcher( seed, null, xml, [] ),
  9632. i = seed.length;
  9633. // Match elements unmatched by `matcher`
  9634. while ( i-- ) {
  9635. if ( (elem = unmatched[i]) ) {
  9636. seed[i] = !(matches[i] = elem);
  9637. }
  9638. }
  9639. }) :
  9640. function( elem, context, xml ) {
  9641. input[0] = elem;
  9642. matcher( input, null, xml, results );
  9643. // Don't keep the element (issue #299)
  9644. input[0] = null;
  9645. return !results.pop();
  9646. };
  9647. }),
  9648. "has": markFunction(function( selector ) {
  9649. return function( elem ) {
  9650. return Sizzle( selector, elem ).length > 0;
  9651. };
  9652. }),
  9653. "contains": markFunction(function( text ) {
  9654. text = text.replace( runescape, funescape );
  9655. return function( elem ) {
  9656. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  9657. };
  9658. }),
  9659. // "Whether an element is represented by a :lang() selector
  9660. // is based solely on the element's language value
  9661. // being equal to the identifier C,
  9662. // or beginning with the identifier C immediately followed by "-".
  9663. // The matching of C against the element's language value is performed case-insensitively.
  9664. // The identifier C does not have to be a valid language name."
  9665. // http://www.w3.org/TR/selectors/#lang-pseudo
  9666. "lang": markFunction( function( lang ) {
  9667. // lang value must be a valid identifier
  9668. if ( !ridentifier.test(lang || "") ) {
  9669. Sizzle.error( "unsupported lang: " + lang );
  9670. }
  9671. lang = lang.replace( runescape, funescape ).toLowerCase();
  9672. return function( elem ) {
  9673. var elemLang;
  9674. do {
  9675. if ( (elemLang = documentIsHTML ?
  9676. elem.lang :
  9677. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  9678. elemLang = elemLang.toLowerCase();
  9679. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  9680. }
  9681. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  9682. return false;
  9683. };
  9684. }),
  9685. // Miscellaneous
  9686. "target": function( elem ) {
  9687. var hash = window.location && window.location.hash;
  9688. return hash && hash.slice( 1 ) === elem.id;
  9689. },
  9690. "root": function( elem ) {
  9691. return elem === docElem;
  9692. },
  9693. "focus": function( elem ) {
  9694. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  9695. },
  9696. // Boolean properties
  9697. "enabled": createDisabledPseudo( false ),
  9698. "disabled": createDisabledPseudo( true ),
  9699. "checked": function( elem ) {
  9700. // In CSS3, :checked should return both checked and selected elements
  9701. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9702. var nodeName = elem.nodeName.toLowerCase();
  9703. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  9704. },
  9705. "selected": function( elem ) {
  9706. // Accessing this property makes selected-by-default
  9707. // options in Safari work properly
  9708. if ( elem.parentNode ) {
  9709. elem.parentNode.selectedIndex;
  9710. }
  9711. return elem.selected === true;
  9712. },
  9713. // Contents
  9714. "empty": function( elem ) {
  9715. // http://www.w3.org/TR/selectors/#empty-pseudo
  9716. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  9717. // but not by others (comment: 8; processing instruction: 7; etc.)
  9718. // nodeType < 6 works because attributes (2) do not appear as children
  9719. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9720. if ( elem.nodeType < 6 ) {
  9721. return false;
  9722. }
  9723. }
  9724. return true;
  9725. },
  9726. "parent": function( elem ) {
  9727. return !Expr.pseudos["empty"]( elem );
  9728. },
  9729. // Element/input types
  9730. "header": function( elem ) {
  9731. return rheader.test( elem.nodeName );
  9732. },
  9733. "input": function( elem ) {
  9734. return rinputs.test( elem.nodeName );
  9735. },
  9736. "button": function( elem ) {
  9737. var name = elem.nodeName.toLowerCase();
  9738. return name === "input" && elem.type === "button" || name === "button";
  9739. },
  9740. "text": function( elem ) {
  9741. var attr;
  9742. return elem.nodeName.toLowerCase() === "input" &&
  9743. elem.type === "text" &&
  9744. // Support: IE<8
  9745. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  9746. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  9747. },
  9748. // Position-in-collection
  9749. "first": createPositionalPseudo(function() {
  9750. return [ 0 ];
  9751. }),
  9752. "last": createPositionalPseudo(function( matchIndexes, length ) {
  9753. return [ length - 1 ];
  9754. }),
  9755. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9756. return [ argument < 0 ? argument + length : argument ];
  9757. }),
  9758. "even": createPositionalPseudo(function( matchIndexes, length ) {
  9759. var i = 0;
  9760. for ( ; i < length; i += 2 ) {
  9761. matchIndexes.push( i );
  9762. }
  9763. return matchIndexes;
  9764. }),
  9765. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  9766. var i = 1;
  9767. for ( ; i < length; i += 2 ) {
  9768. matchIndexes.push( i );
  9769. }
  9770. return matchIndexes;
  9771. }),
  9772. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9773. var i = argument < 0 ?
  9774. argument + length :
  9775. argument > length ?
  9776. length :
  9777. argument;
  9778. for ( ; --i >= 0; ) {
  9779. matchIndexes.push( i );
  9780. }
  9781. return matchIndexes;
  9782. }),
  9783. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9784. var i = argument < 0 ? argument + length : argument;
  9785. for ( ; ++i < length; ) {
  9786. matchIndexes.push( i );
  9787. }
  9788. return matchIndexes;
  9789. })
  9790. }
  9791. };
  9792. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  9793. // Add button/input type pseudos
  9794. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  9795. Expr.pseudos[ i ] = createInputPseudo( i );
  9796. }
  9797. for ( i in { submit: true, reset: true } ) {
  9798. Expr.pseudos[ i ] = createButtonPseudo( i );
  9799. }
  9800. // Easy API for creating new setFilters
  9801. function setFilters() {}
  9802. setFilters.prototype = Expr.filters = Expr.pseudos;
  9803. Expr.setFilters = new setFilters();
  9804. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  9805. var matched, match, tokens, type,
  9806. soFar, groups, preFilters,
  9807. cached = tokenCache[ selector + " " ];
  9808. if ( cached ) {
  9809. return parseOnly ? 0 : cached.slice( 0 );
  9810. }
  9811. soFar = selector;
  9812. groups = [];
  9813. preFilters = Expr.preFilter;
  9814. while ( soFar ) {
  9815. // Comma and first run
  9816. if ( !matched || (match = rcomma.exec( soFar )) ) {
  9817. if ( match ) {
  9818. // Don't consume trailing commas as valid
  9819. soFar = soFar.slice( match[0].length ) || soFar;
  9820. }
  9821. groups.push( (tokens = []) );
  9822. }
  9823. matched = false;
  9824. // Combinators
  9825. if ( (match = rcombinators.exec( soFar )) ) {
  9826. matched = match.shift();
  9827. tokens.push({
  9828. value: matched,
  9829. // Cast descendant combinators to space
  9830. type: match[0].replace( rtrim, " " )
  9831. });
  9832. soFar = soFar.slice( matched.length );
  9833. }
  9834. // Filters
  9835. for ( type in Expr.filter ) {
  9836. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  9837. (match = preFilters[ type ]( match ))) ) {
  9838. matched = match.shift();
  9839. tokens.push({
  9840. value: matched,
  9841. type: type,
  9842. matches: match
  9843. });
  9844. soFar = soFar.slice( matched.length );
  9845. }
  9846. }
  9847. if ( !matched ) {
  9848. break;
  9849. }
  9850. }
  9851. // Return the length of the invalid excess
  9852. // if we're just parsing
  9853. // Otherwise, throw an error or return tokens
  9854. return parseOnly ?
  9855. soFar.length :
  9856. soFar ?
  9857. Sizzle.error( selector ) :
  9858. // Cache the tokens
  9859. tokenCache( selector, groups ).slice( 0 );
  9860. };
  9861. function toSelector( tokens ) {
  9862. var i = 0,
  9863. len = tokens.length,
  9864. selector = "";
  9865. for ( ; i < len; i++ ) {
  9866. selector += tokens[i].value;
  9867. }
  9868. return selector;
  9869. }
  9870. function addCombinator( matcher, combinator, base ) {
  9871. var dir = combinator.dir,
  9872. skip = combinator.next,
  9873. key = skip || dir,
  9874. checkNonElements = base && key === "parentNode",
  9875. doneName = done++;
  9876. return combinator.first ?
  9877. // Check against closest ancestor/preceding element
  9878. function( elem, context, xml ) {
  9879. while ( (elem = elem[ dir ]) ) {
  9880. if ( elem.nodeType === 1 || checkNonElements ) {
  9881. return matcher( elem, context, xml );
  9882. }
  9883. }
  9884. return false;
  9885. } :
  9886. // Check against all ancestor/preceding elements
  9887. function( elem, context, xml ) {
  9888. var oldCache, uniqueCache, outerCache,
  9889. newCache = [ dirruns, doneName ];
  9890. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  9891. if ( xml ) {
  9892. while ( (elem = elem[ dir ]) ) {
  9893. if ( elem.nodeType === 1 || checkNonElements ) {
  9894. if ( matcher( elem, context, xml ) ) {
  9895. return true;
  9896. }
  9897. }
  9898. }
  9899. } else {
  9900. while ( (elem = elem[ dir ]) ) {
  9901. if ( elem.nodeType === 1 || checkNonElements ) {
  9902. outerCache = elem[ expando ] || (elem[ expando ] = {});
  9903. // Support: IE <9 only
  9904. // Defend against cloned attroperties (jQuery gh-1709)
  9905. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  9906. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  9907. elem = elem[ dir ] || elem;
  9908. } else if ( (oldCache = uniqueCache[ key ]) &&
  9909. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  9910. // Assign to newCache so results back-propagate to previous elements
  9911. return (newCache[ 2 ] = oldCache[ 2 ]);
  9912. } else {
  9913. // Reuse newcache so results back-propagate to previous elements
  9914. uniqueCache[ key ] = newCache;
  9915. // A match means we're done; a fail means we have to keep checking
  9916. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  9917. return true;
  9918. }
  9919. }
  9920. }
  9921. }
  9922. }
  9923. return false;
  9924. };
  9925. }
  9926. function elementMatcher( matchers ) {
  9927. return matchers.length > 1 ?
  9928. function( elem, context, xml ) {
  9929. var i = matchers.length;
  9930. while ( i-- ) {
  9931. if ( !matchers[i]( elem, context, xml ) ) {
  9932. return false;
  9933. }
  9934. }
  9935. return true;
  9936. } :
  9937. matchers[0];
  9938. }
  9939. function multipleContexts( selector, contexts, results ) {
  9940. var i = 0,
  9941. len = contexts.length;
  9942. for ( ; i < len; i++ ) {
  9943. Sizzle( selector, contexts[i], results );
  9944. }
  9945. return results;
  9946. }
  9947. function condense( unmatched, map, filter, context, xml ) {
  9948. var elem,
  9949. newUnmatched = [],
  9950. i = 0,
  9951. len = unmatched.length,
  9952. mapped = map != null;
  9953. for ( ; i < len; i++ ) {
  9954. if ( (elem = unmatched[i]) ) {
  9955. if ( !filter || filter( elem, context, xml ) ) {
  9956. newUnmatched.push( elem );
  9957. if ( mapped ) {
  9958. map.push( i );
  9959. }
  9960. }
  9961. }
  9962. }
  9963. return newUnmatched;
  9964. }
  9965. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  9966. if ( postFilter && !postFilter[ expando ] ) {
  9967. postFilter = setMatcher( postFilter );
  9968. }
  9969. if ( postFinder && !postFinder[ expando ] ) {
  9970. postFinder = setMatcher( postFinder, postSelector );
  9971. }
  9972. return markFunction(function( seed, results, context, xml ) {
  9973. var temp, i, elem,
  9974. preMap = [],
  9975. postMap = [],
  9976. preexisting = results.length,
  9977. // Get initial elements from seed or context
  9978. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  9979. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  9980. matcherIn = preFilter && ( seed || !selector ) ?
  9981. condense( elems, preMap, preFilter, context, xml ) :
  9982. elems,
  9983. matcherOut = matcher ?
  9984. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  9985. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  9986. // ...intermediate processing is necessary
  9987. [] :
  9988. // ...otherwise use results directly
  9989. results :
  9990. matcherIn;
  9991. // Find primary matches
  9992. if ( matcher ) {
  9993. matcher( matcherIn, matcherOut, context, xml );
  9994. }
  9995. // Apply postFilter
  9996. if ( postFilter ) {
  9997. temp = condense( matcherOut, postMap );
  9998. postFilter( temp, [], context, xml );
  9999. // Un-match failing elements by moving them back to matcherIn
  10000. i = temp.length;
  10001. while ( i-- ) {
  10002. if ( (elem = temp[i]) ) {
  10003. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  10004. }
  10005. }
  10006. }
  10007. if ( seed ) {
  10008. if ( postFinder || preFilter ) {
  10009. if ( postFinder ) {
  10010. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  10011. temp = [];
  10012. i = matcherOut.length;
  10013. while ( i-- ) {
  10014. if ( (elem = matcherOut[i]) ) {
  10015. // Restore matcherIn since elem is not yet a final match
  10016. temp.push( (matcherIn[i] = elem) );
  10017. }
  10018. }
  10019. postFinder( null, (matcherOut = []), temp, xml );
  10020. }
  10021. // Move matched elements from seed to results to keep them synchronized
  10022. i = matcherOut.length;
  10023. while ( i-- ) {
  10024. if ( (elem = matcherOut[i]) &&
  10025. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  10026. seed[temp] = !(results[temp] = elem);
  10027. }
  10028. }
  10029. }
  10030. // Add elements to results, through postFinder if defined
  10031. } else {
  10032. matcherOut = condense(
  10033. matcherOut === results ?
  10034. matcherOut.splice( preexisting, matcherOut.length ) :
  10035. matcherOut
  10036. );
  10037. if ( postFinder ) {
  10038. postFinder( null, results, matcherOut, xml );
  10039. } else {
  10040. push.apply( results, matcherOut );
  10041. }
  10042. }
  10043. });
  10044. }
  10045. function matcherFromTokens( tokens ) {
  10046. var checkContext, matcher, j,
  10047. len = tokens.length,
  10048. leadingRelative = Expr.relative[ tokens[0].type ],
  10049. implicitRelative = leadingRelative || Expr.relative[" "],
  10050. i = leadingRelative ? 1 : 0,
  10051. // The foundational matcher ensures that elements are reachable from top-level context(s)
  10052. matchContext = addCombinator( function( elem ) {
  10053. return elem === checkContext;
  10054. }, implicitRelative, true ),
  10055. matchAnyContext = addCombinator( function( elem ) {
  10056. return indexOf( checkContext, elem ) > -1;
  10057. }, implicitRelative, true ),
  10058. matchers = [ function( elem, context, xml ) {
  10059. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  10060. (checkContext = context).nodeType ?
  10061. matchContext( elem, context, xml ) :
  10062. matchAnyContext( elem, context, xml ) );
  10063. // Avoid hanging onto element (issue #299)
  10064. checkContext = null;
  10065. return ret;
  10066. } ];
  10067. for ( ; i < len; i++ ) {
  10068. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  10069. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  10070. } else {
  10071. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  10072. // Return special upon seeing a positional matcher
  10073. if ( matcher[ expando ] ) {
  10074. // Find the next relative operator (if any) for proper handling
  10075. j = ++i;
  10076. for ( ; j < len; j++ ) {
  10077. if ( Expr.relative[ tokens[j].type ] ) {
  10078. break;
  10079. }
  10080. }
  10081. return setMatcher(
  10082. i > 1 && elementMatcher( matchers ),
  10083. i > 1 && toSelector(
  10084. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  10085. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  10086. ).replace( rtrim, "$1" ),
  10087. matcher,
  10088. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  10089. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  10090. j < len && toSelector( tokens )
  10091. );
  10092. }
  10093. matchers.push( matcher );
  10094. }
  10095. }
  10096. return elementMatcher( matchers );
  10097. }
  10098. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  10099. var bySet = setMatchers.length > 0,
  10100. byElement = elementMatchers.length > 0,
  10101. superMatcher = function( seed, context, xml, results, outermost ) {
  10102. var elem, j, matcher,
  10103. matchedCount = 0,
  10104. i = "0",
  10105. unmatched = seed && [],
  10106. setMatched = [],
  10107. contextBackup = outermostContext,
  10108. // We must always have either seed elements or outermost context
  10109. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  10110. // Use integer dirruns iff this is the outermost matcher
  10111. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  10112. len = elems.length;
  10113. if ( outermost ) {
  10114. outermostContext = context === document || context || outermost;
  10115. }
  10116. // Add elements passing elementMatchers directly to results
  10117. // Support: IE<9, Safari
  10118. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  10119. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  10120. if ( byElement && elem ) {
  10121. j = 0;
  10122. if ( !context && elem.ownerDocument !== document ) {
  10123. setDocument( elem );
  10124. xml = !documentIsHTML;
  10125. }
  10126. while ( (matcher = elementMatchers[j++]) ) {
  10127. if ( matcher( elem, context || document, xml) ) {
  10128. results.push( elem );
  10129. break;
  10130. }
  10131. }
  10132. if ( outermost ) {
  10133. dirruns = dirrunsUnique;
  10134. }
  10135. }
  10136. // Track unmatched elements for set filters
  10137. if ( bySet ) {
  10138. // They will have gone through all possible matchers
  10139. if ( (elem = !matcher && elem) ) {
  10140. matchedCount--;
  10141. }
  10142. // Lengthen the array for every element, matched or not
  10143. if ( seed ) {
  10144. unmatched.push( elem );
  10145. }
  10146. }
  10147. }
  10148. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  10149. // makes the latter nonnegative.
  10150. matchedCount += i;
  10151. // Apply set filters to unmatched elements
  10152. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  10153. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  10154. // no element matchers and no seed.
  10155. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  10156. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  10157. // numerically zero.
  10158. if ( bySet && i !== matchedCount ) {
  10159. j = 0;
  10160. while ( (matcher = setMatchers[j++]) ) {
  10161. matcher( unmatched, setMatched, context, xml );
  10162. }
  10163. if ( seed ) {
  10164. // Reintegrate element matches to eliminate the need for sorting
  10165. if ( matchedCount > 0 ) {
  10166. while ( i-- ) {
  10167. if ( !(unmatched[i] || setMatched[i]) ) {
  10168. setMatched[i] = pop.call( results );
  10169. }
  10170. }
  10171. }
  10172. // Discard index placeholder values to get only actual matches
  10173. setMatched = condense( setMatched );
  10174. }
  10175. // Add matches to results
  10176. push.apply( results, setMatched );
  10177. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  10178. if ( outermost && !seed && setMatched.length > 0 &&
  10179. ( matchedCount + setMatchers.length ) > 1 ) {
  10180. Sizzle.uniqueSort( results );
  10181. }
  10182. }
  10183. // Override manipulation of globals by nested matchers
  10184. if ( outermost ) {
  10185. dirruns = dirrunsUnique;
  10186. outermostContext = contextBackup;
  10187. }
  10188. return unmatched;
  10189. };
  10190. return bySet ?
  10191. markFunction( superMatcher ) :
  10192. superMatcher;
  10193. }
  10194. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  10195. var i,
  10196. setMatchers = [],
  10197. elementMatchers = [],
  10198. cached = compilerCache[ selector + " " ];
  10199. if ( !cached ) {
  10200. // Generate a function of recursive functions that can be used to check each element
  10201. if ( !match ) {
  10202. match = tokenize( selector );
  10203. }
  10204. i = match.length;
  10205. while ( i-- ) {
  10206. cached = matcherFromTokens( match[i] );
  10207. if ( cached[ expando ] ) {
  10208. setMatchers.push( cached );
  10209. } else {
  10210. elementMatchers.push( cached );
  10211. }
  10212. }
  10213. // Cache the compiled function
  10214. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  10215. // Save selector and tokenization
  10216. cached.selector = selector;
  10217. }
  10218. return cached;
  10219. };
  10220. /**
  10221. * A low-level selection function that works with Sizzle's compiled
  10222. * selector functions
  10223. * @param {String|Function} selector A selector or a pre-compiled
  10224. * selector function built with Sizzle.compile
  10225. * @param {Element} context
  10226. * @param {Array} [results]
  10227. * @param {Array} [seed] A set of elements to match against
  10228. */
  10229. select = Sizzle.select = function( selector, context, results, seed ) {
  10230. var i, tokens, token, type, find,
  10231. compiled = typeof selector === "function" && selector,
  10232. match = !seed && tokenize( (selector = compiled.selector || selector) );
  10233. results = results || [];
  10234. // Try to minimize operations if there is only one selector in the list and no seed
  10235. // (the latter of which guarantees us context)
  10236. if ( match.length === 1 ) {
  10237. // Reduce context if the leading compound selector is an ID
  10238. tokens = match[0] = match[0].slice( 0 );
  10239. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  10240. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  10241. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  10242. if ( !context ) {
  10243. return results;
  10244. // Precompiled matchers will still verify ancestry, so step up a level
  10245. } else if ( compiled ) {
  10246. context = context.parentNode;
  10247. }
  10248. selector = selector.slice( tokens.shift().value.length );
  10249. }
  10250. // Fetch a seed set for right-to-left matching
  10251. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  10252. while ( i-- ) {
  10253. token = tokens[i];
  10254. // Abort if we hit a combinator
  10255. if ( Expr.relative[ (type = token.type) ] ) {
  10256. break;
  10257. }
  10258. if ( (find = Expr.find[ type ]) ) {
  10259. // Search, expanding context for leading sibling combinators
  10260. if ( (seed = find(
  10261. token.matches[0].replace( runescape, funescape ),
  10262. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  10263. )) ) {
  10264. // If seed is empty or no tokens remain, we can return early
  10265. tokens.splice( i, 1 );
  10266. selector = seed.length && toSelector( tokens );
  10267. if ( !selector ) {
  10268. push.apply( results, seed );
  10269. return results;
  10270. }
  10271. break;
  10272. }
  10273. }
  10274. }
  10275. }
  10276. // Compile and execute a filtering function if one is not provided
  10277. // Provide `match` to avoid retokenization if we modified the selector above
  10278. ( compiled || compile( selector, match ) )(
  10279. seed,
  10280. context,
  10281. !documentIsHTML,
  10282. results,
  10283. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  10284. );
  10285. return results;
  10286. };
  10287. // One-time assignments
  10288. // Sort stability
  10289. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  10290. // Support: Chrome 14-35+
  10291. // Always assume duplicates if they aren't passed to the comparison function
  10292. support.detectDuplicates = !!hasDuplicate;
  10293. // Initialize against the default document
  10294. setDocument();
  10295. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  10296. // Detached nodes confoundingly follow *each other*
  10297. support.sortDetached = assert(function( el ) {
  10298. // Should return 1, but returns 4 (following)
  10299. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  10300. });
  10301. // Support: IE<8
  10302. // Prevent attribute/property "interpolation"
  10303. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  10304. if ( !assert(function( el ) {
  10305. el.innerHTML = "<a href='#'></a>";
  10306. return el.firstChild.getAttribute("href") === "#" ;
  10307. }) ) {
  10308. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  10309. if ( !isXML ) {
  10310. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  10311. }
  10312. });
  10313. }
  10314. // Support: IE<9
  10315. // Use defaultValue in place of getAttribute("value")
  10316. if ( !support.attributes || !assert(function( el ) {
  10317. el.innerHTML = "<input/>";
  10318. el.firstChild.setAttribute( "value", "" );
  10319. return el.firstChild.getAttribute( "value" ) === "";
  10320. }) ) {
  10321. addHandle( "value", function( elem, name, isXML ) {
  10322. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  10323. return elem.defaultValue;
  10324. }
  10325. });
  10326. }
  10327. // Support: IE<9
  10328. // Use getAttributeNode to fetch booleans when getAttribute lies
  10329. if ( !assert(function( el ) {
  10330. return el.getAttribute("disabled") == null;
  10331. }) ) {
  10332. addHandle( booleans, function( elem, name, isXML ) {
  10333. var val;
  10334. if ( !isXML ) {
  10335. return elem[ name ] === true ? name.toLowerCase() :
  10336. (val = elem.getAttributeNode( name )) && val.specified ?
  10337. val.value :
  10338. null;
  10339. }
  10340. });
  10341. }
  10342. return Sizzle;
  10343. })( window );
  10344. jQuery.find = Sizzle;
  10345. jQuery.expr = Sizzle.selectors;
  10346. // Deprecated
  10347. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  10348. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  10349. jQuery.text = Sizzle.getText;
  10350. jQuery.isXMLDoc = Sizzle.isXML;
  10351. jQuery.contains = Sizzle.contains;
  10352. jQuery.escapeSelector = Sizzle.escape;
  10353. var dir = function( elem, dir, until ) {
  10354. var matched = [],
  10355. truncate = until !== undefined;
  10356. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  10357. if ( elem.nodeType === 1 ) {
  10358. if ( truncate && jQuery( elem ).is( until ) ) {
  10359. break;
  10360. }
  10361. matched.push( elem );
  10362. }
  10363. }
  10364. return matched;
  10365. };
  10366. var siblings = function( n, elem ) {
  10367. var matched = [];
  10368. for ( ; n; n = n.nextSibling ) {
  10369. if ( n.nodeType === 1 && n !== elem ) {
  10370. matched.push( n );
  10371. }
  10372. }
  10373. return matched;
  10374. };
  10375. var rneedsContext = jQuery.expr.match.needsContext;
  10376. function nodeName( elem, name ) {
  10377. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  10378. };
  10379. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  10380. // Implement the identical functionality for filter and not
  10381. function winnow( elements, qualifier, not ) {
  10382. if ( isFunction( qualifier ) ) {
  10383. return jQuery.grep( elements, function( elem, i ) {
  10384. return !!qualifier.call( elem, i, elem ) !== not;
  10385. } );
  10386. }
  10387. // Single element
  10388. if ( qualifier.nodeType ) {
  10389. return jQuery.grep( elements, function( elem ) {
  10390. return ( elem === qualifier ) !== not;
  10391. } );
  10392. }
  10393. // Arraylike of elements (jQuery, arguments, Array)
  10394. if ( typeof qualifier !== "string" ) {
  10395. return jQuery.grep( elements, function( elem ) {
  10396. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  10397. } );
  10398. }
  10399. // Filtered directly for both simple and complex selectors
  10400. return jQuery.filter( qualifier, elements, not );
  10401. }
  10402. jQuery.filter = function( expr, elems, not ) {
  10403. var elem = elems[ 0 ];
  10404. if ( not ) {
  10405. expr = ":not(" + expr + ")";
  10406. }
  10407. if ( elems.length === 1 && elem.nodeType === 1 ) {
  10408. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  10409. }
  10410. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  10411. return elem.nodeType === 1;
  10412. } ) );
  10413. };
  10414. jQuery.fn.extend( {
  10415. find: function( selector ) {
  10416. var i, ret,
  10417. len = this.length,
  10418. self = this;
  10419. if ( typeof selector !== "string" ) {
  10420. return this.pushStack( jQuery( selector ).filter( function() {
  10421. for ( i = 0; i < len; i++ ) {
  10422. if ( jQuery.contains( self[ i ], this ) ) {
  10423. return true;
  10424. }
  10425. }
  10426. } ) );
  10427. }
  10428. ret = this.pushStack( [] );
  10429. for ( i = 0; i < len; i++ ) {
  10430. jQuery.find( selector, self[ i ], ret );
  10431. }
  10432. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  10433. },
  10434. filter: function( selector ) {
  10435. return this.pushStack( winnow( this, selector || [], false ) );
  10436. },
  10437. not: function( selector ) {
  10438. return this.pushStack( winnow( this, selector || [], true ) );
  10439. },
  10440. is: function( selector ) {
  10441. return !!winnow(
  10442. this,
  10443. // If this is a positional/relative selector, check membership in the returned set
  10444. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  10445. typeof selector === "string" && rneedsContext.test( selector ) ?
  10446. jQuery( selector ) :
  10447. selector || [],
  10448. false
  10449. ).length;
  10450. }
  10451. } );
  10452. // Initialize a jQuery object
  10453. // A central reference to the root jQuery(document)
  10454. var rootjQuery,
  10455. // A simple way to check for HTML strings
  10456. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  10457. // Strict HTML recognition (#11290: must start with <)
  10458. // Shortcut simple #id case for speed
  10459. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  10460. init = jQuery.fn.init = function( selector, context, root ) {
  10461. var match, elem;
  10462. // HANDLE: $(""), $(null), $(undefined), $(false)
  10463. if ( !selector ) {
  10464. return this;
  10465. }
  10466. // Method init() accepts an alternate rootjQuery
  10467. // so migrate can support jQuery.sub (gh-2101)
  10468. root = root || rootjQuery;
  10469. // Handle HTML strings
  10470. if ( typeof selector === "string" ) {
  10471. if ( selector[ 0 ] === "<" &&
  10472. selector[ selector.length - 1 ] === ">" &&
  10473. selector.length >= 3 ) {
  10474. // Assume that strings that start and end with <> are HTML and skip the regex check
  10475. match = [ null, selector, null ];
  10476. } else {
  10477. match = rquickExpr.exec( selector );
  10478. }
  10479. // Match html or make sure no context is specified for #id
  10480. if ( match && ( match[ 1 ] || !context ) ) {
  10481. // HANDLE: $(html) -> $(array)
  10482. if ( match[ 1 ] ) {
  10483. context = context instanceof jQuery ? context[ 0 ] : context;
  10484. // Option to run scripts is true for back-compat
  10485. // Intentionally let the error be thrown if parseHTML is not present
  10486. jQuery.merge( this, jQuery.parseHTML(
  10487. match[ 1 ],
  10488. context && context.nodeType ? context.ownerDocument || context : document,
  10489. true
  10490. ) );
  10491. // HANDLE: $(html, props)
  10492. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  10493. for ( match in context ) {
  10494. // Properties of context are called as methods if possible
  10495. if ( isFunction( this[ match ] ) ) {
  10496. this[ match ]( context[ match ] );
  10497. // ...and otherwise set as attributes
  10498. } else {
  10499. this.attr( match, context[ match ] );
  10500. }
  10501. }
  10502. }
  10503. return this;
  10504. // HANDLE: $(#id)
  10505. } else {
  10506. elem = document.getElementById( match[ 2 ] );
  10507. if ( elem ) {
  10508. // Inject the element directly into the jQuery object
  10509. this[ 0 ] = elem;
  10510. this.length = 1;
  10511. }
  10512. return this;
  10513. }
  10514. // HANDLE: $(expr, $(...))
  10515. } else if ( !context || context.jquery ) {
  10516. return ( context || root ).find( selector );
  10517. // HANDLE: $(expr, context)
  10518. // (which is just equivalent to: $(context).find(expr)
  10519. } else {
  10520. return this.constructor( context ).find( selector );
  10521. }
  10522. // HANDLE: $(DOMElement)
  10523. } else if ( selector.nodeType ) {
  10524. this[ 0 ] = selector;
  10525. this.length = 1;
  10526. return this;
  10527. // HANDLE: $(function)
  10528. // Shortcut for document ready
  10529. } else if ( isFunction( selector ) ) {
  10530. return root.ready !== undefined ?
  10531. root.ready( selector ) :
  10532. // Execute immediately if ready is not present
  10533. selector( jQuery );
  10534. }
  10535. return jQuery.makeArray( selector, this );
  10536. };
  10537. // Give the init function the jQuery prototype for later instantiation
  10538. init.prototype = jQuery.fn;
  10539. // Initialize central reference
  10540. rootjQuery = jQuery( document );
  10541. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  10542. // Methods guaranteed to produce a unique set when starting from a unique set
  10543. guaranteedUnique = {
  10544. children: true,
  10545. contents: true,
  10546. next: true,
  10547. prev: true
  10548. };
  10549. jQuery.fn.extend( {
  10550. has: function( target ) {
  10551. var targets = jQuery( target, this ),
  10552. l = targets.length;
  10553. return this.filter( function() {
  10554. var i = 0;
  10555. for ( ; i < l; i++ ) {
  10556. if ( jQuery.contains( this, targets[ i ] ) ) {
  10557. return true;
  10558. }
  10559. }
  10560. } );
  10561. },
  10562. closest: function( selectors, context ) {
  10563. var cur,
  10564. i = 0,
  10565. l = this.length,
  10566. matched = [],
  10567. targets = typeof selectors !== "string" && jQuery( selectors );
  10568. // Positional selectors never match, since there's no _selection_ context
  10569. if ( !rneedsContext.test( selectors ) ) {
  10570. for ( ; i < l; i++ ) {
  10571. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  10572. // Always skip document fragments
  10573. if ( cur.nodeType < 11 && ( targets ?
  10574. targets.index( cur ) > -1 :
  10575. // Don't pass non-elements to Sizzle
  10576. cur.nodeType === 1 &&
  10577. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  10578. matched.push( cur );
  10579. break;
  10580. }
  10581. }
  10582. }
  10583. }
  10584. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  10585. },
  10586. // Determine the position of an element within the set
  10587. index: function( elem ) {
  10588. // No argument, return index in parent
  10589. if ( !elem ) {
  10590. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  10591. }
  10592. // Index in selector
  10593. if ( typeof elem === "string" ) {
  10594. return indexOf.call( jQuery( elem ), this[ 0 ] );
  10595. }
  10596. // Locate the position of the desired element
  10597. return indexOf.call( this,
  10598. // If it receives a jQuery object, the first element is used
  10599. elem.jquery ? elem[ 0 ] : elem
  10600. );
  10601. },
  10602. add: function( selector, context ) {
  10603. return this.pushStack(
  10604. jQuery.uniqueSort(
  10605. jQuery.merge( this.get(), jQuery( selector, context ) )
  10606. )
  10607. );
  10608. },
  10609. addBack: function( selector ) {
  10610. return this.add( selector == null ?
  10611. this.prevObject : this.prevObject.filter( selector )
  10612. );
  10613. }
  10614. } );
  10615. function sibling( cur, dir ) {
  10616. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  10617. return cur;
  10618. }
  10619. jQuery.each( {
  10620. parent: function( elem ) {
  10621. var parent = elem.parentNode;
  10622. return parent && parent.nodeType !== 11 ? parent : null;
  10623. },
  10624. parents: function( elem ) {
  10625. return dir( elem, "parentNode" );
  10626. },
  10627. parentsUntil: function( elem, i, until ) {
  10628. return dir( elem, "parentNode", until );
  10629. },
  10630. next: function( elem ) {
  10631. return sibling( elem, "nextSibling" );
  10632. },
  10633. prev: function( elem ) {
  10634. return sibling( elem, "previousSibling" );
  10635. },
  10636. nextAll: function( elem ) {
  10637. return dir( elem, "nextSibling" );
  10638. },
  10639. prevAll: function( elem ) {
  10640. return dir( elem, "previousSibling" );
  10641. },
  10642. nextUntil: function( elem, i, until ) {
  10643. return dir( elem, "nextSibling", until );
  10644. },
  10645. prevUntil: function( elem, i, until ) {
  10646. return dir( elem, "previousSibling", until );
  10647. },
  10648. siblings: function( elem ) {
  10649. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  10650. },
  10651. children: function( elem ) {
  10652. return siblings( elem.firstChild );
  10653. },
  10654. contents: function( elem ) {
  10655. if ( typeof elem.contentDocument !== "undefined" ) {
  10656. return elem.contentDocument;
  10657. }
  10658. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  10659. // Treat the template element as a regular one in browsers that
  10660. // don't support it.
  10661. if ( nodeName( elem, "template" ) ) {
  10662. elem = elem.content || elem;
  10663. }
  10664. return jQuery.merge( [], elem.childNodes );
  10665. }
  10666. }, function( name, fn ) {
  10667. jQuery.fn[ name ] = function( until, selector ) {
  10668. var matched = jQuery.map( this, fn, until );
  10669. if ( name.slice( -5 ) !== "Until" ) {
  10670. selector = until;
  10671. }
  10672. if ( selector && typeof selector === "string" ) {
  10673. matched = jQuery.filter( selector, matched );
  10674. }
  10675. if ( this.length > 1 ) {
  10676. // Remove duplicates
  10677. if ( !guaranteedUnique[ name ] ) {
  10678. jQuery.uniqueSort( matched );
  10679. }
  10680. // Reverse order for parents* and prev-derivatives
  10681. if ( rparentsprev.test( name ) ) {
  10682. matched.reverse();
  10683. }
  10684. }
  10685. return this.pushStack( matched );
  10686. };
  10687. } );
  10688. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  10689. // Convert String-formatted options into Object-formatted ones
  10690. function createOptions( options ) {
  10691. var object = {};
  10692. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  10693. object[ flag ] = true;
  10694. } );
  10695. return object;
  10696. }
  10697. /*
  10698. * Create a callback list using the following parameters:
  10699. *
  10700. * options: an optional list of space-separated options that will change how
  10701. * the callback list behaves or a more traditional option object
  10702. *
  10703. * By default a callback list will act like an event callback list and can be
  10704. * "fired" multiple times.
  10705. *
  10706. * Possible options:
  10707. *
  10708. * once: will ensure the callback list can only be fired once (like a Deferred)
  10709. *
  10710. * memory: will keep track of previous values and will call any callback added
  10711. * after the list has been fired right away with the latest "memorized"
  10712. * values (like a Deferred)
  10713. *
  10714. * unique: will ensure a callback can only be added once (no duplicate in the list)
  10715. *
  10716. * stopOnFalse: interrupt callings when a callback returns false
  10717. *
  10718. */
  10719. jQuery.Callbacks = function( options ) {
  10720. // Convert options from String-formatted to Object-formatted if needed
  10721. // (we check in cache first)
  10722. options = typeof options === "string" ?
  10723. createOptions( options ) :
  10724. jQuery.extend( {}, options );
  10725. var // Flag to know if list is currently firing
  10726. firing,
  10727. // Last fire value for non-forgettable lists
  10728. memory,
  10729. // Flag to know if list was already fired
  10730. fired,
  10731. // Flag to prevent firing
  10732. locked,
  10733. // Actual callback list
  10734. list = [],
  10735. // Queue of execution data for repeatable lists
  10736. queue = [],
  10737. // Index of currently firing callback (modified by add/remove as needed)
  10738. firingIndex = -1,
  10739. // Fire callbacks
  10740. fire = function() {
  10741. // Enforce single-firing
  10742. locked = locked || options.once;
  10743. // Execute callbacks for all pending executions,
  10744. // respecting firingIndex overrides and runtime changes
  10745. fired = firing = true;
  10746. for ( ; queue.length; firingIndex = -1 ) {
  10747. memory = queue.shift();
  10748. while ( ++firingIndex < list.length ) {
  10749. // Run callback and check for early termination
  10750. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  10751. options.stopOnFalse ) {
  10752. // Jump to end and forget the data so .add doesn't re-fire
  10753. firingIndex = list.length;
  10754. memory = false;
  10755. }
  10756. }
  10757. }
  10758. // Forget the data if we're done with it
  10759. if ( !options.memory ) {
  10760. memory = false;
  10761. }
  10762. firing = false;
  10763. // Clean up if we're done firing for good
  10764. if ( locked ) {
  10765. // Keep an empty list if we have data for future add calls
  10766. if ( memory ) {
  10767. list = [];
  10768. // Otherwise, this object is spent
  10769. } else {
  10770. list = "";
  10771. }
  10772. }
  10773. },
  10774. // Actual Callbacks object
  10775. self = {
  10776. // Add a callback or a collection of callbacks to the list
  10777. add: function() {
  10778. if ( list ) {
  10779. // If we have memory from a past run, we should fire after adding
  10780. if ( memory && !firing ) {
  10781. firingIndex = list.length - 1;
  10782. queue.push( memory );
  10783. }
  10784. ( function add( args ) {
  10785. jQuery.each( args, function( _, arg ) {
  10786. if ( isFunction( arg ) ) {
  10787. if ( !options.unique || !self.has( arg ) ) {
  10788. list.push( arg );
  10789. }
  10790. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  10791. // Inspect recursively
  10792. add( arg );
  10793. }
  10794. } );
  10795. } )( arguments );
  10796. if ( memory && !firing ) {
  10797. fire();
  10798. }
  10799. }
  10800. return this;
  10801. },
  10802. // Remove a callback from the list
  10803. remove: function() {
  10804. jQuery.each( arguments, function( _, arg ) {
  10805. var index;
  10806. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  10807. list.splice( index, 1 );
  10808. // Handle firing indexes
  10809. if ( index <= firingIndex ) {
  10810. firingIndex--;
  10811. }
  10812. }
  10813. } );
  10814. return this;
  10815. },
  10816. // Check if a given callback is in the list.
  10817. // If no argument is given, return whether or not list has callbacks attached.
  10818. has: function( fn ) {
  10819. return fn ?
  10820. jQuery.inArray( fn, list ) > -1 :
  10821. list.length > 0;
  10822. },
  10823. // Remove all callbacks from the list
  10824. empty: function() {
  10825. if ( list ) {
  10826. list = [];
  10827. }
  10828. return this;
  10829. },
  10830. // Disable .fire and .add
  10831. // Abort any current/pending executions
  10832. // Clear all callbacks and values
  10833. disable: function() {
  10834. locked = queue = [];
  10835. list = memory = "";
  10836. return this;
  10837. },
  10838. disabled: function() {
  10839. return !list;
  10840. },
  10841. // Disable .fire
  10842. // Also disable .add unless we have memory (since it would have no effect)
  10843. // Abort any pending executions
  10844. lock: function() {
  10845. locked = queue = [];
  10846. if ( !memory && !firing ) {
  10847. list = memory = "";
  10848. }
  10849. return this;
  10850. },
  10851. locked: function() {
  10852. return !!locked;
  10853. },
  10854. // Call all callbacks with the given context and arguments
  10855. fireWith: function( context, args ) {
  10856. if ( !locked ) {
  10857. args = args || [];
  10858. args = [ context, args.slice ? args.slice() : args ];
  10859. queue.push( args );
  10860. if ( !firing ) {
  10861. fire();
  10862. }
  10863. }
  10864. return this;
  10865. },
  10866. // Call all the callbacks with the given arguments
  10867. fire: function() {
  10868. self.fireWith( this, arguments );
  10869. return this;
  10870. },
  10871. // To know if the callbacks have already been called at least once
  10872. fired: function() {
  10873. return !!fired;
  10874. }
  10875. };
  10876. return self;
  10877. };
  10878. function Identity( v ) {
  10879. return v;
  10880. }
  10881. function Thrower( ex ) {
  10882. throw ex;
  10883. }
  10884. function adoptValue( value, resolve, reject, noValue ) {
  10885. var method;
  10886. try {
  10887. // Check for promise aspect first to privilege synchronous behavior
  10888. if ( value && isFunction( ( method = value.promise ) ) ) {
  10889. method.call( value ).done( resolve ).fail( reject );
  10890. // Other thenables
  10891. } else if ( value && isFunction( ( method = value.then ) ) ) {
  10892. method.call( value, resolve, reject );
  10893. // Other non-thenables
  10894. } else {
  10895. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  10896. // * false: [ value ].slice( 0 ) => resolve( value )
  10897. // * true: [ value ].slice( 1 ) => resolve()
  10898. resolve.apply( undefined, [ value ].slice( noValue ) );
  10899. }
  10900. // For Promises/A+, convert exceptions into rejections
  10901. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  10902. // Deferred#then to conditionally suppress rejection.
  10903. } catch ( value ) {
  10904. // Support: Android 4.0 only
  10905. // Strict mode functions invoked without .call/.apply get global-object context
  10906. reject.apply( undefined, [ value ] );
  10907. }
  10908. }
  10909. jQuery.extend( {
  10910. Deferred: function( func ) {
  10911. var tuples = [
  10912. // action, add listener, callbacks,
  10913. // ... .then handlers, argument index, [final state]
  10914. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  10915. jQuery.Callbacks( "memory" ), 2 ],
  10916. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  10917. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  10918. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  10919. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  10920. ],
  10921. state = "pending",
  10922. promise = {
  10923. state: function() {
  10924. return state;
  10925. },
  10926. always: function() {
  10927. deferred.done( arguments ).fail( arguments );
  10928. return this;
  10929. },
  10930. "catch": function( fn ) {
  10931. return promise.then( null, fn );
  10932. },
  10933. // Keep pipe for back-compat
  10934. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  10935. var fns = arguments;
  10936. return jQuery.Deferred( function( newDefer ) {
  10937. jQuery.each( tuples, function( i, tuple ) {
  10938. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  10939. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  10940. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  10941. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  10942. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  10943. deferred[ tuple[ 1 ] ]( function() {
  10944. var returned = fn && fn.apply( this, arguments );
  10945. if ( returned && isFunction( returned.promise ) ) {
  10946. returned.promise()
  10947. .progress( newDefer.notify )
  10948. .done( newDefer.resolve )
  10949. .fail( newDefer.reject );
  10950. } else {
  10951. newDefer[ tuple[ 0 ] + "With" ](
  10952. this,
  10953. fn ? [ returned ] : arguments
  10954. );
  10955. }
  10956. } );
  10957. } );
  10958. fns = null;
  10959. } ).promise();
  10960. },
  10961. then: function( onFulfilled, onRejected, onProgress ) {
  10962. var maxDepth = 0;
  10963. function resolve( depth, deferred, handler, special ) {
  10964. return function() {
  10965. var that = this,
  10966. args = arguments,
  10967. mightThrow = function() {
  10968. var returned, then;
  10969. // Support: Promises/A+ section 2.3.3.3.3
  10970. // https://promisesaplus.com/#point-59
  10971. // Ignore double-resolution attempts
  10972. if ( depth < maxDepth ) {
  10973. return;
  10974. }
  10975. returned = handler.apply( that, args );
  10976. // Support: Promises/A+ section 2.3.1
  10977. // https://promisesaplus.com/#point-48
  10978. if ( returned === deferred.promise() ) {
  10979. throw new TypeError( "Thenable self-resolution" );
  10980. }
  10981. // Support: Promises/A+ sections 2.3.3.1, 3.5
  10982. // https://promisesaplus.com/#point-54
  10983. // https://promisesaplus.com/#point-75
  10984. // Retrieve `then` only once
  10985. then = returned &&
  10986. // Support: Promises/A+ section 2.3.4
  10987. // https://promisesaplus.com/#point-64
  10988. // Only check objects and functions for thenability
  10989. ( typeof returned === "object" ||
  10990. typeof returned === "function" ) &&
  10991. returned.then;
  10992. // Handle a returned thenable
  10993. if ( isFunction( then ) ) {
  10994. // Special processors (notify) just wait for resolution
  10995. if ( special ) {
  10996. then.call(
  10997. returned,
  10998. resolve( maxDepth, deferred, Identity, special ),
  10999. resolve( maxDepth, deferred, Thrower, special )
  11000. );
  11001. // Normal processors (resolve) also hook into progress
  11002. } else {
  11003. // ...and disregard older resolution values
  11004. maxDepth++;
  11005. then.call(
  11006. returned,
  11007. resolve( maxDepth, deferred, Identity, special ),
  11008. resolve( maxDepth, deferred, Thrower, special ),
  11009. resolve( maxDepth, deferred, Identity,
  11010. deferred.notifyWith )
  11011. );
  11012. }
  11013. // Handle all other returned values
  11014. } else {
  11015. // Only substitute handlers pass on context
  11016. // and multiple values (non-spec behavior)
  11017. if ( handler !== Identity ) {
  11018. that = undefined;
  11019. args = [ returned ];
  11020. }
  11021. // Process the value(s)
  11022. // Default process is resolve
  11023. ( special || deferred.resolveWith )( that, args );
  11024. }
  11025. },
  11026. // Only normal processors (resolve) catch and reject exceptions
  11027. process = special ?
  11028. mightThrow :
  11029. function() {
  11030. try {
  11031. mightThrow();
  11032. } catch ( e ) {
  11033. if ( jQuery.Deferred.exceptionHook ) {
  11034. jQuery.Deferred.exceptionHook( e,
  11035. process.stackTrace );
  11036. }
  11037. // Support: Promises/A+ section 2.3.3.3.4.1
  11038. // https://promisesaplus.com/#point-61
  11039. // Ignore post-resolution exceptions
  11040. if ( depth + 1 >= maxDepth ) {
  11041. // Only substitute handlers pass on context
  11042. // and multiple values (non-spec behavior)
  11043. if ( handler !== Thrower ) {
  11044. that = undefined;
  11045. args = [ e ];
  11046. }
  11047. deferred.rejectWith( that, args );
  11048. }
  11049. }
  11050. };
  11051. // Support: Promises/A+ section 2.3.3.3.1
  11052. // https://promisesaplus.com/#point-57
  11053. // Re-resolve promises immediately to dodge false rejection from
  11054. // subsequent errors
  11055. if ( depth ) {
  11056. process();
  11057. } else {
  11058. // Call an optional hook to record the stack, in case of exception
  11059. // since it's otherwise lost when execution goes async
  11060. if ( jQuery.Deferred.getStackHook ) {
  11061. process.stackTrace = jQuery.Deferred.getStackHook();
  11062. }
  11063. window.setTimeout( process );
  11064. }
  11065. };
  11066. }
  11067. return jQuery.Deferred( function( newDefer ) {
  11068. // progress_handlers.add( ... )
  11069. tuples[ 0 ][ 3 ].add(
  11070. resolve(
  11071. 0,
  11072. newDefer,
  11073. isFunction( onProgress ) ?
  11074. onProgress :
  11075. Identity,
  11076. newDefer.notifyWith
  11077. )
  11078. );
  11079. // fulfilled_handlers.add( ... )
  11080. tuples[ 1 ][ 3 ].add(
  11081. resolve(
  11082. 0,
  11083. newDefer,
  11084. isFunction( onFulfilled ) ?
  11085. onFulfilled :
  11086. Identity
  11087. )
  11088. );
  11089. // rejected_handlers.add( ... )
  11090. tuples[ 2 ][ 3 ].add(
  11091. resolve(
  11092. 0,
  11093. newDefer,
  11094. isFunction( onRejected ) ?
  11095. onRejected :
  11096. Thrower
  11097. )
  11098. );
  11099. } ).promise();
  11100. },
  11101. // Get a promise for this deferred
  11102. // If obj is provided, the promise aspect is added to the object
  11103. promise: function( obj ) {
  11104. return obj != null ? jQuery.extend( obj, promise ) : promise;
  11105. }
  11106. },
  11107. deferred = {};
  11108. // Add list-specific methods
  11109. jQuery.each( tuples, function( i, tuple ) {
  11110. var list = tuple[ 2 ],
  11111. stateString = tuple[ 5 ];
  11112. // promise.progress = list.add
  11113. // promise.done = list.add
  11114. // promise.fail = list.add
  11115. promise[ tuple[ 1 ] ] = list.add;
  11116. // Handle state
  11117. if ( stateString ) {
  11118. list.add(
  11119. function() {
  11120. // state = "resolved" (i.e., fulfilled)
  11121. // state = "rejected"
  11122. state = stateString;
  11123. },
  11124. // rejected_callbacks.disable
  11125. // fulfilled_callbacks.disable
  11126. tuples[ 3 - i ][ 2 ].disable,
  11127. // rejected_handlers.disable
  11128. // fulfilled_handlers.disable
  11129. tuples[ 3 - i ][ 3 ].disable,
  11130. // progress_callbacks.lock
  11131. tuples[ 0 ][ 2 ].lock,
  11132. // progress_handlers.lock
  11133. tuples[ 0 ][ 3 ].lock
  11134. );
  11135. }
  11136. // progress_handlers.fire
  11137. // fulfilled_handlers.fire
  11138. // rejected_handlers.fire
  11139. list.add( tuple[ 3 ].fire );
  11140. // deferred.notify = function() { deferred.notifyWith(...) }
  11141. // deferred.resolve = function() { deferred.resolveWith(...) }
  11142. // deferred.reject = function() { deferred.rejectWith(...) }
  11143. deferred[ tuple[ 0 ] ] = function() {
  11144. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  11145. return this;
  11146. };
  11147. // deferred.notifyWith = list.fireWith
  11148. // deferred.resolveWith = list.fireWith
  11149. // deferred.rejectWith = list.fireWith
  11150. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  11151. } );
  11152. // Make the deferred a promise
  11153. promise.promise( deferred );
  11154. // Call given func if any
  11155. if ( func ) {
  11156. func.call( deferred, deferred );
  11157. }
  11158. // All done!
  11159. return deferred;
  11160. },
  11161. // Deferred helper
  11162. when: function( singleValue ) {
  11163. var
  11164. // count of uncompleted subordinates
  11165. remaining = arguments.length,
  11166. // count of unprocessed arguments
  11167. i = remaining,
  11168. // subordinate fulfillment data
  11169. resolveContexts = Array( i ),
  11170. resolveValues = slice.call( arguments ),
  11171. // the master Deferred
  11172. master = jQuery.Deferred(),
  11173. // subordinate callback factory
  11174. updateFunc = function( i ) {
  11175. return function( value ) {
  11176. resolveContexts[ i ] = this;
  11177. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  11178. if ( !( --remaining ) ) {
  11179. master.resolveWith( resolveContexts, resolveValues );
  11180. }
  11181. };
  11182. };
  11183. // Single- and empty arguments are adopted like Promise.resolve
  11184. if ( remaining <= 1 ) {
  11185. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  11186. !remaining );
  11187. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  11188. if ( master.state() === "pending" ||
  11189. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  11190. return master.then();
  11191. }
  11192. }
  11193. // Multiple arguments are aggregated like Promise.all array elements
  11194. while ( i-- ) {
  11195. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  11196. }
  11197. return master.promise();
  11198. }
  11199. } );
  11200. // These usually indicate a programmer mistake during development,
  11201. // warn about them ASAP rather than swallowing them by default.
  11202. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  11203. jQuery.Deferred.exceptionHook = function( error, stack ) {
  11204. // Support: IE 8 - 9 only
  11205. // Console exists when dev tools are open, which can happen at any time
  11206. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  11207. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  11208. }
  11209. };
  11210. jQuery.readyException = function( error ) {
  11211. window.setTimeout( function() {
  11212. throw error;
  11213. } );
  11214. };
  11215. // The deferred used on DOM ready
  11216. var readyList = jQuery.Deferred();
  11217. jQuery.fn.ready = function( fn ) {
  11218. readyList
  11219. .then( fn )
  11220. // Wrap jQuery.readyException in a function so that the lookup
  11221. // happens at the time of error handling instead of callback
  11222. // registration.
  11223. .catch( function( error ) {
  11224. jQuery.readyException( error );
  11225. } );
  11226. return this;
  11227. };
  11228. jQuery.extend( {
  11229. // Is the DOM ready to be used? Set to true once it occurs.
  11230. isReady: false,
  11231. // A counter to track how many items to wait for before
  11232. // the ready event fires. See #6781
  11233. readyWait: 1,
  11234. // Handle when the DOM is ready
  11235. ready: function( wait ) {
  11236. // Abort if there are pending holds or we're already ready
  11237. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  11238. return;
  11239. }
  11240. // Remember that the DOM is ready
  11241. jQuery.isReady = true;
  11242. // If a normal DOM Ready event fired, decrement, and wait if need be
  11243. if ( wait !== true && --jQuery.readyWait > 0 ) {
  11244. return;
  11245. }
  11246. // If there are functions bound, to execute
  11247. readyList.resolveWith( document, [ jQuery ] );
  11248. }
  11249. } );
  11250. jQuery.ready.then = readyList.then;
  11251. // The ready event handler and self cleanup method
  11252. function completed() {
  11253. document.removeEventListener( "DOMContentLoaded", completed );
  11254. window.removeEventListener( "load", completed );
  11255. jQuery.ready();
  11256. }
  11257. // Catch cases where $(document).ready() is called
  11258. // after the browser event has already occurred.
  11259. // Support: IE <=9 - 10 only
  11260. // Older IE sometimes signals "interactive" too soon
  11261. if ( document.readyState === "complete" ||
  11262. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  11263. // Handle it asynchronously to allow scripts the opportunity to delay ready
  11264. window.setTimeout( jQuery.ready );
  11265. } else {
  11266. // Use the handy event callback
  11267. document.addEventListener( "DOMContentLoaded", completed );
  11268. // A fallback to window.onload, that will always work
  11269. window.addEventListener( "load", completed );
  11270. }
  11271. // Multifunctional method to get and set values of a collection
  11272. // The value/s can optionally be executed if it's a function
  11273. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  11274. var i = 0,
  11275. len = elems.length,
  11276. bulk = key == null;
  11277. // Sets many values
  11278. if ( toType( key ) === "object" ) {
  11279. chainable = true;
  11280. for ( i in key ) {
  11281. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  11282. }
  11283. // Sets one value
  11284. } else if ( value !== undefined ) {
  11285. chainable = true;
  11286. if ( !isFunction( value ) ) {
  11287. raw = true;
  11288. }
  11289. if ( bulk ) {
  11290. // Bulk operations run against the entire set
  11291. if ( raw ) {
  11292. fn.call( elems, value );
  11293. fn = null;
  11294. // ...except when executing function values
  11295. } else {
  11296. bulk = fn;
  11297. fn = function( elem, key, value ) {
  11298. return bulk.call( jQuery( elem ), value );
  11299. };
  11300. }
  11301. }
  11302. if ( fn ) {
  11303. for ( ; i < len; i++ ) {
  11304. fn(
  11305. elems[ i ], key, raw ?
  11306. value :
  11307. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  11308. );
  11309. }
  11310. }
  11311. }
  11312. if ( chainable ) {
  11313. return elems;
  11314. }
  11315. // Gets
  11316. if ( bulk ) {
  11317. return fn.call( elems );
  11318. }
  11319. return len ? fn( elems[ 0 ], key ) : emptyGet;
  11320. };
  11321. // Matches dashed string for camelizing
  11322. var rmsPrefix = /^-ms-/,
  11323. rdashAlpha = /-([a-z])/g;
  11324. // Used by camelCase as callback to replace()
  11325. function fcamelCase( all, letter ) {
  11326. return letter.toUpperCase();
  11327. }
  11328. // Convert dashed to camelCase; used by the css and data modules
  11329. // Support: IE <=9 - 11, Edge 12 - 15
  11330. // Microsoft forgot to hump their vendor prefix (#9572)
  11331. function camelCase( string ) {
  11332. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  11333. }
  11334. var acceptData = function( owner ) {
  11335. // Accepts only:
  11336. // - Node
  11337. // - Node.ELEMENT_NODE
  11338. // - Node.DOCUMENT_NODE
  11339. // - Object
  11340. // - Any
  11341. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  11342. };
  11343. function Data() {
  11344. this.expando = jQuery.expando + Data.uid++;
  11345. }
  11346. Data.uid = 1;
  11347. Data.prototype = {
  11348. cache: function( owner ) {
  11349. // Check if the owner object already has a cache
  11350. var value = owner[ this.expando ];
  11351. // If not, create one
  11352. if ( !value ) {
  11353. value = {};
  11354. // We can accept data for non-element nodes in modern browsers,
  11355. // but we should not, see #8335.
  11356. // Always return an empty object.
  11357. if ( acceptData( owner ) ) {
  11358. // If it is a node unlikely to be stringify-ed or looped over
  11359. // use plain assignment
  11360. if ( owner.nodeType ) {
  11361. owner[ this.expando ] = value;
  11362. // Otherwise secure it in a non-enumerable property
  11363. // configurable must be true to allow the property to be
  11364. // deleted when data is removed
  11365. } else {
  11366. Object.defineProperty( owner, this.expando, {
  11367. value: value,
  11368. configurable: true
  11369. } );
  11370. }
  11371. }
  11372. }
  11373. return value;
  11374. },
  11375. set: function( owner, data, value ) {
  11376. var prop,
  11377. cache = this.cache( owner );
  11378. // Handle: [ owner, key, value ] args
  11379. // Always use camelCase key (gh-2257)
  11380. if ( typeof data === "string" ) {
  11381. cache[ camelCase( data ) ] = value;
  11382. // Handle: [ owner, { properties } ] args
  11383. } else {
  11384. // Copy the properties one-by-one to the cache object
  11385. for ( prop in data ) {
  11386. cache[ camelCase( prop ) ] = data[ prop ];
  11387. }
  11388. }
  11389. return cache;
  11390. },
  11391. get: function( owner, key ) {
  11392. return key === undefined ?
  11393. this.cache( owner ) :
  11394. // Always use camelCase key (gh-2257)
  11395. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  11396. },
  11397. access: function( owner, key, value ) {
  11398. // In cases where either:
  11399. //
  11400. // 1. No key was specified
  11401. // 2. A string key was specified, but no value provided
  11402. //
  11403. // Take the "read" path and allow the get method to determine
  11404. // which value to return, respectively either:
  11405. //
  11406. // 1. The entire cache object
  11407. // 2. The data stored at the key
  11408. //
  11409. if ( key === undefined ||
  11410. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  11411. return this.get( owner, key );
  11412. }
  11413. // When the key is not a string, or both a key and value
  11414. // are specified, set or extend (existing objects) with either:
  11415. //
  11416. // 1. An object of properties
  11417. // 2. A key and value
  11418. //
  11419. this.set( owner, key, value );
  11420. // Since the "set" path can have two possible entry points
  11421. // return the expected data based on which path was taken[*]
  11422. return value !== undefined ? value : key;
  11423. },
  11424. remove: function( owner, key ) {
  11425. var i,
  11426. cache = owner[ this.expando ];
  11427. if ( cache === undefined ) {
  11428. return;
  11429. }
  11430. if ( key !== undefined ) {
  11431. // Support array or space separated string of keys
  11432. if ( Array.isArray( key ) ) {
  11433. // If key is an array of keys...
  11434. // We always set camelCase keys, so remove that.
  11435. key = key.map( camelCase );
  11436. } else {
  11437. key = camelCase( key );
  11438. // If a key with the spaces exists, use it.
  11439. // Otherwise, create an array by matching non-whitespace
  11440. key = key in cache ?
  11441. [ key ] :
  11442. ( key.match( rnothtmlwhite ) || [] );
  11443. }
  11444. i = key.length;
  11445. while ( i-- ) {
  11446. delete cache[ key[ i ] ];
  11447. }
  11448. }
  11449. // Remove the expando if there's no more data
  11450. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  11451. // Support: Chrome <=35 - 45
  11452. // Webkit & Blink performance suffers when deleting properties
  11453. // from DOM nodes, so set to undefined instead
  11454. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  11455. if ( owner.nodeType ) {
  11456. owner[ this.expando ] = undefined;
  11457. } else {
  11458. delete owner[ this.expando ];
  11459. }
  11460. }
  11461. },
  11462. hasData: function( owner ) {
  11463. var cache = owner[ this.expando ];
  11464. return cache !== undefined && !jQuery.isEmptyObject( cache );
  11465. }
  11466. };
  11467. var dataPriv = new Data();
  11468. var dataUser = new Data();
  11469. // Implementation Summary
  11470. //
  11471. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  11472. // 2. Improve the module's maintainability by reducing the storage
  11473. // paths to a single mechanism.
  11474. // 3. Use the same single mechanism to support "private" and "user" data.
  11475. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  11476. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  11477. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  11478. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  11479. rmultiDash = /[A-Z]/g;
  11480. function getData( data ) {
  11481. if ( data === "true" ) {
  11482. return true;
  11483. }
  11484. if ( data === "false" ) {
  11485. return false;
  11486. }
  11487. if ( data === "null" ) {
  11488. return null;
  11489. }
  11490. // Only convert to a number if it doesn't change the string
  11491. if ( data === +data + "" ) {
  11492. return +data;
  11493. }
  11494. if ( rbrace.test( data ) ) {
  11495. return JSON.parse( data );
  11496. }
  11497. return data;
  11498. }
  11499. function dataAttr( elem, key, data ) {
  11500. var name;
  11501. // If nothing was found internally, try to fetch any
  11502. // data from the HTML5 data-* attribute
  11503. if ( data === undefined && elem.nodeType === 1 ) {
  11504. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  11505. data = elem.getAttribute( name );
  11506. if ( typeof data === "string" ) {
  11507. try {
  11508. data = getData( data );
  11509. } catch ( e ) {}
  11510. // Make sure we set the data so it isn't changed later
  11511. dataUser.set( elem, key, data );
  11512. } else {
  11513. data = undefined;
  11514. }
  11515. }
  11516. return data;
  11517. }
  11518. jQuery.extend( {
  11519. hasData: function( elem ) {
  11520. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  11521. },
  11522. data: function( elem, name, data ) {
  11523. return dataUser.access( elem, name, data );
  11524. },
  11525. removeData: function( elem, name ) {
  11526. dataUser.remove( elem, name );
  11527. },
  11528. // TODO: Now that all calls to _data and _removeData have been replaced
  11529. // with direct calls to dataPriv methods, these can be deprecated.
  11530. _data: function( elem, name, data ) {
  11531. return dataPriv.access( elem, name, data );
  11532. },
  11533. _removeData: function( elem, name ) {
  11534. dataPriv.remove( elem, name );
  11535. }
  11536. } );
  11537. jQuery.fn.extend( {
  11538. data: function( key, value ) {
  11539. var i, name, data,
  11540. elem = this[ 0 ],
  11541. attrs = elem && elem.attributes;
  11542. // Gets all values
  11543. if ( key === undefined ) {
  11544. if ( this.length ) {
  11545. data = dataUser.get( elem );
  11546. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  11547. i = attrs.length;
  11548. while ( i-- ) {
  11549. // Support: IE 11 only
  11550. // The attrs elements can be null (#14894)
  11551. if ( attrs[ i ] ) {
  11552. name = attrs[ i ].name;
  11553. if ( name.indexOf( "data-" ) === 0 ) {
  11554. name = camelCase( name.slice( 5 ) );
  11555. dataAttr( elem, name, data[ name ] );
  11556. }
  11557. }
  11558. }
  11559. dataPriv.set( elem, "hasDataAttrs", true );
  11560. }
  11561. }
  11562. return data;
  11563. }
  11564. // Sets multiple values
  11565. if ( typeof key === "object" ) {
  11566. return this.each( function() {
  11567. dataUser.set( this, key );
  11568. } );
  11569. }
  11570. return access( this, function( value ) {
  11571. var data;
  11572. // The calling jQuery object (element matches) is not empty
  11573. // (and therefore has an element appears at this[ 0 ]) and the
  11574. // `value` parameter was not undefined. An empty jQuery object
  11575. // will result in `undefined` for elem = this[ 0 ] which will
  11576. // throw an exception if an attempt to read a data cache is made.
  11577. if ( elem && value === undefined ) {
  11578. // Attempt to get data from the cache
  11579. // The key will always be camelCased in Data
  11580. data = dataUser.get( elem, key );
  11581. if ( data !== undefined ) {
  11582. return data;
  11583. }
  11584. // Attempt to "discover" the data in
  11585. // HTML5 custom data-* attrs
  11586. data = dataAttr( elem, key );
  11587. if ( data !== undefined ) {
  11588. return data;
  11589. }
  11590. // We tried really hard, but the data doesn't exist.
  11591. return;
  11592. }
  11593. // Set the data...
  11594. this.each( function() {
  11595. // We always store the camelCased key
  11596. dataUser.set( this, key, value );
  11597. } );
  11598. }, null, value, arguments.length > 1, null, true );
  11599. },
  11600. removeData: function( key ) {
  11601. return this.each( function() {
  11602. dataUser.remove( this, key );
  11603. } );
  11604. }
  11605. } );
  11606. jQuery.extend( {
  11607. queue: function( elem, type, data ) {
  11608. var queue;
  11609. if ( elem ) {
  11610. type = ( type || "fx" ) + "queue";
  11611. queue = dataPriv.get( elem, type );
  11612. // Speed up dequeue by getting out quickly if this is just a lookup
  11613. if ( data ) {
  11614. if ( !queue || Array.isArray( data ) ) {
  11615. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  11616. } else {
  11617. queue.push( data );
  11618. }
  11619. }
  11620. return queue || [];
  11621. }
  11622. },
  11623. dequeue: function( elem, type ) {
  11624. type = type || "fx";
  11625. var queue = jQuery.queue( elem, type ),
  11626. startLength = queue.length,
  11627. fn = queue.shift(),
  11628. hooks = jQuery._queueHooks( elem, type ),
  11629. next = function() {
  11630. jQuery.dequeue( elem, type );
  11631. };
  11632. // If the fx queue is dequeued, always remove the progress sentinel
  11633. if ( fn === "inprogress" ) {
  11634. fn = queue.shift();
  11635. startLength--;
  11636. }
  11637. if ( fn ) {
  11638. // Add a progress sentinel to prevent the fx queue from being
  11639. // automatically dequeued
  11640. if ( type === "fx" ) {
  11641. queue.unshift( "inprogress" );
  11642. }
  11643. // Clear up the last queue stop function
  11644. delete hooks.stop;
  11645. fn.call( elem, next, hooks );
  11646. }
  11647. if ( !startLength && hooks ) {
  11648. hooks.empty.fire();
  11649. }
  11650. },
  11651. // Not public - generate a queueHooks object, or return the current one
  11652. _queueHooks: function( elem, type ) {
  11653. var key = type + "queueHooks";
  11654. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  11655. empty: jQuery.Callbacks( "once memory" ).add( function() {
  11656. dataPriv.remove( elem, [ type + "queue", key ] );
  11657. } )
  11658. } );
  11659. }
  11660. } );
  11661. jQuery.fn.extend( {
  11662. queue: function( type, data ) {
  11663. var setter = 2;
  11664. if ( typeof type !== "string" ) {
  11665. data = type;
  11666. type = "fx";
  11667. setter--;
  11668. }
  11669. if ( arguments.length < setter ) {
  11670. return jQuery.queue( this[ 0 ], type );
  11671. }
  11672. return data === undefined ?
  11673. this :
  11674. this.each( function() {
  11675. var queue = jQuery.queue( this, type, data );
  11676. // Ensure a hooks for this queue
  11677. jQuery._queueHooks( this, type );
  11678. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  11679. jQuery.dequeue( this, type );
  11680. }
  11681. } );
  11682. },
  11683. dequeue: function( type ) {
  11684. return this.each( function() {
  11685. jQuery.dequeue( this, type );
  11686. } );
  11687. },
  11688. clearQueue: function( type ) {
  11689. return this.queue( type || "fx", [] );
  11690. },
  11691. // Get a promise resolved when queues of a certain type
  11692. // are emptied (fx is the type by default)
  11693. promise: function( type, obj ) {
  11694. var tmp,
  11695. count = 1,
  11696. defer = jQuery.Deferred(),
  11697. elements = this,
  11698. i = this.length,
  11699. resolve = function() {
  11700. if ( !( --count ) ) {
  11701. defer.resolveWith( elements, [ elements ] );
  11702. }
  11703. };
  11704. if ( typeof type !== "string" ) {
  11705. obj = type;
  11706. type = undefined;
  11707. }
  11708. type = type || "fx";
  11709. while ( i-- ) {
  11710. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  11711. if ( tmp && tmp.empty ) {
  11712. count++;
  11713. tmp.empty.add( resolve );
  11714. }
  11715. }
  11716. resolve();
  11717. return defer.promise( obj );
  11718. }
  11719. } );
  11720. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  11721. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  11722. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  11723. var documentElement = document.documentElement;
  11724. var isAttached = function( elem ) {
  11725. return jQuery.contains( elem.ownerDocument, elem );
  11726. },
  11727. composed = { composed: true };
  11728. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  11729. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  11730. // Support: iOS 10.0-10.2 only
  11731. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  11732. // leading to errors. We need to check for `getRootNode`.
  11733. if ( documentElement.getRootNode ) {
  11734. isAttached = function( elem ) {
  11735. return jQuery.contains( elem.ownerDocument, elem ) ||
  11736. elem.getRootNode( composed ) === elem.ownerDocument;
  11737. };
  11738. }
  11739. var isHiddenWithinTree = function( elem, el ) {
  11740. // isHiddenWithinTree might be called from jQuery#filter function;
  11741. // in that case, element will be second argument
  11742. elem = el || elem;
  11743. // Inline style trumps all
  11744. return elem.style.display === "none" ||
  11745. elem.style.display === "" &&
  11746. // Otherwise, check computed style
  11747. // Support: Firefox <=43 - 45
  11748. // Disconnected elements can have computed display: none, so first confirm that elem is
  11749. // in the document.
  11750. isAttached( elem ) &&
  11751. jQuery.css( elem, "display" ) === "none";
  11752. };
  11753. var swap = function( elem, options, callback, args ) {
  11754. var ret, name,
  11755. old = {};
  11756. // Remember the old values, and insert the new ones
  11757. for ( name in options ) {
  11758. old[ name ] = elem.style[ name ];
  11759. elem.style[ name ] = options[ name ];
  11760. }
  11761. ret = callback.apply( elem, args || [] );
  11762. // Revert the old values
  11763. for ( name in options ) {
  11764. elem.style[ name ] = old[ name ];
  11765. }
  11766. return ret;
  11767. };
  11768. function adjustCSS( elem, prop, valueParts, tween ) {
  11769. var adjusted, scale,
  11770. maxIterations = 20,
  11771. currentValue = tween ?
  11772. function() {
  11773. return tween.cur();
  11774. } :
  11775. function() {
  11776. return jQuery.css( elem, prop, "" );
  11777. },
  11778. initial = currentValue(),
  11779. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  11780. // Starting value computation is required for potential unit mismatches
  11781. initialInUnit = elem.nodeType &&
  11782. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  11783. rcssNum.exec( jQuery.css( elem, prop ) );
  11784. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  11785. // Support: Firefox <=54
  11786. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  11787. initial = initial / 2;
  11788. // Trust units reported by jQuery.css
  11789. unit = unit || initialInUnit[ 3 ];
  11790. // Iteratively approximate from a nonzero starting point
  11791. initialInUnit = +initial || 1;
  11792. while ( maxIterations-- ) {
  11793. // Evaluate and update our best guess (doubling guesses that zero out).
  11794. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  11795. jQuery.style( elem, prop, initialInUnit + unit );
  11796. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  11797. maxIterations = 0;
  11798. }
  11799. initialInUnit = initialInUnit / scale;
  11800. }
  11801. initialInUnit = initialInUnit * 2;
  11802. jQuery.style( elem, prop, initialInUnit + unit );
  11803. // Make sure we update the tween properties later on
  11804. valueParts = valueParts || [];
  11805. }
  11806. if ( valueParts ) {
  11807. initialInUnit = +initialInUnit || +initial || 0;
  11808. // Apply relative offset (+=/-=) if specified
  11809. adjusted = valueParts[ 1 ] ?
  11810. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  11811. +valueParts[ 2 ];
  11812. if ( tween ) {
  11813. tween.unit = unit;
  11814. tween.start = initialInUnit;
  11815. tween.end = adjusted;
  11816. }
  11817. }
  11818. return adjusted;
  11819. }
  11820. var defaultDisplayMap = {};
  11821. function getDefaultDisplay( elem ) {
  11822. var temp,
  11823. doc = elem.ownerDocument,
  11824. nodeName = elem.nodeName,
  11825. display = defaultDisplayMap[ nodeName ];
  11826. if ( display ) {
  11827. return display;
  11828. }
  11829. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  11830. display = jQuery.css( temp, "display" );
  11831. temp.parentNode.removeChild( temp );
  11832. if ( display === "none" ) {
  11833. display = "block";
  11834. }
  11835. defaultDisplayMap[ nodeName ] = display;
  11836. return display;
  11837. }
  11838. function showHide( elements, show ) {
  11839. var display, elem,
  11840. values = [],
  11841. index = 0,
  11842. length = elements.length;
  11843. // Determine new display value for elements that need to change
  11844. for ( ; index < length; index++ ) {
  11845. elem = elements[ index ];
  11846. if ( !elem.style ) {
  11847. continue;
  11848. }
  11849. display = elem.style.display;
  11850. if ( show ) {
  11851. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  11852. // check is required in this first loop unless we have a nonempty display value (either
  11853. // inline or about-to-be-restored)
  11854. if ( display === "none" ) {
  11855. values[ index ] = dataPriv.get( elem, "display" ) || null;
  11856. if ( !values[ index ] ) {
  11857. elem.style.display = "";
  11858. }
  11859. }
  11860. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  11861. values[ index ] = getDefaultDisplay( elem );
  11862. }
  11863. } else {
  11864. if ( display !== "none" ) {
  11865. values[ index ] = "none";
  11866. // Remember what we're overwriting
  11867. dataPriv.set( elem, "display", display );
  11868. }
  11869. }
  11870. }
  11871. // Set the display of the elements in a second loop to avoid constant reflow
  11872. for ( index = 0; index < length; index++ ) {
  11873. if ( values[ index ] != null ) {
  11874. elements[ index ].style.display = values[ index ];
  11875. }
  11876. }
  11877. return elements;
  11878. }
  11879. jQuery.fn.extend( {
  11880. show: function() {
  11881. return showHide( this, true );
  11882. },
  11883. hide: function() {
  11884. return showHide( this );
  11885. },
  11886. toggle: function( state ) {
  11887. if ( typeof state === "boolean" ) {
  11888. return state ? this.show() : this.hide();
  11889. }
  11890. return this.each( function() {
  11891. if ( isHiddenWithinTree( this ) ) {
  11892. jQuery( this ).show();
  11893. } else {
  11894. jQuery( this ).hide();
  11895. }
  11896. } );
  11897. }
  11898. } );
  11899. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  11900. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  11901. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  11902. // We have to close these tags to support XHTML (#13200)
  11903. var wrapMap = {
  11904. // Support: IE <=9 only
  11905. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  11906. // XHTML parsers do not magically insert elements in the
  11907. // same way that tag soup parsers do. So we cannot shorten
  11908. // this by omitting <tbody> or other required elements.
  11909. thead: [ 1, "<table>", "</table>" ],
  11910. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  11911. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  11912. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  11913. _default: [ 0, "", "" ]
  11914. };
  11915. // Support: IE <=9 only
  11916. wrapMap.optgroup = wrapMap.option;
  11917. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  11918. wrapMap.th = wrapMap.td;
  11919. function getAll( context, tag ) {
  11920. // Support: IE <=9 - 11 only
  11921. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  11922. var ret;
  11923. if ( typeof context.getElementsByTagName !== "undefined" ) {
  11924. ret = context.getElementsByTagName( tag || "*" );
  11925. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  11926. ret = context.querySelectorAll( tag || "*" );
  11927. } else {
  11928. ret = [];
  11929. }
  11930. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  11931. return jQuery.merge( [ context ], ret );
  11932. }
  11933. return ret;
  11934. }
  11935. // Mark scripts as having already been evaluated
  11936. function setGlobalEval( elems, refElements ) {
  11937. var i = 0,
  11938. l = elems.length;
  11939. for ( ; i < l; i++ ) {
  11940. dataPriv.set(
  11941. elems[ i ],
  11942. "globalEval",
  11943. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  11944. );
  11945. }
  11946. }
  11947. var rhtml = /<|&#?\w+;/;
  11948. function buildFragment( elems, context, scripts, selection, ignored ) {
  11949. var elem, tmp, tag, wrap, attached, j,
  11950. fragment = context.createDocumentFragment(),
  11951. nodes = [],
  11952. i = 0,
  11953. l = elems.length;
  11954. for ( ; i < l; i++ ) {
  11955. elem = elems[ i ];
  11956. if ( elem || elem === 0 ) {
  11957. // Add nodes directly
  11958. if ( toType( elem ) === "object" ) {
  11959. // Support: Android <=4.0 only, PhantomJS 1 only
  11960. // push.apply(_, arraylike) throws on ancient WebKit
  11961. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  11962. // Convert non-html into a text node
  11963. } else if ( !rhtml.test( elem ) ) {
  11964. nodes.push( context.createTextNode( elem ) );
  11965. // Convert html into DOM nodes
  11966. } else {
  11967. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  11968. // Deserialize a standard representation
  11969. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  11970. wrap = wrapMap[ tag ] || wrapMap._default;
  11971. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  11972. // Descend through wrappers to the right content
  11973. j = wrap[ 0 ];
  11974. while ( j-- ) {
  11975. tmp = tmp.lastChild;
  11976. }
  11977. // Support: Android <=4.0 only, PhantomJS 1 only
  11978. // push.apply(_, arraylike) throws on ancient WebKit
  11979. jQuery.merge( nodes, tmp.childNodes );
  11980. // Remember the top-level container
  11981. tmp = fragment.firstChild;
  11982. // Ensure the created nodes are orphaned (#12392)
  11983. tmp.textContent = "";
  11984. }
  11985. }
  11986. }
  11987. // Remove wrapper from fragment
  11988. fragment.textContent = "";
  11989. i = 0;
  11990. while ( ( elem = nodes[ i++ ] ) ) {
  11991. // Skip elements already in the context collection (trac-4087)
  11992. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  11993. if ( ignored ) {
  11994. ignored.push( elem );
  11995. }
  11996. continue;
  11997. }
  11998. attached = isAttached( elem );
  11999. // Append to fragment
  12000. tmp = getAll( fragment.appendChild( elem ), "script" );
  12001. // Preserve script evaluation history
  12002. if ( attached ) {
  12003. setGlobalEval( tmp );
  12004. }
  12005. // Capture executables
  12006. if ( scripts ) {
  12007. j = 0;
  12008. while ( ( elem = tmp[ j++ ] ) ) {
  12009. if ( rscriptType.test( elem.type || "" ) ) {
  12010. scripts.push( elem );
  12011. }
  12012. }
  12013. }
  12014. }
  12015. return fragment;
  12016. }
  12017. ( function() {
  12018. var fragment = document.createDocumentFragment(),
  12019. div = fragment.appendChild( document.createElement( "div" ) ),
  12020. input = document.createElement( "input" );
  12021. // Support: Android 4.0 - 4.3 only
  12022. // Check state lost if the name is set (#11217)
  12023. // Support: Windows Web Apps (WWA)
  12024. // `name` and `type` must use .setAttribute for WWA (#14901)
  12025. input.setAttribute( "type", "radio" );
  12026. input.setAttribute( "checked", "checked" );
  12027. input.setAttribute( "name", "t" );
  12028. div.appendChild( input );
  12029. // Support: Android <=4.1 only
  12030. // Older WebKit doesn't clone checked state correctly in fragments
  12031. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  12032. // Support: IE <=11 only
  12033. // Make sure textarea (and checkbox) defaultValue is properly cloned
  12034. div.innerHTML = "<textarea>x</textarea>";
  12035. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  12036. } )();
  12037. var
  12038. rkeyEvent = /^key/,
  12039. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  12040. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  12041. function returnTrue() {
  12042. return true;
  12043. }
  12044. function returnFalse() {
  12045. return false;
  12046. }
  12047. // Support: IE <=9 - 11+
  12048. // focus() and blur() are asynchronous, except when they are no-op.
  12049. // So expect focus to be synchronous when the element is already active,
  12050. // and blur to be synchronous when the element is not already active.
  12051. // (focus and blur are always synchronous in other supported browsers,
  12052. // this just defines when we can count on it).
  12053. function expectSync( elem, type ) {
  12054. return ( elem === safeActiveElement() ) === ( type === "focus" );
  12055. }
  12056. // Support: IE <=9 only
  12057. // Accessing document.activeElement can throw unexpectedly
  12058. // https://bugs.jquery.com/ticket/13393
  12059. function safeActiveElement() {
  12060. try {
  12061. return document.activeElement;
  12062. } catch ( err ) { }
  12063. }
  12064. function on( elem, types, selector, data, fn, one ) {
  12065. var origFn, type;
  12066. // Types can be a map of types/handlers
  12067. if ( typeof types === "object" ) {
  12068. // ( types-Object, selector, data )
  12069. if ( typeof selector !== "string" ) {
  12070. // ( types-Object, data )
  12071. data = data || selector;
  12072. selector = undefined;
  12073. }
  12074. for ( type in types ) {
  12075. on( elem, type, selector, data, types[ type ], one );
  12076. }
  12077. return elem;
  12078. }
  12079. if ( data == null && fn == null ) {
  12080. // ( types, fn )
  12081. fn = selector;
  12082. data = selector = undefined;
  12083. } else if ( fn == null ) {
  12084. if ( typeof selector === "string" ) {
  12085. // ( types, selector, fn )
  12086. fn = data;
  12087. data = undefined;
  12088. } else {
  12089. // ( types, data, fn )
  12090. fn = data;
  12091. data = selector;
  12092. selector = undefined;
  12093. }
  12094. }
  12095. if ( fn === false ) {
  12096. fn = returnFalse;
  12097. } else if ( !fn ) {
  12098. return elem;
  12099. }
  12100. if ( one === 1 ) {
  12101. origFn = fn;
  12102. fn = function( event ) {
  12103. // Can use an empty set, since event contains the info
  12104. jQuery().off( event );
  12105. return origFn.apply( this, arguments );
  12106. };
  12107. // Use same guid so caller can remove using origFn
  12108. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  12109. }
  12110. return elem.each( function() {
  12111. jQuery.event.add( this, types, fn, data, selector );
  12112. } );
  12113. }
  12114. /*
  12115. * Helper functions for managing events -- not part of the public interface.
  12116. * Props to Dean Edwards' addEvent library for many of the ideas.
  12117. */
  12118. jQuery.event = {
  12119. global: {},
  12120. add: function( elem, types, handler, data, selector ) {
  12121. var handleObjIn, eventHandle, tmp,
  12122. events, t, handleObj,
  12123. special, handlers, type, namespaces, origType,
  12124. elemData = dataPriv.get( elem );
  12125. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  12126. if ( !elemData ) {
  12127. return;
  12128. }
  12129. // Caller can pass in an object of custom data in lieu of the handler
  12130. if ( handler.handler ) {
  12131. handleObjIn = handler;
  12132. handler = handleObjIn.handler;
  12133. selector = handleObjIn.selector;
  12134. }
  12135. // Ensure that invalid selectors throw exceptions at attach time
  12136. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  12137. if ( selector ) {
  12138. jQuery.find.matchesSelector( documentElement, selector );
  12139. }
  12140. // Make sure that the handler has a unique ID, used to find/remove it later
  12141. if ( !handler.guid ) {
  12142. handler.guid = jQuery.guid++;
  12143. }
  12144. // Init the element's event structure and main handler, if this is the first
  12145. if ( !( events = elemData.events ) ) {
  12146. events = elemData.events = {};
  12147. }
  12148. if ( !( eventHandle = elemData.handle ) ) {
  12149. eventHandle = elemData.handle = function( e ) {
  12150. // Discard the second event of a jQuery.event.trigger() and
  12151. // when an event is called after a page has unloaded
  12152. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  12153. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  12154. };
  12155. }
  12156. // Handle multiple events separated by a space
  12157. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12158. t = types.length;
  12159. while ( t-- ) {
  12160. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12161. type = origType = tmp[ 1 ];
  12162. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12163. // There *must* be a type, no attaching namespace-only handlers
  12164. if ( !type ) {
  12165. continue;
  12166. }
  12167. // If event changes its type, use the special event handlers for the changed type
  12168. special = jQuery.event.special[ type ] || {};
  12169. // If selector defined, determine special event api type, otherwise given type
  12170. type = ( selector ? special.delegateType : special.bindType ) || type;
  12171. // Update special based on newly reset type
  12172. special = jQuery.event.special[ type ] || {};
  12173. // handleObj is passed to all event handlers
  12174. handleObj = jQuery.extend( {
  12175. type: type,
  12176. origType: origType,
  12177. data: data,
  12178. handler: handler,
  12179. guid: handler.guid,
  12180. selector: selector,
  12181. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  12182. namespace: namespaces.join( "." )
  12183. }, handleObjIn );
  12184. // Init the event handler queue if we're the first
  12185. if ( !( handlers = events[ type ] ) ) {
  12186. handlers = events[ type ] = [];
  12187. handlers.delegateCount = 0;
  12188. // Only use addEventListener if the special events handler returns false
  12189. if ( !special.setup ||
  12190. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  12191. if ( elem.addEventListener ) {
  12192. elem.addEventListener( type, eventHandle );
  12193. }
  12194. }
  12195. }
  12196. if ( special.add ) {
  12197. special.add.call( elem, handleObj );
  12198. if ( !handleObj.handler.guid ) {
  12199. handleObj.handler.guid = handler.guid;
  12200. }
  12201. }
  12202. // Add to the element's handler list, delegates in front
  12203. if ( selector ) {
  12204. handlers.splice( handlers.delegateCount++, 0, handleObj );
  12205. } else {
  12206. handlers.push( handleObj );
  12207. }
  12208. // Keep track of which events have ever been used, for event optimization
  12209. jQuery.event.global[ type ] = true;
  12210. }
  12211. },
  12212. // Detach an event or set of events from an element
  12213. remove: function( elem, types, handler, selector, mappedTypes ) {
  12214. var j, origCount, tmp,
  12215. events, t, handleObj,
  12216. special, handlers, type, namespaces, origType,
  12217. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  12218. if ( !elemData || !( events = elemData.events ) ) {
  12219. return;
  12220. }
  12221. // Once for each type.namespace in types; type may be omitted
  12222. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12223. t = types.length;
  12224. while ( t-- ) {
  12225. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12226. type = origType = tmp[ 1 ];
  12227. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12228. // Unbind all events (on this namespace, if provided) for the element
  12229. if ( !type ) {
  12230. for ( type in events ) {
  12231. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  12232. }
  12233. continue;
  12234. }
  12235. special = jQuery.event.special[ type ] || {};
  12236. type = ( selector ? special.delegateType : special.bindType ) || type;
  12237. handlers = events[ type ] || [];
  12238. tmp = tmp[ 2 ] &&
  12239. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  12240. // Remove matching events
  12241. origCount = j = handlers.length;
  12242. while ( j-- ) {
  12243. handleObj = handlers[ j ];
  12244. if ( ( mappedTypes || origType === handleObj.origType ) &&
  12245. ( !handler || handler.guid === handleObj.guid ) &&
  12246. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  12247. ( !selector || selector === handleObj.selector ||
  12248. selector === "**" && handleObj.selector ) ) {
  12249. handlers.splice( j, 1 );
  12250. if ( handleObj.selector ) {
  12251. handlers.delegateCount--;
  12252. }
  12253. if ( special.remove ) {
  12254. special.remove.call( elem, handleObj );
  12255. }
  12256. }
  12257. }
  12258. // Remove generic event handler if we removed something and no more handlers exist
  12259. // (avoids potential for endless recursion during removal of special event handlers)
  12260. if ( origCount && !handlers.length ) {
  12261. if ( !special.teardown ||
  12262. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  12263. jQuery.removeEvent( elem, type, elemData.handle );
  12264. }
  12265. delete events[ type ];
  12266. }
  12267. }
  12268. // Remove data and the expando if it's no longer used
  12269. if ( jQuery.isEmptyObject( events ) ) {
  12270. dataPriv.remove( elem, "handle events" );
  12271. }
  12272. },
  12273. dispatch: function( nativeEvent ) {
  12274. // Make a writable jQuery.Event from the native event object
  12275. var event = jQuery.event.fix( nativeEvent );
  12276. var i, j, ret, matched, handleObj, handlerQueue,
  12277. args = new Array( arguments.length ),
  12278. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  12279. special = jQuery.event.special[ event.type ] || {};
  12280. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  12281. args[ 0 ] = event;
  12282. for ( i = 1; i < arguments.length; i++ ) {
  12283. args[ i ] = arguments[ i ];
  12284. }
  12285. event.delegateTarget = this;
  12286. // Call the preDispatch hook for the mapped type, and let it bail if desired
  12287. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  12288. return;
  12289. }
  12290. // Determine handlers
  12291. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  12292. // Run delegates first; they may want to stop propagation beneath us
  12293. i = 0;
  12294. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  12295. event.currentTarget = matched.elem;
  12296. j = 0;
  12297. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  12298. !event.isImmediatePropagationStopped() ) {
  12299. // If the event is namespaced, then each handler is only invoked if it is
  12300. // specially universal or its namespaces are a superset of the event's.
  12301. if ( !event.rnamespace || handleObj.namespace === false ||
  12302. event.rnamespace.test( handleObj.namespace ) ) {
  12303. event.handleObj = handleObj;
  12304. event.data = handleObj.data;
  12305. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  12306. handleObj.handler ).apply( matched.elem, args );
  12307. if ( ret !== undefined ) {
  12308. if ( ( event.result = ret ) === false ) {
  12309. event.preventDefault();
  12310. event.stopPropagation();
  12311. }
  12312. }
  12313. }
  12314. }
  12315. }
  12316. // Call the postDispatch hook for the mapped type
  12317. if ( special.postDispatch ) {
  12318. special.postDispatch.call( this, event );
  12319. }
  12320. return event.result;
  12321. },
  12322. handlers: function( event, handlers ) {
  12323. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  12324. handlerQueue = [],
  12325. delegateCount = handlers.delegateCount,
  12326. cur = event.target;
  12327. // Find delegate handlers
  12328. if ( delegateCount &&
  12329. // Support: IE <=9
  12330. // Black-hole SVG <use> instance trees (trac-13180)
  12331. cur.nodeType &&
  12332. // Support: Firefox <=42
  12333. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  12334. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  12335. // Support: IE 11 only
  12336. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  12337. !( event.type === "click" && event.button >= 1 ) ) {
  12338. for ( ; cur !== this; cur = cur.parentNode || this ) {
  12339. // Don't check non-elements (#13208)
  12340. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  12341. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  12342. matchedHandlers = [];
  12343. matchedSelectors = {};
  12344. for ( i = 0; i < delegateCount; i++ ) {
  12345. handleObj = handlers[ i ];
  12346. // Don't conflict with Object.prototype properties (#13203)
  12347. sel = handleObj.selector + " ";
  12348. if ( matchedSelectors[ sel ] === undefined ) {
  12349. matchedSelectors[ sel ] = handleObj.needsContext ?
  12350. jQuery( sel, this ).index( cur ) > -1 :
  12351. jQuery.find( sel, this, null, [ cur ] ).length;
  12352. }
  12353. if ( matchedSelectors[ sel ] ) {
  12354. matchedHandlers.push( handleObj );
  12355. }
  12356. }
  12357. if ( matchedHandlers.length ) {
  12358. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  12359. }
  12360. }
  12361. }
  12362. }
  12363. // Add the remaining (directly-bound) handlers
  12364. cur = this;
  12365. if ( delegateCount < handlers.length ) {
  12366. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  12367. }
  12368. return handlerQueue;
  12369. },
  12370. addProp: function( name, hook ) {
  12371. Object.defineProperty( jQuery.Event.prototype, name, {
  12372. enumerable: true,
  12373. configurable: true,
  12374. get: isFunction( hook ) ?
  12375. function() {
  12376. if ( this.originalEvent ) {
  12377. return hook( this.originalEvent );
  12378. }
  12379. } :
  12380. function() {
  12381. if ( this.originalEvent ) {
  12382. return this.originalEvent[ name ];
  12383. }
  12384. },
  12385. set: function( value ) {
  12386. Object.defineProperty( this, name, {
  12387. enumerable: true,
  12388. configurable: true,
  12389. writable: true,
  12390. value: value
  12391. } );
  12392. }
  12393. } );
  12394. },
  12395. fix: function( originalEvent ) {
  12396. return originalEvent[ jQuery.expando ] ?
  12397. originalEvent :
  12398. new jQuery.Event( originalEvent );
  12399. },
  12400. special: {
  12401. load: {
  12402. // Prevent triggered image.load events from bubbling to window.load
  12403. noBubble: true
  12404. },
  12405. click: {
  12406. // Utilize native event to ensure correct state for checkable inputs
  12407. setup: function( data ) {
  12408. // For mutual compressibility with _default, replace `this` access with a local var.
  12409. // `|| data` is dead code meant only to preserve the variable through minification.
  12410. var el = this || data;
  12411. // Claim the first handler
  12412. if ( rcheckableType.test( el.type ) &&
  12413. el.click && nodeName( el, "input" ) ) {
  12414. // dataPriv.set( el, "click", ... )
  12415. leverageNative( el, "click", returnTrue );
  12416. }
  12417. // Return false to allow normal processing in the caller
  12418. return false;
  12419. },
  12420. trigger: function( data ) {
  12421. // For mutual compressibility with _default, replace `this` access with a local var.
  12422. // `|| data` is dead code meant only to preserve the variable through minification.
  12423. var el = this || data;
  12424. // Force setup before triggering a click
  12425. if ( rcheckableType.test( el.type ) &&
  12426. el.click && nodeName( el, "input" ) ) {
  12427. leverageNative( el, "click" );
  12428. }
  12429. // Return non-false to allow normal event-path propagation
  12430. return true;
  12431. },
  12432. // For cross-browser consistency, suppress native .click() on links
  12433. // Also prevent it if we're currently inside a leveraged native-event stack
  12434. _default: function( event ) {
  12435. var target = event.target;
  12436. return rcheckableType.test( target.type ) &&
  12437. target.click && nodeName( target, "input" ) &&
  12438. dataPriv.get( target, "click" ) ||
  12439. nodeName( target, "a" );
  12440. }
  12441. },
  12442. beforeunload: {
  12443. postDispatch: function( event ) {
  12444. // Support: Firefox 20+
  12445. // Firefox doesn't alert if the returnValue field is not set.
  12446. if ( event.result !== undefined && event.originalEvent ) {
  12447. event.originalEvent.returnValue = event.result;
  12448. }
  12449. }
  12450. }
  12451. }
  12452. };
  12453. // Ensure the presence of an event listener that handles manually-triggered
  12454. // synthetic events by interrupting progress until reinvoked in response to
  12455. // *native* events that it fires directly, ensuring that state changes have
  12456. // already occurred before other listeners are invoked.
  12457. function leverageNative( el, type, expectSync ) {
  12458. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  12459. if ( !expectSync ) {
  12460. if ( dataPriv.get( el, type ) === undefined ) {
  12461. jQuery.event.add( el, type, returnTrue );
  12462. }
  12463. return;
  12464. }
  12465. // Register the controller as a special universal handler for all event namespaces
  12466. dataPriv.set( el, type, false );
  12467. jQuery.event.add( el, type, {
  12468. namespace: false,
  12469. handler: function( event ) {
  12470. var notAsync, result,
  12471. saved = dataPriv.get( this, type );
  12472. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  12473. // Interrupt processing of the outer synthetic .trigger()ed event
  12474. // Saved data should be false in such cases, but might be a leftover capture object
  12475. // from an async native handler (gh-4350)
  12476. if ( !saved.length ) {
  12477. // Store arguments for use when handling the inner native event
  12478. // There will always be at least one argument (an event object), so this array
  12479. // will not be confused with a leftover capture object.
  12480. saved = slice.call( arguments );
  12481. dataPriv.set( this, type, saved );
  12482. // Trigger the native event and capture its result
  12483. // Support: IE <=9 - 11+
  12484. // focus() and blur() are asynchronous
  12485. notAsync = expectSync( this, type );
  12486. this[ type ]();
  12487. result = dataPriv.get( this, type );
  12488. if ( saved !== result || notAsync ) {
  12489. dataPriv.set( this, type, false );
  12490. } else {
  12491. result = {};
  12492. }
  12493. if ( saved !== result ) {
  12494. // Cancel the outer synthetic event
  12495. event.stopImmediatePropagation();
  12496. event.preventDefault();
  12497. return result.value;
  12498. }
  12499. // If this is an inner synthetic event for an event with a bubbling surrogate
  12500. // (focus or blur), assume that the surrogate already propagated from triggering the
  12501. // native event and prevent that from happening again here.
  12502. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  12503. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  12504. // less bad than duplication.
  12505. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  12506. event.stopPropagation();
  12507. }
  12508. // If this is a native event triggered above, everything is now in order
  12509. // Fire an inner synthetic event with the original arguments
  12510. } else if ( saved.length ) {
  12511. // ...and capture the result
  12512. dataPriv.set( this, type, {
  12513. value: jQuery.event.trigger(
  12514. // Support: IE <=9 - 11+
  12515. // Extend with the prototype to reset the above stopImmediatePropagation()
  12516. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  12517. saved.slice( 1 ),
  12518. this
  12519. )
  12520. } );
  12521. // Abort handling of the native event
  12522. event.stopImmediatePropagation();
  12523. }
  12524. }
  12525. } );
  12526. }
  12527. jQuery.removeEvent = function( elem, type, handle ) {
  12528. // This "if" is needed for plain objects
  12529. if ( elem.removeEventListener ) {
  12530. elem.removeEventListener( type, handle );
  12531. }
  12532. };
  12533. jQuery.Event = function( src, props ) {
  12534. // Allow instantiation without the 'new' keyword
  12535. if ( !( this instanceof jQuery.Event ) ) {
  12536. return new jQuery.Event( src, props );
  12537. }
  12538. // Event object
  12539. if ( src && src.type ) {
  12540. this.originalEvent = src;
  12541. this.type = src.type;
  12542. // Events bubbling up the document may have been marked as prevented
  12543. // by a handler lower down the tree; reflect the correct value.
  12544. this.isDefaultPrevented = src.defaultPrevented ||
  12545. src.defaultPrevented === undefined &&
  12546. // Support: Android <=2.3 only
  12547. src.returnValue === false ?
  12548. returnTrue :
  12549. returnFalse;
  12550. // Create target properties
  12551. // Support: Safari <=6 - 7 only
  12552. // Target should not be a text node (#504, #13143)
  12553. this.target = ( src.target && src.target.nodeType === 3 ) ?
  12554. src.target.parentNode :
  12555. src.target;
  12556. this.currentTarget = src.currentTarget;
  12557. this.relatedTarget = src.relatedTarget;
  12558. // Event type
  12559. } else {
  12560. this.type = src;
  12561. }
  12562. // Put explicitly provided properties onto the event object
  12563. if ( props ) {
  12564. jQuery.extend( this, props );
  12565. }
  12566. // Create a timestamp if incoming event doesn't have one
  12567. this.timeStamp = src && src.timeStamp || Date.now();
  12568. // Mark it as fixed
  12569. this[ jQuery.expando ] = true;
  12570. };
  12571. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  12572. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  12573. jQuery.Event.prototype = {
  12574. constructor: jQuery.Event,
  12575. isDefaultPrevented: returnFalse,
  12576. isPropagationStopped: returnFalse,
  12577. isImmediatePropagationStopped: returnFalse,
  12578. isSimulated: false,
  12579. preventDefault: function() {
  12580. var e = this.originalEvent;
  12581. this.isDefaultPrevented = returnTrue;
  12582. if ( e && !this.isSimulated ) {
  12583. e.preventDefault();
  12584. }
  12585. },
  12586. stopPropagation: function() {
  12587. var e = this.originalEvent;
  12588. this.isPropagationStopped = returnTrue;
  12589. if ( e && !this.isSimulated ) {
  12590. e.stopPropagation();
  12591. }
  12592. },
  12593. stopImmediatePropagation: function() {
  12594. var e = this.originalEvent;
  12595. this.isImmediatePropagationStopped = returnTrue;
  12596. if ( e && !this.isSimulated ) {
  12597. e.stopImmediatePropagation();
  12598. }
  12599. this.stopPropagation();
  12600. }
  12601. };
  12602. // Includes all common event props including KeyEvent and MouseEvent specific props
  12603. jQuery.each( {
  12604. altKey: true,
  12605. bubbles: true,
  12606. cancelable: true,
  12607. changedTouches: true,
  12608. ctrlKey: true,
  12609. detail: true,
  12610. eventPhase: true,
  12611. metaKey: true,
  12612. pageX: true,
  12613. pageY: true,
  12614. shiftKey: true,
  12615. view: true,
  12616. "char": true,
  12617. code: true,
  12618. charCode: true,
  12619. key: true,
  12620. keyCode: true,
  12621. button: true,
  12622. buttons: true,
  12623. clientX: true,
  12624. clientY: true,
  12625. offsetX: true,
  12626. offsetY: true,
  12627. pointerId: true,
  12628. pointerType: true,
  12629. screenX: true,
  12630. screenY: true,
  12631. targetTouches: true,
  12632. toElement: true,
  12633. touches: true,
  12634. which: function( event ) {
  12635. var button = event.button;
  12636. // Add which for key events
  12637. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  12638. return event.charCode != null ? event.charCode : event.keyCode;
  12639. }
  12640. // Add which for click: 1 === left; 2 === middle; 3 === right
  12641. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  12642. if ( button & 1 ) {
  12643. return 1;
  12644. }
  12645. if ( button & 2 ) {
  12646. return 3;
  12647. }
  12648. if ( button & 4 ) {
  12649. return 2;
  12650. }
  12651. return 0;
  12652. }
  12653. return event.which;
  12654. }
  12655. }, jQuery.event.addProp );
  12656. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  12657. jQuery.event.special[ type ] = {
  12658. // Utilize native event if possible so blur/focus sequence is correct
  12659. setup: function() {
  12660. // Claim the first handler
  12661. // dataPriv.set( this, "focus", ... )
  12662. // dataPriv.set( this, "blur", ... )
  12663. leverageNative( this, type, expectSync );
  12664. // Return false to allow normal processing in the caller
  12665. return false;
  12666. },
  12667. trigger: function() {
  12668. // Force setup before trigger
  12669. leverageNative( this, type );
  12670. // Return non-false to allow normal event-path propagation
  12671. return true;
  12672. },
  12673. delegateType: delegateType
  12674. };
  12675. } );
  12676. // Create mouseenter/leave events using mouseover/out and event-time checks
  12677. // so that event delegation works in jQuery.
  12678. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  12679. //
  12680. // Support: Safari 7 only
  12681. // Safari sends mouseenter too often; see:
  12682. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  12683. // for the description of the bug (it existed in older Chrome versions as well).
  12684. jQuery.each( {
  12685. mouseenter: "mouseover",
  12686. mouseleave: "mouseout",
  12687. pointerenter: "pointerover",
  12688. pointerleave: "pointerout"
  12689. }, function( orig, fix ) {
  12690. jQuery.event.special[ orig ] = {
  12691. delegateType: fix,
  12692. bindType: fix,
  12693. handle: function( event ) {
  12694. var ret,
  12695. target = this,
  12696. related = event.relatedTarget,
  12697. handleObj = event.handleObj;
  12698. // For mouseenter/leave call the handler if related is outside the target.
  12699. // NB: No relatedTarget if the mouse left/entered the browser window
  12700. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  12701. event.type = handleObj.origType;
  12702. ret = handleObj.handler.apply( this, arguments );
  12703. event.type = fix;
  12704. }
  12705. return ret;
  12706. }
  12707. };
  12708. } );
  12709. jQuery.fn.extend( {
  12710. on: function( types, selector, data, fn ) {
  12711. return on( this, types, selector, data, fn );
  12712. },
  12713. one: function( types, selector, data, fn ) {
  12714. return on( this, types, selector, data, fn, 1 );
  12715. },
  12716. off: function( types, selector, fn ) {
  12717. var handleObj, type;
  12718. if ( types && types.preventDefault && types.handleObj ) {
  12719. // ( event ) dispatched jQuery.Event
  12720. handleObj = types.handleObj;
  12721. jQuery( types.delegateTarget ).off(
  12722. handleObj.namespace ?
  12723. handleObj.origType + "." + handleObj.namespace :
  12724. handleObj.origType,
  12725. handleObj.selector,
  12726. handleObj.handler
  12727. );
  12728. return this;
  12729. }
  12730. if ( typeof types === "object" ) {
  12731. // ( types-object [, selector] )
  12732. for ( type in types ) {
  12733. this.off( type, selector, types[ type ] );
  12734. }
  12735. return this;
  12736. }
  12737. if ( selector === false || typeof selector === "function" ) {
  12738. // ( types [, fn] )
  12739. fn = selector;
  12740. selector = undefined;
  12741. }
  12742. if ( fn === false ) {
  12743. fn = returnFalse;
  12744. }
  12745. return this.each( function() {
  12746. jQuery.event.remove( this, types, fn, selector );
  12747. } );
  12748. }
  12749. } );
  12750. var
  12751. /* eslint-disable max-len */
  12752. // See https://github.com/eslint/eslint/issues/3229
  12753. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  12754. /* eslint-enable */
  12755. // Support: IE <=10 - 11, Edge 12 - 13 only
  12756. // In IE/Edge using regex groups here causes severe slowdowns.
  12757. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  12758. rnoInnerhtml = /<script|<style|<link/i,
  12759. // checked="checked" or checked
  12760. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  12761. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  12762. // Prefer a tbody over its parent table for containing new rows
  12763. function manipulationTarget( elem, content ) {
  12764. if ( nodeName( elem, "table" ) &&
  12765. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  12766. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  12767. }
  12768. return elem;
  12769. }
  12770. // Replace/restore the type attribute of script elements for safe DOM manipulation
  12771. function disableScript( elem ) {
  12772. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  12773. return elem;
  12774. }
  12775. function restoreScript( elem ) {
  12776. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  12777. elem.type = elem.type.slice( 5 );
  12778. } else {
  12779. elem.removeAttribute( "type" );
  12780. }
  12781. return elem;
  12782. }
  12783. function cloneCopyEvent( src, dest ) {
  12784. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  12785. if ( dest.nodeType !== 1 ) {
  12786. return;
  12787. }
  12788. // 1. Copy private data: events, handlers, etc.
  12789. if ( dataPriv.hasData( src ) ) {
  12790. pdataOld = dataPriv.access( src );
  12791. pdataCur = dataPriv.set( dest, pdataOld );
  12792. events = pdataOld.events;
  12793. if ( events ) {
  12794. delete pdataCur.handle;
  12795. pdataCur.events = {};
  12796. for ( type in events ) {
  12797. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  12798. jQuery.event.add( dest, type, events[ type ][ i ] );
  12799. }
  12800. }
  12801. }
  12802. }
  12803. // 2. Copy user data
  12804. if ( dataUser.hasData( src ) ) {
  12805. udataOld = dataUser.access( src );
  12806. udataCur = jQuery.extend( {}, udataOld );
  12807. dataUser.set( dest, udataCur );
  12808. }
  12809. }
  12810. // Fix IE bugs, see support tests
  12811. function fixInput( src, dest ) {
  12812. var nodeName = dest.nodeName.toLowerCase();
  12813. // Fails to persist the checked state of a cloned checkbox or radio button.
  12814. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  12815. dest.checked = src.checked;
  12816. // Fails to return the selected option to the default selected state when cloning options
  12817. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  12818. dest.defaultValue = src.defaultValue;
  12819. }
  12820. }
  12821. function domManip( collection, args, callback, ignored ) {
  12822. // Flatten any nested arrays
  12823. args = concat.apply( [], args );
  12824. var fragment, first, scripts, hasScripts, node, doc,
  12825. i = 0,
  12826. l = collection.length,
  12827. iNoClone = l - 1,
  12828. value = args[ 0 ],
  12829. valueIsFunction = isFunction( value );
  12830. // We can't cloneNode fragments that contain checked, in WebKit
  12831. if ( valueIsFunction ||
  12832. ( l > 1 && typeof value === "string" &&
  12833. !support.checkClone && rchecked.test( value ) ) ) {
  12834. return collection.each( function( index ) {
  12835. var self = collection.eq( index );
  12836. if ( valueIsFunction ) {
  12837. args[ 0 ] = value.call( this, index, self.html() );
  12838. }
  12839. domManip( self, args, callback, ignored );
  12840. } );
  12841. }
  12842. if ( l ) {
  12843. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  12844. first = fragment.firstChild;
  12845. if ( fragment.childNodes.length === 1 ) {
  12846. fragment = first;
  12847. }
  12848. // Require either new content or an interest in ignored elements to invoke the callback
  12849. if ( first || ignored ) {
  12850. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  12851. hasScripts = scripts.length;
  12852. // Use the original fragment for the last item
  12853. // instead of the first because it can end up
  12854. // being emptied incorrectly in certain situations (#8070).
  12855. for ( ; i < l; i++ ) {
  12856. node = fragment;
  12857. if ( i !== iNoClone ) {
  12858. node = jQuery.clone( node, true, true );
  12859. // Keep references to cloned scripts for later restoration
  12860. if ( hasScripts ) {
  12861. // Support: Android <=4.0 only, PhantomJS 1 only
  12862. // push.apply(_, arraylike) throws on ancient WebKit
  12863. jQuery.merge( scripts, getAll( node, "script" ) );
  12864. }
  12865. }
  12866. callback.call( collection[ i ], node, i );
  12867. }
  12868. if ( hasScripts ) {
  12869. doc = scripts[ scripts.length - 1 ].ownerDocument;
  12870. // Reenable scripts
  12871. jQuery.map( scripts, restoreScript );
  12872. // Evaluate executable scripts on first document insertion
  12873. for ( i = 0; i < hasScripts; i++ ) {
  12874. node = scripts[ i ];
  12875. if ( rscriptType.test( node.type || "" ) &&
  12876. !dataPriv.access( node, "globalEval" ) &&
  12877. jQuery.contains( doc, node ) ) {
  12878. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  12879. // Optional AJAX dependency, but won't run scripts if not present
  12880. if ( jQuery._evalUrl && !node.noModule ) {
  12881. jQuery._evalUrl( node.src, {
  12882. nonce: node.nonce || node.getAttribute( "nonce" )
  12883. } );
  12884. }
  12885. } else {
  12886. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  12887. }
  12888. }
  12889. }
  12890. }
  12891. }
  12892. }
  12893. return collection;
  12894. }
  12895. function remove( elem, selector, keepData ) {
  12896. var node,
  12897. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  12898. i = 0;
  12899. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  12900. if ( !keepData && node.nodeType === 1 ) {
  12901. jQuery.cleanData( getAll( node ) );
  12902. }
  12903. if ( node.parentNode ) {
  12904. if ( keepData && isAttached( node ) ) {
  12905. setGlobalEval( getAll( node, "script" ) );
  12906. }
  12907. node.parentNode.removeChild( node );
  12908. }
  12909. }
  12910. return elem;
  12911. }
  12912. jQuery.extend( {
  12913. htmlPrefilter: function( html ) {
  12914. return html.replace( rxhtmlTag, "<$1></$2>" );
  12915. },
  12916. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  12917. var i, l, srcElements, destElements,
  12918. clone = elem.cloneNode( true ),
  12919. inPage = isAttached( elem );
  12920. // Fix IE cloning issues
  12921. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  12922. !jQuery.isXMLDoc( elem ) ) {
  12923. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  12924. destElements = getAll( clone );
  12925. srcElements = getAll( elem );
  12926. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12927. fixInput( srcElements[ i ], destElements[ i ] );
  12928. }
  12929. }
  12930. // Copy the events from the original to the clone
  12931. if ( dataAndEvents ) {
  12932. if ( deepDataAndEvents ) {
  12933. srcElements = srcElements || getAll( elem );
  12934. destElements = destElements || getAll( clone );
  12935. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12936. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  12937. }
  12938. } else {
  12939. cloneCopyEvent( elem, clone );
  12940. }
  12941. }
  12942. // Preserve script evaluation history
  12943. destElements = getAll( clone, "script" );
  12944. if ( destElements.length > 0 ) {
  12945. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  12946. }
  12947. // Return the cloned set
  12948. return clone;
  12949. },
  12950. cleanData: function( elems ) {
  12951. var data, elem, type,
  12952. special = jQuery.event.special,
  12953. i = 0;
  12954. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  12955. if ( acceptData( elem ) ) {
  12956. if ( ( data = elem[ dataPriv.expando ] ) ) {
  12957. if ( data.events ) {
  12958. for ( type in data.events ) {
  12959. if ( special[ type ] ) {
  12960. jQuery.event.remove( elem, type );
  12961. // This is a shortcut to avoid jQuery.event.remove's overhead
  12962. } else {
  12963. jQuery.removeEvent( elem, type, data.handle );
  12964. }
  12965. }
  12966. }
  12967. // Support: Chrome <=35 - 45+
  12968. // Assign undefined instead of using delete, see Data#remove
  12969. elem[ dataPriv.expando ] = undefined;
  12970. }
  12971. if ( elem[ dataUser.expando ] ) {
  12972. // Support: Chrome <=35 - 45+
  12973. // Assign undefined instead of using delete, see Data#remove
  12974. elem[ dataUser.expando ] = undefined;
  12975. }
  12976. }
  12977. }
  12978. }
  12979. } );
  12980. jQuery.fn.extend( {
  12981. detach: function( selector ) {
  12982. return remove( this, selector, true );
  12983. },
  12984. remove: function( selector ) {
  12985. return remove( this, selector );
  12986. },
  12987. text: function( value ) {
  12988. return access( this, function( value ) {
  12989. return value === undefined ?
  12990. jQuery.text( this ) :
  12991. this.empty().each( function() {
  12992. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12993. this.textContent = value;
  12994. }
  12995. } );
  12996. }, null, value, arguments.length );
  12997. },
  12998. append: function() {
  12999. return domManip( this, arguments, function( elem ) {
  13000. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13001. var target = manipulationTarget( this, elem );
  13002. target.appendChild( elem );
  13003. }
  13004. } );
  13005. },
  13006. prepend: function() {
  13007. return domManip( this, arguments, function( elem ) {
  13008. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  13009. var target = manipulationTarget( this, elem );
  13010. target.insertBefore( elem, target.firstChild );
  13011. }
  13012. } );
  13013. },
  13014. before: function() {
  13015. return domManip( this, arguments, function( elem ) {
  13016. if ( this.parentNode ) {
  13017. this.parentNode.insertBefore( elem, this );
  13018. }
  13019. } );
  13020. },
  13021. after: function() {
  13022. return domManip( this, arguments, function( elem ) {
  13023. if ( this.parentNode ) {
  13024. this.parentNode.insertBefore( elem, this.nextSibling );
  13025. }
  13026. } );
  13027. },
  13028. empty: function() {
  13029. var elem,
  13030. i = 0;
  13031. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  13032. if ( elem.nodeType === 1 ) {
  13033. // Prevent memory leaks
  13034. jQuery.cleanData( getAll( elem, false ) );
  13035. // Remove any remaining nodes
  13036. elem.textContent = "";
  13037. }
  13038. }
  13039. return this;
  13040. },
  13041. clone: function( dataAndEvents, deepDataAndEvents ) {
  13042. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  13043. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  13044. return this.map( function() {
  13045. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  13046. } );
  13047. },
  13048. html: function( value ) {
  13049. return access( this, function( value ) {
  13050. var elem = this[ 0 ] || {},
  13051. i = 0,
  13052. l = this.length;
  13053. if ( value === undefined && elem.nodeType === 1 ) {
  13054. return elem.innerHTML;
  13055. }
  13056. // See if we can take a shortcut and just use innerHTML
  13057. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  13058. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  13059. value = jQuery.htmlPrefilter( value );
  13060. try {
  13061. for ( ; i < l; i++ ) {
  13062. elem = this[ i ] || {};
  13063. // Remove element nodes and prevent memory leaks
  13064. if ( elem.nodeType === 1 ) {
  13065. jQuery.cleanData( getAll( elem, false ) );
  13066. elem.innerHTML = value;
  13067. }
  13068. }
  13069. elem = 0;
  13070. // If using innerHTML throws an exception, use the fallback method
  13071. } catch ( e ) {}
  13072. }
  13073. if ( elem ) {
  13074. this.empty().append( value );
  13075. }
  13076. }, null, value, arguments.length );
  13077. },
  13078. replaceWith: function() {
  13079. var ignored = [];
  13080. // Make the changes, replacing each non-ignored context element with the new content
  13081. return domManip( this, arguments, function( elem ) {
  13082. var parent = this.parentNode;
  13083. if ( jQuery.inArray( this, ignored ) < 0 ) {
  13084. jQuery.cleanData( getAll( this ) );
  13085. if ( parent ) {
  13086. parent.replaceChild( elem, this );
  13087. }
  13088. }
  13089. // Force callback invocation
  13090. }, ignored );
  13091. }
  13092. } );
  13093. jQuery.each( {
  13094. appendTo: "append",
  13095. prependTo: "prepend",
  13096. insertBefore: "before",
  13097. insertAfter: "after",
  13098. replaceAll: "replaceWith"
  13099. }, function( name, original ) {
  13100. jQuery.fn[ name ] = function( selector ) {
  13101. var elems,
  13102. ret = [],
  13103. insert = jQuery( selector ),
  13104. last = insert.length - 1,
  13105. i = 0;
  13106. for ( ; i <= last; i++ ) {
  13107. elems = i === last ? this : this.clone( true );
  13108. jQuery( insert[ i ] )[ original ]( elems );
  13109. // Support: Android <=4.0 only, PhantomJS 1 only
  13110. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  13111. push.apply( ret, elems.get() );
  13112. }
  13113. return this.pushStack( ret );
  13114. };
  13115. } );
  13116. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  13117. var getStyles = function( elem ) {
  13118. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  13119. // IE throws on elements created in popups
  13120. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  13121. var view = elem.ownerDocument.defaultView;
  13122. if ( !view || !view.opener ) {
  13123. view = window;
  13124. }
  13125. return view.getComputedStyle( elem );
  13126. };
  13127. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  13128. ( function() {
  13129. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  13130. // so they're executed at the same time to save the second computation.
  13131. function computeStyleTests() {
  13132. // This is a singleton, we need to execute it only once
  13133. if ( !div ) {
  13134. return;
  13135. }
  13136. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  13137. "margin-top:1px;padding:0;border:0";
  13138. div.style.cssText =
  13139. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  13140. "margin:auto;border:1px;padding:1px;" +
  13141. "width:60%;top:1%";
  13142. documentElement.appendChild( container ).appendChild( div );
  13143. var divStyle = window.getComputedStyle( div );
  13144. pixelPositionVal = divStyle.top !== "1%";
  13145. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  13146. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  13147. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  13148. // Some styles come back with percentage values, even though they shouldn't
  13149. div.style.right = "60%";
  13150. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  13151. // Support: IE 9 - 11 only
  13152. // Detect misreporting of content dimensions for box-sizing:border-box elements
  13153. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  13154. // Support: IE 9 only
  13155. // Detect overflow:scroll screwiness (gh-3699)
  13156. // Support: Chrome <=64
  13157. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  13158. div.style.position = "absolute";
  13159. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  13160. documentElement.removeChild( container );
  13161. // Nullify the div so it wouldn't be stored in the memory and
  13162. // it will also be a sign that checks already performed
  13163. div = null;
  13164. }
  13165. function roundPixelMeasures( measure ) {
  13166. return Math.round( parseFloat( measure ) );
  13167. }
  13168. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  13169. reliableMarginLeftVal,
  13170. container = document.createElement( "div" ),
  13171. div = document.createElement( "div" );
  13172. // Finish early in limited (non-browser) environments
  13173. if ( !div.style ) {
  13174. return;
  13175. }
  13176. // Support: IE <=9 - 11 only
  13177. // Style of cloned element affects source element cloned (#8908)
  13178. div.style.backgroundClip = "content-box";
  13179. div.cloneNode( true ).style.backgroundClip = "";
  13180. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  13181. jQuery.extend( support, {
  13182. boxSizingReliable: function() {
  13183. computeStyleTests();
  13184. return boxSizingReliableVal;
  13185. },
  13186. pixelBoxStyles: function() {
  13187. computeStyleTests();
  13188. return pixelBoxStylesVal;
  13189. },
  13190. pixelPosition: function() {
  13191. computeStyleTests();
  13192. return pixelPositionVal;
  13193. },
  13194. reliableMarginLeft: function() {
  13195. computeStyleTests();
  13196. return reliableMarginLeftVal;
  13197. },
  13198. scrollboxSize: function() {
  13199. computeStyleTests();
  13200. return scrollboxSizeVal;
  13201. }
  13202. } );
  13203. } )();
  13204. function curCSS( elem, name, computed ) {
  13205. var width, minWidth, maxWidth, ret,
  13206. // Support: Firefox 51+
  13207. // Retrieving style before computed somehow
  13208. // fixes an issue with getting wrong values
  13209. // on detached elements
  13210. style = elem.style;
  13211. computed = computed || getStyles( elem );
  13212. // getPropertyValue is needed for:
  13213. // .css('filter') (IE 9 only, #12537)
  13214. // .css('--customProperty) (#3144)
  13215. if ( computed ) {
  13216. ret = computed.getPropertyValue( name ) || computed[ name ];
  13217. if ( ret === "" && !isAttached( elem ) ) {
  13218. ret = jQuery.style( elem, name );
  13219. }
  13220. // A tribute to the "awesome hack by Dean Edwards"
  13221. // Android Browser returns percentage for some values,
  13222. // but width seems to be reliably pixels.
  13223. // This is against the CSSOM draft spec:
  13224. // https://drafts.csswg.org/cssom/#resolved-values
  13225. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  13226. // Remember the original values
  13227. width = style.width;
  13228. minWidth = style.minWidth;
  13229. maxWidth = style.maxWidth;
  13230. // Put in the new values to get a computed value out
  13231. style.minWidth = style.maxWidth = style.width = ret;
  13232. ret = computed.width;
  13233. // Revert the changed values
  13234. style.width = width;
  13235. style.minWidth = minWidth;
  13236. style.maxWidth = maxWidth;
  13237. }
  13238. }
  13239. return ret !== undefined ?
  13240. // Support: IE <=9 - 11 only
  13241. // IE returns zIndex value as an integer.
  13242. ret + "" :
  13243. ret;
  13244. }
  13245. function addGetHookIf( conditionFn, hookFn ) {
  13246. // Define the hook, we'll check on the first run if it's really needed.
  13247. return {
  13248. get: function() {
  13249. if ( conditionFn() ) {
  13250. // Hook not needed (or it's not possible to use it due
  13251. // to missing dependency), remove it.
  13252. delete this.get;
  13253. return;
  13254. }
  13255. // Hook needed; redefine it so that the support test is not executed again.
  13256. return ( this.get = hookFn ).apply( this, arguments );
  13257. }
  13258. };
  13259. }
  13260. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  13261. emptyStyle = document.createElement( "div" ).style,
  13262. vendorProps = {};
  13263. // Return a vendor-prefixed property or undefined
  13264. function vendorPropName( name ) {
  13265. // Check for vendor prefixed names
  13266. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  13267. i = cssPrefixes.length;
  13268. while ( i-- ) {
  13269. name = cssPrefixes[ i ] + capName;
  13270. if ( name in emptyStyle ) {
  13271. return name;
  13272. }
  13273. }
  13274. }
  13275. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  13276. function finalPropName( name ) {
  13277. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  13278. if ( final ) {
  13279. return final;
  13280. }
  13281. if ( name in emptyStyle ) {
  13282. return name;
  13283. }
  13284. return vendorProps[ name ] = vendorPropName( name ) || name;
  13285. }
  13286. var
  13287. // Swappable if display is none or starts with table
  13288. // except "table", "table-cell", or "table-caption"
  13289. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  13290. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  13291. rcustomProp = /^--/,
  13292. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  13293. cssNormalTransform = {
  13294. letterSpacing: "0",
  13295. fontWeight: "400"
  13296. };
  13297. function setPositiveNumber( elem, value, subtract ) {
  13298. // Any relative (+/-) values have already been
  13299. // normalized at this point
  13300. var matches = rcssNum.exec( value );
  13301. return matches ?
  13302. // Guard against undefined "subtract", e.g., when used as in cssHooks
  13303. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  13304. value;
  13305. }
  13306. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  13307. var i = dimension === "width" ? 1 : 0,
  13308. extra = 0,
  13309. delta = 0;
  13310. // Adjustment may not be necessary
  13311. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  13312. return 0;
  13313. }
  13314. for ( ; i < 4; i += 2 ) {
  13315. // Both box models exclude margin
  13316. if ( box === "margin" ) {
  13317. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  13318. }
  13319. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  13320. if ( !isBorderBox ) {
  13321. // Add padding
  13322. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13323. // For "border" or "margin", add border
  13324. if ( box !== "padding" ) {
  13325. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13326. // But still keep track of it otherwise
  13327. } else {
  13328. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13329. }
  13330. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  13331. // "padding" or "margin"
  13332. } else {
  13333. // For "content", subtract padding
  13334. if ( box === "content" ) {
  13335. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13336. }
  13337. // For "content" or "padding", subtract border
  13338. if ( box !== "margin" ) {
  13339. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13340. }
  13341. }
  13342. }
  13343. // Account for positive content-box scroll gutter when requested by providing computedVal
  13344. if ( !isBorderBox && computedVal >= 0 ) {
  13345. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  13346. // Assuming integer scroll gutter, subtract the rest and round down
  13347. delta += Math.max( 0, Math.ceil(
  13348. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13349. computedVal -
  13350. delta -
  13351. extra -
  13352. 0.5
  13353. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  13354. // Use an explicit zero to avoid NaN (gh-3964)
  13355. ) ) || 0;
  13356. }
  13357. return delta;
  13358. }
  13359. function getWidthOrHeight( elem, dimension, extra ) {
  13360. // Start with computed style
  13361. var styles = getStyles( elem ),
  13362. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  13363. // Fake content-box until we know it's needed to know the true value.
  13364. boxSizingNeeded = !support.boxSizingReliable() || extra,
  13365. isBorderBox = boxSizingNeeded &&
  13366. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13367. valueIsBorderBox = isBorderBox,
  13368. val = curCSS( elem, dimension, styles ),
  13369. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  13370. // Support: Firefox <=54
  13371. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  13372. if ( rnumnonpx.test( val ) ) {
  13373. if ( !extra ) {
  13374. return val;
  13375. }
  13376. val = "auto";
  13377. }
  13378. // Fall back to offsetWidth/offsetHeight when value is "auto"
  13379. // This happens for inline elements with no explicit setting (gh-3571)
  13380. // Support: Android <=4.1 - 4.3 only
  13381. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  13382. // Support: IE 9-11 only
  13383. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  13384. // We use getClientRects() to check for hidden/disconnected.
  13385. // In those cases, the computed value can be trusted to be border-box
  13386. if ( ( !support.boxSizingReliable() && isBorderBox ||
  13387. val === "auto" ||
  13388. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  13389. elem.getClientRects().length ) {
  13390. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  13391. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  13392. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  13393. // retrieved value as a content box dimension.
  13394. valueIsBorderBox = offsetProp in elem;
  13395. if ( valueIsBorderBox ) {
  13396. val = elem[ offsetProp ];
  13397. }
  13398. }
  13399. // Normalize "" and auto
  13400. val = parseFloat( val ) || 0;
  13401. // Adjust for the element's box model
  13402. return ( val +
  13403. boxModelAdjustment(
  13404. elem,
  13405. dimension,
  13406. extra || ( isBorderBox ? "border" : "content" ),
  13407. valueIsBorderBox,
  13408. styles,
  13409. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  13410. val
  13411. )
  13412. ) + "px";
  13413. }
  13414. jQuery.extend( {
  13415. // Add in style property hooks for overriding the default
  13416. // behavior of getting and setting a style property
  13417. cssHooks: {
  13418. opacity: {
  13419. get: function( elem, computed ) {
  13420. if ( computed ) {
  13421. // We should always get a number back from opacity
  13422. var ret = curCSS( elem, "opacity" );
  13423. return ret === "" ? "1" : ret;
  13424. }
  13425. }
  13426. }
  13427. },
  13428. // Don't automatically add "px" to these possibly-unitless properties
  13429. cssNumber: {
  13430. "animationIterationCount": true,
  13431. "columnCount": true,
  13432. "fillOpacity": true,
  13433. "flexGrow": true,
  13434. "flexShrink": true,
  13435. "fontWeight": true,
  13436. "gridArea": true,
  13437. "gridColumn": true,
  13438. "gridColumnEnd": true,
  13439. "gridColumnStart": true,
  13440. "gridRow": true,
  13441. "gridRowEnd": true,
  13442. "gridRowStart": true,
  13443. "lineHeight": true,
  13444. "opacity": true,
  13445. "order": true,
  13446. "orphans": true,
  13447. "widows": true,
  13448. "zIndex": true,
  13449. "zoom": true
  13450. },
  13451. // Add in properties whose names you wish to fix before
  13452. // setting or getting the value
  13453. cssProps: {},
  13454. // Get and set the style property on a DOM Node
  13455. style: function( elem, name, value, extra ) {
  13456. // Don't set styles on text and comment nodes
  13457. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  13458. return;
  13459. }
  13460. // Make sure that we're working with the right name
  13461. var ret, type, hooks,
  13462. origName = camelCase( name ),
  13463. isCustomProp = rcustomProp.test( name ),
  13464. style = elem.style;
  13465. // Make sure that we're working with the right name. We don't
  13466. // want to query the value if it is a CSS custom property
  13467. // since they are user-defined.
  13468. if ( !isCustomProp ) {
  13469. name = finalPropName( origName );
  13470. }
  13471. // Gets hook for the prefixed version, then unprefixed version
  13472. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13473. // Check if we're setting a value
  13474. if ( value !== undefined ) {
  13475. type = typeof value;
  13476. // Convert "+=" or "-=" to relative numbers (#7345)
  13477. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  13478. value = adjustCSS( elem, name, ret );
  13479. // Fixes bug #9237
  13480. type = "number";
  13481. }
  13482. // Make sure that null and NaN values aren't set (#7116)
  13483. if ( value == null || value !== value ) {
  13484. return;
  13485. }
  13486. // If a number was passed in, add the unit (except for certain CSS properties)
  13487. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  13488. // "px" to a few hardcoded values.
  13489. if ( type === "number" && !isCustomProp ) {
  13490. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  13491. }
  13492. // background-* props affect original clone's values
  13493. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  13494. style[ name ] = "inherit";
  13495. }
  13496. // If a hook was provided, use that value, otherwise just set the specified value
  13497. if ( !hooks || !( "set" in hooks ) ||
  13498. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  13499. if ( isCustomProp ) {
  13500. style.setProperty( name, value );
  13501. } else {
  13502. style[ name ] = value;
  13503. }
  13504. }
  13505. } else {
  13506. // If a hook was provided get the non-computed value from there
  13507. if ( hooks && "get" in hooks &&
  13508. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  13509. return ret;
  13510. }
  13511. // Otherwise just get the value from the style object
  13512. return style[ name ];
  13513. }
  13514. },
  13515. css: function( elem, name, extra, styles ) {
  13516. var val, num, hooks,
  13517. origName = camelCase( name ),
  13518. isCustomProp = rcustomProp.test( name );
  13519. // Make sure that we're working with the right name. We don't
  13520. // want to modify the value if it is a CSS custom property
  13521. // since they are user-defined.
  13522. if ( !isCustomProp ) {
  13523. name = finalPropName( origName );
  13524. }
  13525. // Try prefixed name followed by the unprefixed name
  13526. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13527. // If a hook was provided get the computed value from there
  13528. if ( hooks && "get" in hooks ) {
  13529. val = hooks.get( elem, true, extra );
  13530. }
  13531. // Otherwise, if a way to get the computed value exists, use that
  13532. if ( val === undefined ) {
  13533. val = curCSS( elem, name, styles );
  13534. }
  13535. // Convert "normal" to computed value
  13536. if ( val === "normal" && name in cssNormalTransform ) {
  13537. val = cssNormalTransform[ name ];
  13538. }
  13539. // Make numeric if forced or a qualifier was provided and val looks numeric
  13540. if ( extra === "" || extra ) {
  13541. num = parseFloat( val );
  13542. return extra === true || isFinite( num ) ? num || 0 : val;
  13543. }
  13544. return val;
  13545. }
  13546. } );
  13547. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  13548. jQuery.cssHooks[ dimension ] = {
  13549. get: function( elem, computed, extra ) {
  13550. if ( computed ) {
  13551. // Certain elements can have dimension info if we invisibly show them
  13552. // but it must have a current display style that would benefit
  13553. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  13554. // Support: Safari 8+
  13555. // Table columns in Safari have non-zero offsetWidth & zero
  13556. // getBoundingClientRect().width unless display is changed.
  13557. // Support: IE <=11 only
  13558. // Running getBoundingClientRect on a disconnected node
  13559. // in IE throws an error.
  13560. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  13561. swap( elem, cssShow, function() {
  13562. return getWidthOrHeight( elem, dimension, extra );
  13563. } ) :
  13564. getWidthOrHeight( elem, dimension, extra );
  13565. }
  13566. },
  13567. set: function( elem, value, extra ) {
  13568. var matches,
  13569. styles = getStyles( elem ),
  13570. // Only read styles.position if the test has a chance to fail
  13571. // to avoid forcing a reflow.
  13572. scrollboxSizeBuggy = !support.scrollboxSize() &&
  13573. styles.position === "absolute",
  13574. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  13575. boxSizingNeeded = scrollboxSizeBuggy || extra,
  13576. isBorderBox = boxSizingNeeded &&
  13577. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13578. subtract = extra ?
  13579. boxModelAdjustment(
  13580. elem,
  13581. dimension,
  13582. extra,
  13583. isBorderBox,
  13584. styles
  13585. ) :
  13586. 0;
  13587. // Account for unreliable border-box dimensions by comparing offset* to computed and
  13588. // faking a content-box to get border and padding (gh-3699)
  13589. if ( isBorderBox && scrollboxSizeBuggy ) {
  13590. subtract -= Math.ceil(
  13591. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13592. parseFloat( styles[ dimension ] ) -
  13593. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  13594. 0.5
  13595. );
  13596. }
  13597. // Convert to pixels if value adjustment is needed
  13598. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  13599. ( matches[ 3 ] || "px" ) !== "px" ) {
  13600. elem.style[ dimension ] = value;
  13601. value = jQuery.css( elem, dimension );
  13602. }
  13603. return setPositiveNumber( elem, value, subtract );
  13604. }
  13605. };
  13606. } );
  13607. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  13608. function( elem, computed ) {
  13609. if ( computed ) {
  13610. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  13611. elem.getBoundingClientRect().left -
  13612. swap( elem, { marginLeft: 0 }, function() {
  13613. return elem.getBoundingClientRect().left;
  13614. } )
  13615. ) + "px";
  13616. }
  13617. }
  13618. );
  13619. // These hooks are used by animate to expand properties
  13620. jQuery.each( {
  13621. margin: "",
  13622. padding: "",
  13623. border: "Width"
  13624. }, function( prefix, suffix ) {
  13625. jQuery.cssHooks[ prefix + suffix ] = {
  13626. expand: function( value ) {
  13627. var i = 0,
  13628. expanded = {},
  13629. // Assumes a single number if not a string
  13630. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  13631. for ( ; i < 4; i++ ) {
  13632. expanded[ prefix + cssExpand[ i ] + suffix ] =
  13633. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  13634. }
  13635. return expanded;
  13636. }
  13637. };
  13638. if ( prefix !== "margin" ) {
  13639. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  13640. }
  13641. } );
  13642. jQuery.fn.extend( {
  13643. css: function( name, value ) {
  13644. return access( this, function( elem, name, value ) {
  13645. var styles, len,
  13646. map = {},
  13647. i = 0;
  13648. if ( Array.isArray( name ) ) {
  13649. styles = getStyles( elem );
  13650. len = name.length;
  13651. for ( ; i < len; i++ ) {
  13652. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  13653. }
  13654. return map;
  13655. }
  13656. return value !== undefined ?
  13657. jQuery.style( elem, name, value ) :
  13658. jQuery.css( elem, name );
  13659. }, name, value, arguments.length > 1 );
  13660. }
  13661. } );
  13662. function Tween( elem, options, prop, end, easing ) {
  13663. return new Tween.prototype.init( elem, options, prop, end, easing );
  13664. }
  13665. jQuery.Tween = Tween;
  13666. Tween.prototype = {
  13667. constructor: Tween,
  13668. init: function( elem, options, prop, end, easing, unit ) {
  13669. this.elem = elem;
  13670. this.prop = prop;
  13671. this.easing = easing || jQuery.easing._default;
  13672. this.options = options;
  13673. this.start = this.now = this.cur();
  13674. this.end = end;
  13675. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  13676. },
  13677. cur: function() {
  13678. var hooks = Tween.propHooks[ this.prop ];
  13679. return hooks && hooks.get ?
  13680. hooks.get( this ) :
  13681. Tween.propHooks._default.get( this );
  13682. },
  13683. run: function( percent ) {
  13684. var eased,
  13685. hooks = Tween.propHooks[ this.prop ];
  13686. if ( this.options.duration ) {
  13687. this.pos = eased = jQuery.easing[ this.easing ](
  13688. percent, this.options.duration * percent, 0, 1, this.options.duration
  13689. );
  13690. } else {
  13691. this.pos = eased = percent;
  13692. }
  13693. this.now = ( this.end - this.start ) * eased + this.start;
  13694. if ( this.options.step ) {
  13695. this.options.step.call( this.elem, this.now, this );
  13696. }
  13697. if ( hooks && hooks.set ) {
  13698. hooks.set( this );
  13699. } else {
  13700. Tween.propHooks._default.set( this );
  13701. }
  13702. return this;
  13703. }
  13704. };
  13705. Tween.prototype.init.prototype = Tween.prototype;
  13706. Tween.propHooks = {
  13707. _default: {
  13708. get: function( tween ) {
  13709. var result;
  13710. // Use a property on the element directly when it is not a DOM element,
  13711. // or when there is no matching style property that exists.
  13712. if ( tween.elem.nodeType !== 1 ||
  13713. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  13714. return tween.elem[ tween.prop ];
  13715. }
  13716. // Passing an empty string as a 3rd parameter to .css will automatically
  13717. // attempt a parseFloat and fallback to a string if the parse fails.
  13718. // Simple values such as "10px" are parsed to Float;
  13719. // complex values such as "rotate(1rad)" are returned as-is.
  13720. result = jQuery.css( tween.elem, tween.prop, "" );
  13721. // Empty strings, null, undefined and "auto" are converted to 0.
  13722. return !result || result === "auto" ? 0 : result;
  13723. },
  13724. set: function( tween ) {
  13725. // Use step hook for back compat.
  13726. // Use cssHook if its there.
  13727. // Use .style if available and use plain properties where available.
  13728. if ( jQuery.fx.step[ tween.prop ] ) {
  13729. jQuery.fx.step[ tween.prop ]( tween );
  13730. } else if ( tween.elem.nodeType === 1 && (
  13731. jQuery.cssHooks[ tween.prop ] ||
  13732. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  13733. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  13734. } else {
  13735. tween.elem[ tween.prop ] = tween.now;
  13736. }
  13737. }
  13738. }
  13739. };
  13740. // Support: IE <=9 only
  13741. // Panic based approach to setting things on disconnected nodes
  13742. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  13743. set: function( tween ) {
  13744. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  13745. tween.elem[ tween.prop ] = tween.now;
  13746. }
  13747. }
  13748. };
  13749. jQuery.easing = {
  13750. linear: function( p ) {
  13751. return p;
  13752. },
  13753. swing: function( p ) {
  13754. return 0.5 - Math.cos( p * Math.PI ) / 2;
  13755. },
  13756. _default: "swing"
  13757. };
  13758. jQuery.fx = Tween.prototype.init;
  13759. // Back compat <1.8 extension point
  13760. jQuery.fx.step = {};
  13761. var
  13762. fxNow, inProgress,
  13763. rfxtypes = /^(?:toggle|show|hide)$/,
  13764. rrun = /queueHooks$/;
  13765. function schedule() {
  13766. if ( inProgress ) {
  13767. if ( document.hidden === false && window.requestAnimationFrame ) {
  13768. window.requestAnimationFrame( schedule );
  13769. } else {
  13770. window.setTimeout( schedule, jQuery.fx.interval );
  13771. }
  13772. jQuery.fx.tick();
  13773. }
  13774. }
  13775. // Animations created synchronously will run synchronously
  13776. function createFxNow() {
  13777. window.setTimeout( function() {
  13778. fxNow = undefined;
  13779. } );
  13780. return ( fxNow = Date.now() );
  13781. }
  13782. // Generate parameters to create a standard animation
  13783. function genFx( type, includeWidth ) {
  13784. var which,
  13785. i = 0,
  13786. attrs = { height: type };
  13787. // If we include width, step value is 1 to do all cssExpand values,
  13788. // otherwise step value is 2 to skip over Left and Right
  13789. includeWidth = includeWidth ? 1 : 0;
  13790. for ( ; i < 4; i += 2 - includeWidth ) {
  13791. which = cssExpand[ i ];
  13792. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  13793. }
  13794. if ( includeWidth ) {
  13795. attrs.opacity = attrs.width = type;
  13796. }
  13797. return attrs;
  13798. }
  13799. function createTween( value, prop, animation ) {
  13800. var tween,
  13801. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  13802. index = 0,
  13803. length = collection.length;
  13804. for ( ; index < length; index++ ) {
  13805. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  13806. // We're done with this property
  13807. return tween;
  13808. }
  13809. }
  13810. }
  13811. function defaultPrefilter( elem, props, opts ) {
  13812. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  13813. isBox = "width" in props || "height" in props,
  13814. anim = this,
  13815. orig = {},
  13816. style = elem.style,
  13817. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  13818. dataShow = dataPriv.get( elem, "fxshow" );
  13819. // Queue-skipping animations hijack the fx hooks
  13820. if ( !opts.queue ) {
  13821. hooks = jQuery._queueHooks( elem, "fx" );
  13822. if ( hooks.unqueued == null ) {
  13823. hooks.unqueued = 0;
  13824. oldfire = hooks.empty.fire;
  13825. hooks.empty.fire = function() {
  13826. if ( !hooks.unqueued ) {
  13827. oldfire();
  13828. }
  13829. };
  13830. }
  13831. hooks.unqueued++;
  13832. anim.always( function() {
  13833. // Ensure the complete handler is called before this completes
  13834. anim.always( function() {
  13835. hooks.unqueued--;
  13836. if ( !jQuery.queue( elem, "fx" ).length ) {
  13837. hooks.empty.fire();
  13838. }
  13839. } );
  13840. } );
  13841. }
  13842. // Detect show/hide animations
  13843. for ( prop in props ) {
  13844. value = props[ prop ];
  13845. if ( rfxtypes.test( value ) ) {
  13846. delete props[ prop ];
  13847. toggle = toggle || value === "toggle";
  13848. if ( value === ( hidden ? "hide" : "show" ) ) {
  13849. // Pretend to be hidden if this is a "show" and
  13850. // there is still data from a stopped show/hide
  13851. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  13852. hidden = true;
  13853. // Ignore all other no-op show/hide data
  13854. } else {
  13855. continue;
  13856. }
  13857. }
  13858. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  13859. }
  13860. }
  13861. // Bail out if this is a no-op like .hide().hide()
  13862. propTween = !jQuery.isEmptyObject( props );
  13863. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  13864. return;
  13865. }
  13866. // Restrict "overflow" and "display" styles during box animations
  13867. if ( isBox && elem.nodeType === 1 ) {
  13868. // Support: IE <=9 - 11, Edge 12 - 15
  13869. // Record all 3 overflow attributes because IE does not infer the shorthand
  13870. // from identically-valued overflowX and overflowY and Edge just mirrors
  13871. // the overflowX value there.
  13872. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  13873. // Identify a display type, preferring old show/hide data over the CSS cascade
  13874. restoreDisplay = dataShow && dataShow.display;
  13875. if ( restoreDisplay == null ) {
  13876. restoreDisplay = dataPriv.get( elem, "display" );
  13877. }
  13878. display = jQuery.css( elem, "display" );
  13879. if ( display === "none" ) {
  13880. if ( restoreDisplay ) {
  13881. display = restoreDisplay;
  13882. } else {
  13883. // Get nonempty value(s) by temporarily forcing visibility
  13884. showHide( [ elem ], true );
  13885. restoreDisplay = elem.style.display || restoreDisplay;
  13886. display = jQuery.css( elem, "display" );
  13887. showHide( [ elem ] );
  13888. }
  13889. }
  13890. // Animate inline elements as inline-block
  13891. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  13892. if ( jQuery.css( elem, "float" ) === "none" ) {
  13893. // Restore the original display value at the end of pure show/hide animations
  13894. if ( !propTween ) {
  13895. anim.done( function() {
  13896. style.display = restoreDisplay;
  13897. } );
  13898. if ( restoreDisplay == null ) {
  13899. display = style.display;
  13900. restoreDisplay = display === "none" ? "" : display;
  13901. }
  13902. }
  13903. style.display = "inline-block";
  13904. }
  13905. }
  13906. }
  13907. if ( opts.overflow ) {
  13908. style.overflow = "hidden";
  13909. anim.always( function() {
  13910. style.overflow = opts.overflow[ 0 ];
  13911. style.overflowX = opts.overflow[ 1 ];
  13912. style.overflowY = opts.overflow[ 2 ];
  13913. } );
  13914. }
  13915. // Implement show/hide animations
  13916. propTween = false;
  13917. for ( prop in orig ) {
  13918. // General show/hide setup for this element animation
  13919. if ( !propTween ) {
  13920. if ( dataShow ) {
  13921. if ( "hidden" in dataShow ) {
  13922. hidden = dataShow.hidden;
  13923. }
  13924. } else {
  13925. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  13926. }
  13927. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  13928. if ( toggle ) {
  13929. dataShow.hidden = !hidden;
  13930. }
  13931. // Show elements before animating them
  13932. if ( hidden ) {
  13933. showHide( [ elem ], true );
  13934. }
  13935. /* eslint-disable no-loop-func */
  13936. anim.done( function() {
  13937. /* eslint-enable no-loop-func */
  13938. // The final step of a "hide" animation is actually hiding the element
  13939. if ( !hidden ) {
  13940. showHide( [ elem ] );
  13941. }
  13942. dataPriv.remove( elem, "fxshow" );
  13943. for ( prop in orig ) {
  13944. jQuery.style( elem, prop, orig[ prop ] );
  13945. }
  13946. } );
  13947. }
  13948. // Per-property setup
  13949. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  13950. if ( !( prop in dataShow ) ) {
  13951. dataShow[ prop ] = propTween.start;
  13952. if ( hidden ) {
  13953. propTween.end = propTween.start;
  13954. propTween.start = 0;
  13955. }
  13956. }
  13957. }
  13958. }
  13959. function propFilter( props, specialEasing ) {
  13960. var index, name, easing, value, hooks;
  13961. // camelCase, specialEasing and expand cssHook pass
  13962. for ( index in props ) {
  13963. name = camelCase( index );
  13964. easing = specialEasing[ name ];
  13965. value = props[ index ];
  13966. if ( Array.isArray( value ) ) {
  13967. easing = value[ 1 ];
  13968. value = props[ index ] = value[ 0 ];
  13969. }
  13970. if ( index !== name ) {
  13971. props[ name ] = value;
  13972. delete props[ index ];
  13973. }
  13974. hooks = jQuery.cssHooks[ name ];
  13975. if ( hooks && "expand" in hooks ) {
  13976. value = hooks.expand( value );
  13977. delete props[ name ];
  13978. // Not quite $.extend, this won't overwrite existing keys.
  13979. // Reusing 'index' because we have the correct "name"
  13980. for ( index in value ) {
  13981. if ( !( index in props ) ) {
  13982. props[ index ] = value[ index ];
  13983. specialEasing[ index ] = easing;
  13984. }
  13985. }
  13986. } else {
  13987. specialEasing[ name ] = easing;
  13988. }
  13989. }
  13990. }
  13991. function Animation( elem, properties, options ) {
  13992. var result,
  13993. stopped,
  13994. index = 0,
  13995. length = Animation.prefilters.length,
  13996. deferred = jQuery.Deferred().always( function() {
  13997. // Don't match elem in the :animated selector
  13998. delete tick.elem;
  13999. } ),
  14000. tick = function() {
  14001. if ( stopped ) {
  14002. return false;
  14003. }
  14004. var currentTime = fxNow || createFxNow(),
  14005. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  14006. // Support: Android 2.3 only
  14007. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  14008. temp = remaining / animation.duration || 0,
  14009. percent = 1 - temp,
  14010. index = 0,
  14011. length = animation.tweens.length;
  14012. for ( ; index < length; index++ ) {
  14013. animation.tweens[ index ].run( percent );
  14014. }
  14015. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  14016. // If there's more to do, yield
  14017. if ( percent < 1 && length ) {
  14018. return remaining;
  14019. }
  14020. // If this was an empty animation, synthesize a final progress notification
  14021. if ( !length ) {
  14022. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14023. }
  14024. // Resolve the animation and report its conclusion
  14025. deferred.resolveWith( elem, [ animation ] );
  14026. return false;
  14027. },
  14028. animation = deferred.promise( {
  14029. elem: elem,
  14030. props: jQuery.extend( {}, properties ),
  14031. opts: jQuery.extend( true, {
  14032. specialEasing: {},
  14033. easing: jQuery.easing._default
  14034. }, options ),
  14035. originalProperties: properties,
  14036. originalOptions: options,
  14037. startTime: fxNow || createFxNow(),
  14038. duration: options.duration,
  14039. tweens: [],
  14040. createTween: function( prop, end ) {
  14041. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  14042. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  14043. animation.tweens.push( tween );
  14044. return tween;
  14045. },
  14046. stop: function( gotoEnd ) {
  14047. var index = 0,
  14048. // If we are going to the end, we want to run all the tweens
  14049. // otherwise we skip this part
  14050. length = gotoEnd ? animation.tweens.length : 0;
  14051. if ( stopped ) {
  14052. return this;
  14053. }
  14054. stopped = true;
  14055. for ( ; index < length; index++ ) {
  14056. animation.tweens[ index ].run( 1 );
  14057. }
  14058. // Resolve when we played the last frame; otherwise, reject
  14059. if ( gotoEnd ) {
  14060. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14061. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  14062. } else {
  14063. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  14064. }
  14065. return this;
  14066. }
  14067. } ),
  14068. props = animation.props;
  14069. propFilter( props, animation.opts.specialEasing );
  14070. for ( ; index < length; index++ ) {
  14071. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  14072. if ( result ) {
  14073. if ( isFunction( result.stop ) ) {
  14074. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  14075. result.stop.bind( result );
  14076. }
  14077. return result;
  14078. }
  14079. }
  14080. jQuery.map( props, createTween, animation );
  14081. if ( isFunction( animation.opts.start ) ) {
  14082. animation.opts.start.call( elem, animation );
  14083. }
  14084. // Attach callbacks from options
  14085. animation
  14086. .progress( animation.opts.progress )
  14087. .done( animation.opts.done, animation.opts.complete )
  14088. .fail( animation.opts.fail )
  14089. .always( animation.opts.always );
  14090. jQuery.fx.timer(
  14091. jQuery.extend( tick, {
  14092. elem: elem,
  14093. anim: animation,
  14094. queue: animation.opts.queue
  14095. } )
  14096. );
  14097. return animation;
  14098. }
  14099. jQuery.Animation = jQuery.extend( Animation, {
  14100. tweeners: {
  14101. "*": [ function( prop, value ) {
  14102. var tween = this.createTween( prop, value );
  14103. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  14104. return tween;
  14105. } ]
  14106. },
  14107. tweener: function( props, callback ) {
  14108. if ( isFunction( props ) ) {
  14109. callback = props;
  14110. props = [ "*" ];
  14111. } else {
  14112. props = props.match( rnothtmlwhite );
  14113. }
  14114. var prop,
  14115. index = 0,
  14116. length = props.length;
  14117. for ( ; index < length; index++ ) {
  14118. prop = props[ index ];
  14119. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  14120. Animation.tweeners[ prop ].unshift( callback );
  14121. }
  14122. },
  14123. prefilters: [ defaultPrefilter ],
  14124. prefilter: function( callback, prepend ) {
  14125. if ( prepend ) {
  14126. Animation.prefilters.unshift( callback );
  14127. } else {
  14128. Animation.prefilters.push( callback );
  14129. }
  14130. }
  14131. } );
  14132. jQuery.speed = function( speed, easing, fn ) {
  14133. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  14134. complete: fn || !fn && easing ||
  14135. isFunction( speed ) && speed,
  14136. duration: speed,
  14137. easing: fn && easing || easing && !isFunction( easing ) && easing
  14138. };
  14139. // Go to the end state if fx are off
  14140. if ( jQuery.fx.off ) {
  14141. opt.duration = 0;
  14142. } else {
  14143. if ( typeof opt.duration !== "number" ) {
  14144. if ( opt.duration in jQuery.fx.speeds ) {
  14145. opt.duration = jQuery.fx.speeds[ opt.duration ];
  14146. } else {
  14147. opt.duration = jQuery.fx.speeds._default;
  14148. }
  14149. }
  14150. }
  14151. // Normalize opt.queue - true/undefined/null -> "fx"
  14152. if ( opt.queue == null || opt.queue === true ) {
  14153. opt.queue = "fx";
  14154. }
  14155. // Queueing
  14156. opt.old = opt.complete;
  14157. opt.complete = function() {
  14158. if ( isFunction( opt.old ) ) {
  14159. opt.old.call( this );
  14160. }
  14161. if ( opt.queue ) {
  14162. jQuery.dequeue( this, opt.queue );
  14163. }
  14164. };
  14165. return opt;
  14166. };
  14167. jQuery.fn.extend( {
  14168. fadeTo: function( speed, to, easing, callback ) {
  14169. // Show any hidden elements after setting opacity to 0
  14170. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  14171. // Animate to the value specified
  14172. .end().animate( { opacity: to }, speed, easing, callback );
  14173. },
  14174. animate: function( prop, speed, easing, callback ) {
  14175. var empty = jQuery.isEmptyObject( prop ),
  14176. optall = jQuery.speed( speed, easing, callback ),
  14177. doAnimation = function() {
  14178. // Operate on a copy of prop so per-property easing won't be lost
  14179. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  14180. // Empty animations, or finishing resolves immediately
  14181. if ( empty || dataPriv.get( this, "finish" ) ) {
  14182. anim.stop( true );
  14183. }
  14184. };
  14185. doAnimation.finish = doAnimation;
  14186. return empty || optall.queue === false ?
  14187. this.each( doAnimation ) :
  14188. this.queue( optall.queue, doAnimation );
  14189. },
  14190. stop: function( type, clearQueue, gotoEnd ) {
  14191. var stopQueue = function( hooks ) {
  14192. var stop = hooks.stop;
  14193. delete hooks.stop;
  14194. stop( gotoEnd );
  14195. };
  14196. if ( typeof type !== "string" ) {
  14197. gotoEnd = clearQueue;
  14198. clearQueue = type;
  14199. type = undefined;
  14200. }
  14201. if ( clearQueue && type !== false ) {
  14202. this.queue( type || "fx", [] );
  14203. }
  14204. return this.each( function() {
  14205. var dequeue = true,
  14206. index = type != null && type + "queueHooks",
  14207. timers = jQuery.timers,
  14208. data = dataPriv.get( this );
  14209. if ( index ) {
  14210. if ( data[ index ] && data[ index ].stop ) {
  14211. stopQueue( data[ index ] );
  14212. }
  14213. } else {
  14214. for ( index in data ) {
  14215. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  14216. stopQueue( data[ index ] );
  14217. }
  14218. }
  14219. }
  14220. for ( index = timers.length; index--; ) {
  14221. if ( timers[ index ].elem === this &&
  14222. ( type == null || timers[ index ].queue === type ) ) {
  14223. timers[ index ].anim.stop( gotoEnd );
  14224. dequeue = false;
  14225. timers.splice( index, 1 );
  14226. }
  14227. }
  14228. // Start the next in the queue if the last step wasn't forced.
  14229. // Timers currently will call their complete callbacks, which
  14230. // will dequeue but only if they were gotoEnd.
  14231. if ( dequeue || !gotoEnd ) {
  14232. jQuery.dequeue( this, type );
  14233. }
  14234. } );
  14235. },
  14236. finish: function( type ) {
  14237. if ( type !== false ) {
  14238. type = type || "fx";
  14239. }
  14240. return this.each( function() {
  14241. var index,
  14242. data = dataPriv.get( this ),
  14243. queue = data[ type + "queue" ],
  14244. hooks = data[ type + "queueHooks" ],
  14245. timers = jQuery.timers,
  14246. length = queue ? queue.length : 0;
  14247. // Enable finishing flag on private data
  14248. data.finish = true;
  14249. // Empty the queue first
  14250. jQuery.queue( this, type, [] );
  14251. if ( hooks && hooks.stop ) {
  14252. hooks.stop.call( this, true );
  14253. }
  14254. // Look for any active animations, and finish them
  14255. for ( index = timers.length; index--; ) {
  14256. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  14257. timers[ index ].anim.stop( true );
  14258. timers.splice( index, 1 );
  14259. }
  14260. }
  14261. // Look for any animations in the old queue and finish them
  14262. for ( index = 0; index < length; index++ ) {
  14263. if ( queue[ index ] && queue[ index ].finish ) {
  14264. queue[ index ].finish.call( this );
  14265. }
  14266. }
  14267. // Turn off finishing flag
  14268. delete data.finish;
  14269. } );
  14270. }
  14271. } );
  14272. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  14273. var cssFn = jQuery.fn[ name ];
  14274. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14275. return speed == null || typeof speed === "boolean" ?
  14276. cssFn.apply( this, arguments ) :
  14277. this.animate( genFx( name, true ), speed, easing, callback );
  14278. };
  14279. } );
  14280. // Generate shortcuts for custom animations
  14281. jQuery.each( {
  14282. slideDown: genFx( "show" ),
  14283. slideUp: genFx( "hide" ),
  14284. slideToggle: genFx( "toggle" ),
  14285. fadeIn: { opacity: "show" },
  14286. fadeOut: { opacity: "hide" },
  14287. fadeToggle: { opacity: "toggle" }
  14288. }, function( name, props ) {
  14289. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14290. return this.animate( props, speed, easing, callback );
  14291. };
  14292. } );
  14293. jQuery.timers = [];
  14294. jQuery.fx.tick = function() {
  14295. var timer,
  14296. i = 0,
  14297. timers = jQuery.timers;
  14298. fxNow = Date.now();
  14299. for ( ; i < timers.length; i++ ) {
  14300. timer = timers[ i ];
  14301. // Run the timer and safely remove it when done (allowing for external removal)
  14302. if ( !timer() && timers[ i ] === timer ) {
  14303. timers.splice( i--, 1 );
  14304. }
  14305. }
  14306. if ( !timers.length ) {
  14307. jQuery.fx.stop();
  14308. }
  14309. fxNow = undefined;
  14310. };
  14311. jQuery.fx.timer = function( timer ) {
  14312. jQuery.timers.push( timer );
  14313. jQuery.fx.start();
  14314. };
  14315. jQuery.fx.interval = 13;
  14316. jQuery.fx.start = function() {
  14317. if ( inProgress ) {
  14318. return;
  14319. }
  14320. inProgress = true;
  14321. schedule();
  14322. };
  14323. jQuery.fx.stop = function() {
  14324. inProgress = null;
  14325. };
  14326. jQuery.fx.speeds = {
  14327. slow: 600,
  14328. fast: 200,
  14329. // Default speed
  14330. _default: 400
  14331. };
  14332. // Based off of the plugin by Clint Helfers, with permission.
  14333. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  14334. jQuery.fn.delay = function( time, type ) {
  14335. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  14336. type = type || "fx";
  14337. return this.queue( type, function( next, hooks ) {
  14338. var timeout = window.setTimeout( next, time );
  14339. hooks.stop = function() {
  14340. window.clearTimeout( timeout );
  14341. };
  14342. } );
  14343. };
  14344. ( function() {
  14345. var input = document.createElement( "input" ),
  14346. select = document.createElement( "select" ),
  14347. opt = select.appendChild( document.createElement( "option" ) );
  14348. input.type = "checkbox";
  14349. // Support: Android <=4.3 only
  14350. // Default value for a checkbox should be "on"
  14351. support.checkOn = input.value !== "";
  14352. // Support: IE <=11 only
  14353. // Must access selectedIndex to make default options select
  14354. support.optSelected = opt.selected;
  14355. // Support: IE <=11 only
  14356. // An input loses its value after becoming a radio
  14357. input = document.createElement( "input" );
  14358. input.value = "t";
  14359. input.type = "radio";
  14360. support.radioValue = input.value === "t";
  14361. } )();
  14362. var boolHook,
  14363. attrHandle = jQuery.expr.attrHandle;
  14364. jQuery.fn.extend( {
  14365. attr: function( name, value ) {
  14366. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  14367. },
  14368. removeAttr: function( name ) {
  14369. return this.each( function() {
  14370. jQuery.removeAttr( this, name );
  14371. } );
  14372. }
  14373. } );
  14374. jQuery.extend( {
  14375. attr: function( elem, name, value ) {
  14376. var ret, hooks,
  14377. nType = elem.nodeType;
  14378. // Don't get/set attributes on text, comment and attribute nodes
  14379. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14380. return;
  14381. }
  14382. // Fallback to prop when attributes are not supported
  14383. if ( typeof elem.getAttribute === "undefined" ) {
  14384. return jQuery.prop( elem, name, value );
  14385. }
  14386. // Attribute hooks are determined by the lowercase version
  14387. // Grab necessary hook if one is defined
  14388. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14389. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  14390. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  14391. }
  14392. if ( value !== undefined ) {
  14393. if ( value === null ) {
  14394. jQuery.removeAttr( elem, name );
  14395. return;
  14396. }
  14397. if ( hooks && "set" in hooks &&
  14398. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14399. return ret;
  14400. }
  14401. elem.setAttribute( name, value + "" );
  14402. return value;
  14403. }
  14404. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14405. return ret;
  14406. }
  14407. ret = jQuery.find.attr( elem, name );
  14408. // Non-existent attributes return null, we normalize to undefined
  14409. return ret == null ? undefined : ret;
  14410. },
  14411. attrHooks: {
  14412. type: {
  14413. set: function( elem, value ) {
  14414. if ( !support.radioValue && value === "radio" &&
  14415. nodeName( elem, "input" ) ) {
  14416. var val = elem.value;
  14417. elem.setAttribute( "type", value );
  14418. if ( val ) {
  14419. elem.value = val;
  14420. }
  14421. return value;
  14422. }
  14423. }
  14424. }
  14425. },
  14426. removeAttr: function( elem, value ) {
  14427. var name,
  14428. i = 0,
  14429. // Attribute names can contain non-HTML whitespace characters
  14430. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  14431. attrNames = value && value.match( rnothtmlwhite );
  14432. if ( attrNames && elem.nodeType === 1 ) {
  14433. while ( ( name = attrNames[ i++ ] ) ) {
  14434. elem.removeAttribute( name );
  14435. }
  14436. }
  14437. }
  14438. } );
  14439. // Hooks for boolean attributes
  14440. boolHook = {
  14441. set: function( elem, value, name ) {
  14442. if ( value === false ) {
  14443. // Remove boolean attributes when set to false
  14444. jQuery.removeAttr( elem, name );
  14445. } else {
  14446. elem.setAttribute( name, name );
  14447. }
  14448. return name;
  14449. }
  14450. };
  14451. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  14452. var getter = attrHandle[ name ] || jQuery.find.attr;
  14453. attrHandle[ name ] = function( elem, name, isXML ) {
  14454. var ret, handle,
  14455. lowercaseName = name.toLowerCase();
  14456. if ( !isXML ) {
  14457. // Avoid an infinite loop by temporarily removing this function from the getter
  14458. handle = attrHandle[ lowercaseName ];
  14459. attrHandle[ lowercaseName ] = ret;
  14460. ret = getter( elem, name, isXML ) != null ?
  14461. lowercaseName :
  14462. null;
  14463. attrHandle[ lowercaseName ] = handle;
  14464. }
  14465. return ret;
  14466. };
  14467. } );
  14468. var rfocusable = /^(?:input|select|textarea|button)$/i,
  14469. rclickable = /^(?:a|area)$/i;
  14470. jQuery.fn.extend( {
  14471. prop: function( name, value ) {
  14472. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  14473. },
  14474. removeProp: function( name ) {
  14475. return this.each( function() {
  14476. delete this[ jQuery.propFix[ name ] || name ];
  14477. } );
  14478. }
  14479. } );
  14480. jQuery.extend( {
  14481. prop: function( elem, name, value ) {
  14482. var ret, hooks,
  14483. nType = elem.nodeType;
  14484. // Don't get/set properties on text, comment and attribute nodes
  14485. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14486. return;
  14487. }
  14488. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14489. // Fix name and attach hooks
  14490. name = jQuery.propFix[ name ] || name;
  14491. hooks = jQuery.propHooks[ name ];
  14492. }
  14493. if ( value !== undefined ) {
  14494. if ( hooks && "set" in hooks &&
  14495. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14496. return ret;
  14497. }
  14498. return ( elem[ name ] = value );
  14499. }
  14500. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14501. return ret;
  14502. }
  14503. return elem[ name ];
  14504. },
  14505. propHooks: {
  14506. tabIndex: {
  14507. get: function( elem ) {
  14508. // Support: IE <=9 - 11 only
  14509. // elem.tabIndex doesn't always return the
  14510. // correct value when it hasn't been explicitly set
  14511. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  14512. // Use proper attribute retrieval(#12072)
  14513. var tabindex = jQuery.find.attr( elem, "tabindex" );
  14514. if ( tabindex ) {
  14515. return parseInt( tabindex, 10 );
  14516. }
  14517. if (
  14518. rfocusable.test( elem.nodeName ) ||
  14519. rclickable.test( elem.nodeName ) &&
  14520. elem.href
  14521. ) {
  14522. return 0;
  14523. }
  14524. return -1;
  14525. }
  14526. }
  14527. },
  14528. propFix: {
  14529. "for": "htmlFor",
  14530. "class": "className"
  14531. }
  14532. } );
  14533. // Support: IE <=11 only
  14534. // Accessing the selectedIndex property
  14535. // forces the browser to respect setting selected
  14536. // on the option
  14537. // The getter ensures a default option is selected
  14538. // when in an optgroup
  14539. // eslint rule "no-unused-expressions" is disabled for this code
  14540. // since it considers such accessions noop
  14541. if ( !support.optSelected ) {
  14542. jQuery.propHooks.selected = {
  14543. get: function( elem ) {
  14544. /* eslint no-unused-expressions: "off" */
  14545. var parent = elem.parentNode;
  14546. if ( parent && parent.parentNode ) {
  14547. parent.parentNode.selectedIndex;
  14548. }
  14549. return null;
  14550. },
  14551. set: function( elem ) {
  14552. /* eslint no-unused-expressions: "off" */
  14553. var parent = elem.parentNode;
  14554. if ( parent ) {
  14555. parent.selectedIndex;
  14556. if ( parent.parentNode ) {
  14557. parent.parentNode.selectedIndex;
  14558. }
  14559. }
  14560. }
  14561. };
  14562. }
  14563. jQuery.each( [
  14564. "tabIndex",
  14565. "readOnly",
  14566. "maxLength",
  14567. "cellSpacing",
  14568. "cellPadding",
  14569. "rowSpan",
  14570. "colSpan",
  14571. "useMap",
  14572. "frameBorder",
  14573. "contentEditable"
  14574. ], function() {
  14575. jQuery.propFix[ this.toLowerCase() ] = this;
  14576. } );
  14577. // Strip and collapse whitespace according to HTML spec
  14578. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  14579. function stripAndCollapse( value ) {
  14580. var tokens = value.match( rnothtmlwhite ) || [];
  14581. return tokens.join( " " );
  14582. }
  14583. function getClass( elem ) {
  14584. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  14585. }
  14586. function classesToArray( value ) {
  14587. if ( Array.isArray( value ) ) {
  14588. return value;
  14589. }
  14590. if ( typeof value === "string" ) {
  14591. return value.match( rnothtmlwhite ) || [];
  14592. }
  14593. return [];
  14594. }
  14595. jQuery.fn.extend( {
  14596. addClass: function( value ) {
  14597. var classes, elem, cur, curValue, clazz, j, finalValue,
  14598. i = 0;
  14599. if ( isFunction( value ) ) {
  14600. return this.each( function( j ) {
  14601. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  14602. } );
  14603. }
  14604. classes = classesToArray( value );
  14605. if ( classes.length ) {
  14606. while ( ( elem = this[ i++ ] ) ) {
  14607. curValue = getClass( elem );
  14608. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14609. if ( cur ) {
  14610. j = 0;
  14611. while ( ( clazz = classes[ j++ ] ) ) {
  14612. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  14613. cur += clazz + " ";
  14614. }
  14615. }
  14616. // Only assign if different to avoid unneeded rendering.
  14617. finalValue = stripAndCollapse( cur );
  14618. if ( curValue !== finalValue ) {
  14619. elem.setAttribute( "class", finalValue );
  14620. }
  14621. }
  14622. }
  14623. }
  14624. return this;
  14625. },
  14626. removeClass: function( value ) {
  14627. var classes, elem, cur, curValue, clazz, j, finalValue,
  14628. i = 0;
  14629. if ( isFunction( value ) ) {
  14630. return this.each( function( j ) {
  14631. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  14632. } );
  14633. }
  14634. if ( !arguments.length ) {
  14635. return this.attr( "class", "" );
  14636. }
  14637. classes = classesToArray( value );
  14638. if ( classes.length ) {
  14639. while ( ( elem = this[ i++ ] ) ) {
  14640. curValue = getClass( elem );
  14641. // This expression is here for better compressibility (see addClass)
  14642. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14643. if ( cur ) {
  14644. j = 0;
  14645. while ( ( clazz = classes[ j++ ] ) ) {
  14646. // Remove *all* instances
  14647. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  14648. cur = cur.replace( " " + clazz + " ", " " );
  14649. }
  14650. }
  14651. // Only assign if different to avoid unneeded rendering.
  14652. finalValue = stripAndCollapse( cur );
  14653. if ( curValue !== finalValue ) {
  14654. elem.setAttribute( "class", finalValue );
  14655. }
  14656. }
  14657. }
  14658. }
  14659. return this;
  14660. },
  14661. toggleClass: function( value, stateVal ) {
  14662. var type = typeof value,
  14663. isValidValue = type === "string" || Array.isArray( value );
  14664. if ( typeof stateVal === "boolean" && isValidValue ) {
  14665. return stateVal ? this.addClass( value ) : this.removeClass( value );
  14666. }
  14667. if ( isFunction( value ) ) {
  14668. return this.each( function( i ) {
  14669. jQuery( this ).toggleClass(
  14670. value.call( this, i, getClass( this ), stateVal ),
  14671. stateVal
  14672. );
  14673. } );
  14674. }
  14675. return this.each( function() {
  14676. var className, i, self, classNames;
  14677. if ( isValidValue ) {
  14678. // Toggle individual class names
  14679. i = 0;
  14680. self = jQuery( this );
  14681. classNames = classesToArray( value );
  14682. while ( ( className = classNames[ i++ ] ) ) {
  14683. // Check each className given, space separated list
  14684. if ( self.hasClass( className ) ) {
  14685. self.removeClass( className );
  14686. } else {
  14687. self.addClass( className );
  14688. }
  14689. }
  14690. // Toggle whole class name
  14691. } else if ( value === undefined || type === "boolean" ) {
  14692. className = getClass( this );
  14693. if ( className ) {
  14694. // Store className if set
  14695. dataPriv.set( this, "__className__", className );
  14696. }
  14697. // If the element has a class name or if we're passed `false`,
  14698. // then remove the whole classname (if there was one, the above saved it).
  14699. // Otherwise bring back whatever was previously saved (if anything),
  14700. // falling back to the empty string if nothing was stored.
  14701. if ( this.setAttribute ) {
  14702. this.setAttribute( "class",
  14703. className || value === false ?
  14704. "" :
  14705. dataPriv.get( this, "__className__" ) || ""
  14706. );
  14707. }
  14708. }
  14709. } );
  14710. },
  14711. hasClass: function( selector ) {
  14712. var className, elem,
  14713. i = 0;
  14714. className = " " + selector + " ";
  14715. while ( ( elem = this[ i++ ] ) ) {
  14716. if ( elem.nodeType === 1 &&
  14717. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  14718. return true;
  14719. }
  14720. }
  14721. return false;
  14722. }
  14723. } );
  14724. var rreturn = /\r/g;
  14725. jQuery.fn.extend( {
  14726. val: function( value ) {
  14727. var hooks, ret, valueIsFunction,
  14728. elem = this[ 0 ];
  14729. if ( !arguments.length ) {
  14730. if ( elem ) {
  14731. hooks = jQuery.valHooks[ elem.type ] ||
  14732. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  14733. if ( hooks &&
  14734. "get" in hooks &&
  14735. ( ret = hooks.get( elem, "value" ) ) !== undefined
  14736. ) {
  14737. return ret;
  14738. }
  14739. ret = elem.value;
  14740. // Handle most common string cases
  14741. if ( typeof ret === "string" ) {
  14742. return ret.replace( rreturn, "" );
  14743. }
  14744. // Handle cases where value is null/undef or number
  14745. return ret == null ? "" : ret;
  14746. }
  14747. return;
  14748. }
  14749. valueIsFunction = isFunction( value );
  14750. return this.each( function( i ) {
  14751. var val;
  14752. if ( this.nodeType !== 1 ) {
  14753. return;
  14754. }
  14755. if ( valueIsFunction ) {
  14756. val = value.call( this, i, jQuery( this ).val() );
  14757. } else {
  14758. val = value;
  14759. }
  14760. // Treat null/undefined as ""; convert numbers to string
  14761. if ( val == null ) {
  14762. val = "";
  14763. } else if ( typeof val === "number" ) {
  14764. val += "";
  14765. } else if ( Array.isArray( val ) ) {
  14766. val = jQuery.map( val, function( value ) {
  14767. return value == null ? "" : value + "";
  14768. } );
  14769. }
  14770. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  14771. // If set returns undefined, fall back to normal setting
  14772. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  14773. this.value = val;
  14774. }
  14775. } );
  14776. }
  14777. } );
  14778. jQuery.extend( {
  14779. valHooks: {
  14780. option: {
  14781. get: function( elem ) {
  14782. var val = jQuery.find.attr( elem, "value" );
  14783. return val != null ?
  14784. val :
  14785. // Support: IE <=10 - 11 only
  14786. // option.text throws exceptions (#14686, #14858)
  14787. // Strip and collapse whitespace
  14788. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  14789. stripAndCollapse( jQuery.text( elem ) );
  14790. }
  14791. },
  14792. select: {
  14793. get: function( elem ) {
  14794. var value, option, i,
  14795. options = elem.options,
  14796. index = elem.selectedIndex,
  14797. one = elem.type === "select-one",
  14798. values = one ? null : [],
  14799. max = one ? index + 1 : options.length;
  14800. if ( index < 0 ) {
  14801. i = max;
  14802. } else {
  14803. i = one ? index : 0;
  14804. }
  14805. // Loop through all the selected options
  14806. for ( ; i < max; i++ ) {
  14807. option = options[ i ];
  14808. // Support: IE <=9 only
  14809. // IE8-9 doesn't update selected after form reset (#2551)
  14810. if ( ( option.selected || i === index ) &&
  14811. // Don't return options that are disabled or in a disabled optgroup
  14812. !option.disabled &&
  14813. ( !option.parentNode.disabled ||
  14814. !nodeName( option.parentNode, "optgroup" ) ) ) {
  14815. // Get the specific value for the option
  14816. value = jQuery( option ).val();
  14817. // We don't need an array for one selects
  14818. if ( one ) {
  14819. return value;
  14820. }
  14821. // Multi-Selects return an array
  14822. values.push( value );
  14823. }
  14824. }
  14825. return values;
  14826. },
  14827. set: function( elem, value ) {
  14828. var optionSet, option,
  14829. options = elem.options,
  14830. values = jQuery.makeArray( value ),
  14831. i = options.length;
  14832. while ( i-- ) {
  14833. option = options[ i ];
  14834. /* eslint-disable no-cond-assign */
  14835. if ( option.selected =
  14836. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  14837. ) {
  14838. optionSet = true;
  14839. }
  14840. /* eslint-enable no-cond-assign */
  14841. }
  14842. // Force browsers to behave consistently when non-matching value is set
  14843. if ( !optionSet ) {
  14844. elem.selectedIndex = -1;
  14845. }
  14846. return values;
  14847. }
  14848. }
  14849. }
  14850. } );
  14851. // Radios and checkboxes getter/setter
  14852. jQuery.each( [ "radio", "checkbox" ], function() {
  14853. jQuery.valHooks[ this ] = {
  14854. set: function( elem, value ) {
  14855. if ( Array.isArray( value ) ) {
  14856. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  14857. }
  14858. }
  14859. };
  14860. if ( !support.checkOn ) {
  14861. jQuery.valHooks[ this ].get = function( elem ) {
  14862. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  14863. };
  14864. }
  14865. } );
  14866. // Return jQuery for attributes-only inclusion
  14867. support.focusin = "onfocusin" in window;
  14868. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  14869. stopPropagationCallback = function( e ) {
  14870. e.stopPropagation();
  14871. };
  14872. jQuery.extend( jQuery.event, {
  14873. trigger: function( event, data, elem, onlyHandlers ) {
  14874. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  14875. eventPath = [ elem || document ],
  14876. type = hasOwn.call( event, "type" ) ? event.type : event,
  14877. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  14878. cur = lastElement = tmp = elem = elem || document;
  14879. // Don't do events on text and comment nodes
  14880. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  14881. return;
  14882. }
  14883. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  14884. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  14885. return;
  14886. }
  14887. if ( type.indexOf( "." ) > -1 ) {
  14888. // Namespaced trigger; create a regexp to match event type in handle()
  14889. namespaces = type.split( "." );
  14890. type = namespaces.shift();
  14891. namespaces.sort();
  14892. }
  14893. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  14894. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  14895. event = event[ jQuery.expando ] ?
  14896. event :
  14897. new jQuery.Event( type, typeof event === "object" && event );
  14898. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  14899. event.isTrigger = onlyHandlers ? 2 : 3;
  14900. event.namespace = namespaces.join( "." );
  14901. event.rnamespace = event.namespace ?
  14902. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  14903. null;
  14904. // Clean up the event in case it is being reused
  14905. event.result = undefined;
  14906. if ( !event.target ) {
  14907. event.target = elem;
  14908. }
  14909. // Clone any incoming data and prepend the event, creating the handler arg list
  14910. data = data == null ?
  14911. [ event ] :
  14912. jQuery.makeArray( data, [ event ] );
  14913. // Allow special events to draw outside the lines
  14914. special = jQuery.event.special[ type ] || {};
  14915. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  14916. return;
  14917. }
  14918. // Determine event propagation path in advance, per W3C events spec (#9951)
  14919. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  14920. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  14921. bubbleType = special.delegateType || type;
  14922. if ( !rfocusMorph.test( bubbleType + type ) ) {
  14923. cur = cur.parentNode;
  14924. }
  14925. for ( ; cur; cur = cur.parentNode ) {
  14926. eventPath.push( cur );
  14927. tmp = cur;
  14928. }
  14929. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  14930. if ( tmp === ( elem.ownerDocument || document ) ) {
  14931. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  14932. }
  14933. }
  14934. // Fire handlers on the event path
  14935. i = 0;
  14936. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  14937. lastElement = cur;
  14938. event.type = i > 1 ?
  14939. bubbleType :
  14940. special.bindType || type;
  14941. // jQuery handler
  14942. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  14943. dataPriv.get( cur, "handle" );
  14944. if ( handle ) {
  14945. handle.apply( cur, data );
  14946. }
  14947. // Native handler
  14948. handle = ontype && cur[ ontype ];
  14949. if ( handle && handle.apply && acceptData( cur ) ) {
  14950. event.result = handle.apply( cur, data );
  14951. if ( event.result === false ) {
  14952. event.preventDefault();
  14953. }
  14954. }
  14955. }
  14956. event.type = type;
  14957. // If nobody prevented the default action, do it now
  14958. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  14959. if ( ( !special._default ||
  14960. special._default.apply( eventPath.pop(), data ) === false ) &&
  14961. acceptData( elem ) ) {
  14962. // Call a native DOM method on the target with the same name as the event.
  14963. // Don't do default actions on window, that's where global variables be (#6170)
  14964. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  14965. // Don't re-trigger an onFOO event when we call its FOO() method
  14966. tmp = elem[ ontype ];
  14967. if ( tmp ) {
  14968. elem[ ontype ] = null;
  14969. }
  14970. // Prevent re-triggering of the same event, since we already bubbled it above
  14971. jQuery.event.triggered = type;
  14972. if ( event.isPropagationStopped() ) {
  14973. lastElement.addEventListener( type, stopPropagationCallback );
  14974. }
  14975. elem[ type ]();
  14976. if ( event.isPropagationStopped() ) {
  14977. lastElement.removeEventListener( type, stopPropagationCallback );
  14978. }
  14979. jQuery.event.triggered = undefined;
  14980. if ( tmp ) {
  14981. elem[ ontype ] = tmp;
  14982. }
  14983. }
  14984. }
  14985. }
  14986. return event.result;
  14987. },
  14988. // Piggyback on a donor event to simulate a different one
  14989. // Used only for `focus(in | out)` events
  14990. simulate: function( type, elem, event ) {
  14991. var e = jQuery.extend(
  14992. new jQuery.Event(),
  14993. event,
  14994. {
  14995. type: type,
  14996. isSimulated: true
  14997. }
  14998. );
  14999. jQuery.event.trigger( e, null, elem );
  15000. }
  15001. } );
  15002. jQuery.fn.extend( {
  15003. trigger: function( type, data ) {
  15004. return this.each( function() {
  15005. jQuery.event.trigger( type, data, this );
  15006. } );
  15007. },
  15008. triggerHandler: function( type, data ) {
  15009. var elem = this[ 0 ];
  15010. if ( elem ) {
  15011. return jQuery.event.trigger( type, data, elem, true );
  15012. }
  15013. }
  15014. } );
  15015. // Support: Firefox <=44
  15016. // Firefox doesn't have focus(in | out) events
  15017. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  15018. //
  15019. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  15020. // focus(in | out) events fire after focus & blur events,
  15021. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  15022. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  15023. if ( !support.focusin ) {
  15024. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  15025. // Attach a single capturing handler on the document while someone wants focusin/focusout
  15026. var handler = function( event ) {
  15027. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  15028. };
  15029. jQuery.event.special[ fix ] = {
  15030. setup: function() {
  15031. var doc = this.ownerDocument || this,
  15032. attaches = dataPriv.access( doc, fix );
  15033. if ( !attaches ) {
  15034. doc.addEventListener( orig, handler, true );
  15035. }
  15036. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  15037. },
  15038. teardown: function() {
  15039. var doc = this.ownerDocument || this,
  15040. attaches = dataPriv.access( doc, fix ) - 1;
  15041. if ( !attaches ) {
  15042. doc.removeEventListener( orig, handler, true );
  15043. dataPriv.remove( doc, fix );
  15044. } else {
  15045. dataPriv.access( doc, fix, attaches );
  15046. }
  15047. }
  15048. };
  15049. } );
  15050. }
  15051. var location = window.location;
  15052. var nonce = Date.now();
  15053. var rquery = ( /\?/ );
  15054. // Cross-browser xml parsing
  15055. jQuery.parseXML = function( data ) {
  15056. var xml;
  15057. if ( !data || typeof data !== "string" ) {
  15058. return null;
  15059. }
  15060. // Support: IE 9 - 11 only
  15061. // IE throws on parseFromString with invalid input.
  15062. try {
  15063. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  15064. } catch ( e ) {
  15065. xml = undefined;
  15066. }
  15067. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  15068. jQuery.error( "Invalid XML: " + data );
  15069. }
  15070. return xml;
  15071. };
  15072. var
  15073. rbracket = /\[\]$/,
  15074. rCRLF = /\r?\n/g,
  15075. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  15076. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  15077. function buildParams( prefix, obj, traditional, add ) {
  15078. var name;
  15079. if ( Array.isArray( obj ) ) {
  15080. // Serialize array item.
  15081. jQuery.each( obj, function( i, v ) {
  15082. if ( traditional || rbracket.test( prefix ) ) {
  15083. // Treat each array item as a scalar.
  15084. add( prefix, v );
  15085. } else {
  15086. // Item is non-scalar (array or object), encode its numeric index.
  15087. buildParams(
  15088. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  15089. v,
  15090. traditional,
  15091. add
  15092. );
  15093. }
  15094. } );
  15095. } else if ( !traditional && toType( obj ) === "object" ) {
  15096. // Serialize object item.
  15097. for ( name in obj ) {
  15098. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  15099. }
  15100. } else {
  15101. // Serialize scalar item.
  15102. add( prefix, obj );
  15103. }
  15104. }
  15105. // Serialize an array of form elements or a set of
  15106. // key/values into a query string
  15107. jQuery.param = function( a, traditional ) {
  15108. var prefix,
  15109. s = [],
  15110. add = function( key, valueOrFunction ) {
  15111. // If value is a function, invoke it and use its return value
  15112. var value = isFunction( valueOrFunction ) ?
  15113. valueOrFunction() :
  15114. valueOrFunction;
  15115. s[ s.length ] = encodeURIComponent( key ) + "=" +
  15116. encodeURIComponent( value == null ? "" : value );
  15117. };
  15118. if ( a == null ) {
  15119. return "";
  15120. }
  15121. // If an array was passed in, assume that it is an array of form elements.
  15122. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  15123. // Serialize the form elements
  15124. jQuery.each( a, function() {
  15125. add( this.name, this.value );
  15126. } );
  15127. } else {
  15128. // If traditional, encode the "old" way (the way 1.3.2 or older
  15129. // did it), otherwise encode params recursively.
  15130. for ( prefix in a ) {
  15131. buildParams( prefix, a[ prefix ], traditional, add );
  15132. }
  15133. }
  15134. // Return the resulting serialization
  15135. return s.join( "&" );
  15136. };
  15137. jQuery.fn.extend( {
  15138. serialize: function() {
  15139. return jQuery.param( this.serializeArray() );
  15140. },
  15141. serializeArray: function() {
  15142. return this.map( function() {
  15143. // Can add propHook for "elements" to filter or add form elements
  15144. var elements = jQuery.prop( this, "elements" );
  15145. return elements ? jQuery.makeArray( elements ) : this;
  15146. } )
  15147. .filter( function() {
  15148. var type = this.type;
  15149. // Use .is( ":disabled" ) so that fieldset[disabled] works
  15150. return this.name && !jQuery( this ).is( ":disabled" ) &&
  15151. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  15152. ( this.checked || !rcheckableType.test( type ) );
  15153. } )
  15154. .map( function( i, elem ) {
  15155. var val = jQuery( this ).val();
  15156. if ( val == null ) {
  15157. return null;
  15158. }
  15159. if ( Array.isArray( val ) ) {
  15160. return jQuery.map( val, function( val ) {
  15161. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15162. } );
  15163. }
  15164. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15165. } ).get();
  15166. }
  15167. } );
  15168. var
  15169. r20 = /%20/g,
  15170. rhash = /#.*$/,
  15171. rantiCache = /([?&])_=[^&]*/,
  15172. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  15173. // #7653, #8125, #8152: local protocol detection
  15174. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  15175. rnoContent = /^(?:GET|HEAD)$/,
  15176. rprotocol = /^\/\//,
  15177. /* Prefilters
  15178. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  15179. * 2) These are called:
  15180. * - BEFORE asking for a transport
  15181. * - AFTER param serialization (s.data is a string if s.processData is true)
  15182. * 3) key is the dataType
  15183. * 4) the catchall symbol "*" can be used
  15184. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  15185. */
  15186. prefilters = {},
  15187. /* Transports bindings
  15188. * 1) key is the dataType
  15189. * 2) the catchall symbol "*" can be used
  15190. * 3) selection will start with transport dataType and THEN go to "*" if needed
  15191. */
  15192. transports = {},
  15193. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  15194. allTypes = "*/".concat( "*" ),
  15195. // Anchor tag for parsing the document origin
  15196. originAnchor = document.createElement( "a" );
  15197. originAnchor.href = location.href;
  15198. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  15199. function addToPrefiltersOrTransports( structure ) {
  15200. // dataTypeExpression is optional and defaults to "*"
  15201. return function( dataTypeExpression, func ) {
  15202. if ( typeof dataTypeExpression !== "string" ) {
  15203. func = dataTypeExpression;
  15204. dataTypeExpression = "*";
  15205. }
  15206. var dataType,
  15207. i = 0,
  15208. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  15209. if ( isFunction( func ) ) {
  15210. // For each dataType in the dataTypeExpression
  15211. while ( ( dataType = dataTypes[ i++ ] ) ) {
  15212. // Prepend if requested
  15213. if ( dataType[ 0 ] === "+" ) {
  15214. dataType = dataType.slice( 1 ) || "*";
  15215. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  15216. // Otherwise append
  15217. } else {
  15218. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  15219. }
  15220. }
  15221. }
  15222. };
  15223. }
  15224. // Base inspection function for prefilters and transports
  15225. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  15226. var inspected = {},
  15227. seekingTransport = ( structure === transports );
  15228. function inspect( dataType ) {
  15229. var selected;
  15230. inspected[ dataType ] = true;
  15231. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  15232. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  15233. if ( typeof dataTypeOrTransport === "string" &&
  15234. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  15235. options.dataTypes.unshift( dataTypeOrTransport );
  15236. inspect( dataTypeOrTransport );
  15237. return false;
  15238. } else if ( seekingTransport ) {
  15239. return !( selected = dataTypeOrTransport );
  15240. }
  15241. } );
  15242. return selected;
  15243. }
  15244. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  15245. }
  15246. // A special extend for ajax options
  15247. // that takes "flat" options (not to be deep extended)
  15248. // Fixes #9887
  15249. function ajaxExtend( target, src ) {
  15250. var key, deep,
  15251. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  15252. for ( key in src ) {
  15253. if ( src[ key ] !== undefined ) {
  15254. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  15255. }
  15256. }
  15257. if ( deep ) {
  15258. jQuery.extend( true, target, deep );
  15259. }
  15260. return target;
  15261. }
  15262. /* Handles responses to an ajax request:
  15263. * - finds the right dataType (mediates between content-type and expected dataType)
  15264. * - returns the corresponding response
  15265. */
  15266. function ajaxHandleResponses( s, jqXHR, responses ) {
  15267. var ct, type, finalDataType, firstDataType,
  15268. contents = s.contents,
  15269. dataTypes = s.dataTypes;
  15270. // Remove auto dataType and get content-type in the process
  15271. while ( dataTypes[ 0 ] === "*" ) {
  15272. dataTypes.shift();
  15273. if ( ct === undefined ) {
  15274. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  15275. }
  15276. }
  15277. // Check if we're dealing with a known content-type
  15278. if ( ct ) {
  15279. for ( type in contents ) {
  15280. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  15281. dataTypes.unshift( type );
  15282. break;
  15283. }
  15284. }
  15285. }
  15286. // Check to see if we have a response for the expected dataType
  15287. if ( dataTypes[ 0 ] in responses ) {
  15288. finalDataType = dataTypes[ 0 ];
  15289. } else {
  15290. // Try convertible dataTypes
  15291. for ( type in responses ) {
  15292. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  15293. finalDataType = type;
  15294. break;
  15295. }
  15296. if ( !firstDataType ) {
  15297. firstDataType = type;
  15298. }
  15299. }
  15300. // Or just use first one
  15301. finalDataType = finalDataType || firstDataType;
  15302. }
  15303. // If we found a dataType
  15304. // We add the dataType to the list if needed
  15305. // and return the corresponding response
  15306. if ( finalDataType ) {
  15307. if ( finalDataType !== dataTypes[ 0 ] ) {
  15308. dataTypes.unshift( finalDataType );
  15309. }
  15310. return responses[ finalDataType ];
  15311. }
  15312. }
  15313. /* Chain conversions given the request and the original response
  15314. * Also sets the responseXXX fields on the jqXHR instance
  15315. */
  15316. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  15317. var conv2, current, conv, tmp, prev,
  15318. converters = {},
  15319. // Work with a copy of dataTypes in case we need to modify it for conversion
  15320. dataTypes = s.dataTypes.slice();
  15321. // Create converters map with lowercased keys
  15322. if ( dataTypes[ 1 ] ) {
  15323. for ( conv in s.converters ) {
  15324. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  15325. }
  15326. }
  15327. current = dataTypes.shift();
  15328. // Convert to each sequential dataType
  15329. while ( current ) {
  15330. if ( s.responseFields[ current ] ) {
  15331. jqXHR[ s.responseFields[ current ] ] = response;
  15332. }
  15333. // Apply the dataFilter if provided
  15334. if ( !prev && isSuccess && s.dataFilter ) {
  15335. response = s.dataFilter( response, s.dataType );
  15336. }
  15337. prev = current;
  15338. current = dataTypes.shift();
  15339. if ( current ) {
  15340. // There's only work to do if current dataType is non-auto
  15341. if ( current === "*" ) {
  15342. current = prev;
  15343. // Convert response if prev dataType is non-auto and differs from current
  15344. } else if ( prev !== "*" && prev !== current ) {
  15345. // Seek a direct converter
  15346. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  15347. // If none found, seek a pair
  15348. if ( !conv ) {
  15349. for ( conv2 in converters ) {
  15350. // If conv2 outputs current
  15351. tmp = conv2.split( " " );
  15352. if ( tmp[ 1 ] === current ) {
  15353. // If prev can be converted to accepted input
  15354. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  15355. converters[ "* " + tmp[ 0 ] ];
  15356. if ( conv ) {
  15357. // Condense equivalence converters
  15358. if ( conv === true ) {
  15359. conv = converters[ conv2 ];
  15360. // Otherwise, insert the intermediate dataType
  15361. } else if ( converters[ conv2 ] !== true ) {
  15362. current = tmp[ 0 ];
  15363. dataTypes.unshift( tmp[ 1 ] );
  15364. }
  15365. break;
  15366. }
  15367. }
  15368. }
  15369. }
  15370. // Apply converter (if not an equivalence)
  15371. if ( conv !== true ) {
  15372. // Unless errors are allowed to bubble, catch and return them
  15373. if ( conv && s.throws ) {
  15374. response = conv( response );
  15375. } else {
  15376. try {
  15377. response = conv( response );
  15378. } catch ( e ) {
  15379. return {
  15380. state: "parsererror",
  15381. error: conv ? e : "No conversion from " + prev + " to " + current
  15382. };
  15383. }
  15384. }
  15385. }
  15386. }
  15387. }
  15388. }
  15389. return { state: "success", data: response };
  15390. }
  15391. jQuery.extend( {
  15392. // Counter for holding the number of active queries
  15393. active: 0,
  15394. // Last-Modified header cache for next request
  15395. lastModified: {},
  15396. etag: {},
  15397. ajaxSettings: {
  15398. url: location.href,
  15399. type: "GET",
  15400. isLocal: rlocalProtocol.test( location.protocol ),
  15401. global: true,
  15402. processData: true,
  15403. async: true,
  15404. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  15405. /*
  15406. timeout: 0,
  15407. data: null,
  15408. dataType: null,
  15409. username: null,
  15410. password: null,
  15411. cache: null,
  15412. throws: false,
  15413. traditional: false,
  15414. headers: {},
  15415. */
  15416. accepts: {
  15417. "*": allTypes,
  15418. text: "text/plain",
  15419. html: "text/html",
  15420. xml: "application/xml, text/xml",
  15421. json: "application/json, text/javascript"
  15422. },
  15423. contents: {
  15424. xml: /\bxml\b/,
  15425. html: /\bhtml/,
  15426. json: /\bjson\b/
  15427. },
  15428. responseFields: {
  15429. xml: "responseXML",
  15430. text: "responseText",
  15431. json: "responseJSON"
  15432. },
  15433. // Data converters
  15434. // Keys separate source (or catchall "*") and destination types with a single space
  15435. converters: {
  15436. // Convert anything to text
  15437. "* text": String,
  15438. // Text to html (true = no transformation)
  15439. "text html": true,
  15440. // Evaluate text as a json expression
  15441. "text json": JSON.parse,
  15442. // Parse text as xml
  15443. "text xml": jQuery.parseXML
  15444. },
  15445. // For options that shouldn't be deep extended:
  15446. // you can add your own custom options here if
  15447. // and when you create one that shouldn't be
  15448. // deep extended (see ajaxExtend)
  15449. flatOptions: {
  15450. url: true,
  15451. context: true
  15452. }
  15453. },
  15454. // Creates a full fledged settings object into target
  15455. // with both ajaxSettings and settings fields.
  15456. // If target is omitted, writes into ajaxSettings.
  15457. ajaxSetup: function( target, settings ) {
  15458. return settings ?
  15459. // Building a settings object
  15460. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  15461. // Extending ajaxSettings
  15462. ajaxExtend( jQuery.ajaxSettings, target );
  15463. },
  15464. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  15465. ajaxTransport: addToPrefiltersOrTransports( transports ),
  15466. // Main method
  15467. ajax: function( url, options ) {
  15468. // If url is an object, simulate pre-1.5 signature
  15469. if ( typeof url === "object" ) {
  15470. options = url;
  15471. url = undefined;
  15472. }
  15473. // Force options to be an object
  15474. options = options || {};
  15475. var transport,
  15476. // URL without anti-cache param
  15477. cacheURL,
  15478. // Response headers
  15479. responseHeadersString,
  15480. responseHeaders,
  15481. // timeout handle
  15482. timeoutTimer,
  15483. // Url cleanup var
  15484. urlAnchor,
  15485. // Request state (becomes false upon send and true upon completion)
  15486. completed,
  15487. // To know if global events are to be dispatched
  15488. fireGlobals,
  15489. // Loop variable
  15490. i,
  15491. // uncached part of the url
  15492. uncached,
  15493. // Create the final options object
  15494. s = jQuery.ajaxSetup( {}, options ),
  15495. // Callbacks context
  15496. callbackContext = s.context || s,
  15497. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  15498. globalEventContext = s.context &&
  15499. ( callbackContext.nodeType || callbackContext.jquery ) ?
  15500. jQuery( callbackContext ) :
  15501. jQuery.event,
  15502. // Deferreds
  15503. deferred = jQuery.Deferred(),
  15504. completeDeferred = jQuery.Callbacks( "once memory" ),
  15505. // Status-dependent callbacks
  15506. statusCode = s.statusCode || {},
  15507. // Headers (they are sent all at once)
  15508. requestHeaders = {},
  15509. requestHeadersNames = {},
  15510. // Default abort message
  15511. strAbort = "canceled",
  15512. // Fake xhr
  15513. jqXHR = {
  15514. readyState: 0,
  15515. // Builds headers hashtable if needed
  15516. getResponseHeader: function( key ) {
  15517. var match;
  15518. if ( completed ) {
  15519. if ( !responseHeaders ) {
  15520. responseHeaders = {};
  15521. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  15522. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  15523. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  15524. .concat( match[ 2 ] );
  15525. }
  15526. }
  15527. match = responseHeaders[ key.toLowerCase() + " " ];
  15528. }
  15529. return match == null ? null : match.join( ", " );
  15530. },
  15531. // Raw string
  15532. getAllResponseHeaders: function() {
  15533. return completed ? responseHeadersString : null;
  15534. },
  15535. // Caches the header
  15536. setRequestHeader: function( name, value ) {
  15537. if ( completed == null ) {
  15538. name = requestHeadersNames[ name.toLowerCase() ] =
  15539. requestHeadersNames[ name.toLowerCase() ] || name;
  15540. requestHeaders[ name ] = value;
  15541. }
  15542. return this;
  15543. },
  15544. // Overrides response content-type header
  15545. overrideMimeType: function( type ) {
  15546. if ( completed == null ) {
  15547. s.mimeType = type;
  15548. }
  15549. return this;
  15550. },
  15551. // Status-dependent callbacks
  15552. statusCode: function( map ) {
  15553. var code;
  15554. if ( map ) {
  15555. if ( completed ) {
  15556. // Execute the appropriate callbacks
  15557. jqXHR.always( map[ jqXHR.status ] );
  15558. } else {
  15559. // Lazy-add the new callbacks in a way that preserves old ones
  15560. for ( code in map ) {
  15561. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  15562. }
  15563. }
  15564. }
  15565. return this;
  15566. },
  15567. // Cancel the request
  15568. abort: function( statusText ) {
  15569. var finalText = statusText || strAbort;
  15570. if ( transport ) {
  15571. transport.abort( finalText );
  15572. }
  15573. done( 0, finalText );
  15574. return this;
  15575. }
  15576. };
  15577. // Attach deferreds
  15578. deferred.promise( jqXHR );
  15579. // Add protocol if not provided (prefilters might expect it)
  15580. // Handle falsy url in the settings object (#10093: consistency with old signature)
  15581. // We also use the url parameter if available
  15582. s.url = ( ( url || s.url || location.href ) + "" )
  15583. .replace( rprotocol, location.protocol + "//" );
  15584. // Alias method option to type as per ticket #12004
  15585. s.type = options.method || options.type || s.method || s.type;
  15586. // Extract dataTypes list
  15587. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  15588. // A cross-domain request is in order when the origin doesn't match the current origin.
  15589. if ( s.crossDomain == null ) {
  15590. urlAnchor = document.createElement( "a" );
  15591. // Support: IE <=8 - 11, Edge 12 - 15
  15592. // IE throws exception on accessing the href property if url is malformed,
  15593. // e.g. http://example.com:80x/
  15594. try {
  15595. urlAnchor.href = s.url;
  15596. // Support: IE <=8 - 11 only
  15597. // Anchor's host property isn't correctly set when s.url is relative
  15598. urlAnchor.href = urlAnchor.href;
  15599. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  15600. urlAnchor.protocol + "//" + urlAnchor.host;
  15601. } catch ( e ) {
  15602. // If there is an error parsing the URL, assume it is crossDomain,
  15603. // it can be rejected by the transport if it is invalid
  15604. s.crossDomain = true;
  15605. }
  15606. }
  15607. // Convert data if not already a string
  15608. if ( s.data && s.processData && typeof s.data !== "string" ) {
  15609. s.data = jQuery.param( s.data, s.traditional );
  15610. }
  15611. // Apply prefilters
  15612. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  15613. // If request was aborted inside a prefilter, stop there
  15614. if ( completed ) {
  15615. return jqXHR;
  15616. }
  15617. // We can fire global events as of now if asked to
  15618. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  15619. fireGlobals = jQuery.event && s.global;
  15620. // Watch for a new set of requests
  15621. if ( fireGlobals && jQuery.active++ === 0 ) {
  15622. jQuery.event.trigger( "ajaxStart" );
  15623. }
  15624. // Uppercase the type
  15625. s.type = s.type.toUpperCase();
  15626. // Determine if request has content
  15627. s.hasContent = !rnoContent.test( s.type );
  15628. // Save the URL in case we're toying with the If-Modified-Since
  15629. // and/or If-None-Match header later on
  15630. // Remove hash to simplify url manipulation
  15631. cacheURL = s.url.replace( rhash, "" );
  15632. // More options handling for requests with no content
  15633. if ( !s.hasContent ) {
  15634. // Remember the hash so we can put it back
  15635. uncached = s.url.slice( cacheURL.length );
  15636. // If data is available and should be processed, append data to url
  15637. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  15638. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  15639. // #9682: remove data so that it's not used in an eventual retry
  15640. delete s.data;
  15641. }
  15642. // Add or update anti-cache param if needed
  15643. if ( s.cache === false ) {
  15644. cacheURL = cacheURL.replace( rantiCache, "$1" );
  15645. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  15646. }
  15647. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  15648. s.url = cacheURL + uncached;
  15649. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  15650. } else if ( s.data && s.processData &&
  15651. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  15652. s.data = s.data.replace( r20, "+" );
  15653. }
  15654. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15655. if ( s.ifModified ) {
  15656. if ( jQuery.lastModified[ cacheURL ] ) {
  15657. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  15658. }
  15659. if ( jQuery.etag[ cacheURL ] ) {
  15660. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  15661. }
  15662. }
  15663. // Set the correct header, if data is being sent
  15664. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  15665. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  15666. }
  15667. // Set the Accepts header for the server, depending on the dataType
  15668. jqXHR.setRequestHeader(
  15669. "Accept",
  15670. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  15671. s.accepts[ s.dataTypes[ 0 ] ] +
  15672. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  15673. s.accepts[ "*" ]
  15674. );
  15675. // Check for headers option
  15676. for ( i in s.headers ) {
  15677. jqXHR.setRequestHeader( i, s.headers[ i ] );
  15678. }
  15679. // Allow custom headers/mimetypes and early abort
  15680. if ( s.beforeSend &&
  15681. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  15682. // Abort if not done already and return
  15683. return jqXHR.abort();
  15684. }
  15685. // Aborting is no longer a cancellation
  15686. strAbort = "abort";
  15687. // Install callbacks on deferreds
  15688. completeDeferred.add( s.complete );
  15689. jqXHR.done( s.success );
  15690. jqXHR.fail( s.error );
  15691. // Get transport
  15692. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  15693. // If no transport, we auto-abort
  15694. if ( !transport ) {
  15695. done( -1, "No Transport" );
  15696. } else {
  15697. jqXHR.readyState = 1;
  15698. // Send global event
  15699. if ( fireGlobals ) {
  15700. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  15701. }
  15702. // If request was aborted inside ajaxSend, stop there
  15703. if ( completed ) {
  15704. return jqXHR;
  15705. }
  15706. // Timeout
  15707. if ( s.async && s.timeout > 0 ) {
  15708. timeoutTimer = window.setTimeout( function() {
  15709. jqXHR.abort( "timeout" );
  15710. }, s.timeout );
  15711. }
  15712. try {
  15713. completed = false;
  15714. transport.send( requestHeaders, done );
  15715. } catch ( e ) {
  15716. // Rethrow post-completion exceptions
  15717. if ( completed ) {
  15718. throw e;
  15719. }
  15720. // Propagate others as results
  15721. done( -1, e );
  15722. }
  15723. }
  15724. // Callback for when everything is done
  15725. function done( status, nativeStatusText, responses, headers ) {
  15726. var isSuccess, success, error, response, modified,
  15727. statusText = nativeStatusText;
  15728. // Ignore repeat invocations
  15729. if ( completed ) {
  15730. return;
  15731. }
  15732. completed = true;
  15733. // Clear timeout if it exists
  15734. if ( timeoutTimer ) {
  15735. window.clearTimeout( timeoutTimer );
  15736. }
  15737. // Dereference transport for early garbage collection
  15738. // (no matter how long the jqXHR object will be used)
  15739. transport = undefined;
  15740. // Cache response headers
  15741. responseHeadersString = headers || "";
  15742. // Set readyState
  15743. jqXHR.readyState = status > 0 ? 4 : 0;
  15744. // Determine if successful
  15745. isSuccess = status >= 200 && status < 300 || status === 304;
  15746. // Get response data
  15747. if ( responses ) {
  15748. response = ajaxHandleResponses( s, jqXHR, responses );
  15749. }
  15750. // Convert no matter what (that way responseXXX fields are always set)
  15751. response = ajaxConvert( s, response, jqXHR, isSuccess );
  15752. // If successful, handle type chaining
  15753. if ( isSuccess ) {
  15754. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15755. if ( s.ifModified ) {
  15756. modified = jqXHR.getResponseHeader( "Last-Modified" );
  15757. if ( modified ) {
  15758. jQuery.lastModified[ cacheURL ] = modified;
  15759. }
  15760. modified = jqXHR.getResponseHeader( "etag" );
  15761. if ( modified ) {
  15762. jQuery.etag[ cacheURL ] = modified;
  15763. }
  15764. }
  15765. // if no content
  15766. if ( status === 204 || s.type === "HEAD" ) {
  15767. statusText = "nocontent";
  15768. // if not modified
  15769. } else if ( status === 304 ) {
  15770. statusText = "notmodified";
  15771. // If we have data, let's convert it
  15772. } else {
  15773. statusText = response.state;
  15774. success = response.data;
  15775. error = response.error;
  15776. isSuccess = !error;
  15777. }
  15778. } else {
  15779. // Extract error from statusText and normalize for non-aborts
  15780. error = statusText;
  15781. if ( status || !statusText ) {
  15782. statusText = "error";
  15783. if ( status < 0 ) {
  15784. status = 0;
  15785. }
  15786. }
  15787. }
  15788. // Set data for the fake xhr object
  15789. jqXHR.status = status;
  15790. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  15791. // Success/Error
  15792. if ( isSuccess ) {
  15793. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  15794. } else {
  15795. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  15796. }
  15797. // Status-dependent callbacks
  15798. jqXHR.statusCode( statusCode );
  15799. statusCode = undefined;
  15800. if ( fireGlobals ) {
  15801. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  15802. [ jqXHR, s, isSuccess ? success : error ] );
  15803. }
  15804. // Complete
  15805. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  15806. if ( fireGlobals ) {
  15807. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  15808. // Handle the global AJAX counter
  15809. if ( !( --jQuery.active ) ) {
  15810. jQuery.event.trigger( "ajaxStop" );
  15811. }
  15812. }
  15813. }
  15814. return jqXHR;
  15815. },
  15816. getJSON: function( url, data, callback ) {
  15817. return jQuery.get( url, data, callback, "json" );
  15818. },
  15819. getScript: function( url, callback ) {
  15820. return jQuery.get( url, undefined, callback, "script" );
  15821. }
  15822. } );
  15823. jQuery.each( [ "get", "post" ], function( i, method ) {
  15824. jQuery[ method ] = function( url, data, callback, type ) {
  15825. // Shift arguments if data argument was omitted
  15826. if ( isFunction( data ) ) {
  15827. type = type || callback;
  15828. callback = data;
  15829. data = undefined;
  15830. }
  15831. // The url can be an options object (which then must have .url)
  15832. return jQuery.ajax( jQuery.extend( {
  15833. url: url,
  15834. type: method,
  15835. dataType: type,
  15836. data: data,
  15837. success: callback
  15838. }, jQuery.isPlainObject( url ) && url ) );
  15839. };
  15840. } );
  15841. jQuery._evalUrl = function( url, options ) {
  15842. return jQuery.ajax( {
  15843. url: url,
  15844. // Make this explicit, since user can override this through ajaxSetup (#11264)
  15845. type: "GET",
  15846. dataType: "script",
  15847. cache: true,
  15848. async: false,
  15849. global: false,
  15850. // Only evaluate the response if it is successful (gh-4126)
  15851. // dataFilter is not invoked for failure responses, so using it instead
  15852. // of the default converter is kludgy but it works.
  15853. converters: {
  15854. "text script": function() {}
  15855. },
  15856. dataFilter: function( response ) {
  15857. jQuery.globalEval( response, options );
  15858. }
  15859. } );
  15860. };
  15861. jQuery.fn.extend( {
  15862. wrapAll: function( html ) {
  15863. var wrap;
  15864. if ( this[ 0 ] ) {
  15865. if ( isFunction( html ) ) {
  15866. html = html.call( this[ 0 ] );
  15867. }
  15868. // The elements to wrap the target around
  15869. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  15870. if ( this[ 0 ].parentNode ) {
  15871. wrap.insertBefore( this[ 0 ] );
  15872. }
  15873. wrap.map( function() {
  15874. var elem = this;
  15875. while ( elem.firstElementChild ) {
  15876. elem = elem.firstElementChild;
  15877. }
  15878. return elem;
  15879. } ).append( this );
  15880. }
  15881. return this;
  15882. },
  15883. wrapInner: function( html ) {
  15884. if ( isFunction( html ) ) {
  15885. return this.each( function( i ) {
  15886. jQuery( this ).wrapInner( html.call( this, i ) );
  15887. } );
  15888. }
  15889. return this.each( function() {
  15890. var self = jQuery( this ),
  15891. contents = self.contents();
  15892. if ( contents.length ) {
  15893. contents.wrapAll( html );
  15894. } else {
  15895. self.append( html );
  15896. }
  15897. } );
  15898. },
  15899. wrap: function( html ) {
  15900. var htmlIsFunction = isFunction( html );
  15901. return this.each( function( i ) {
  15902. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  15903. } );
  15904. },
  15905. unwrap: function( selector ) {
  15906. this.parent( selector ).not( "body" ).each( function() {
  15907. jQuery( this ).replaceWith( this.childNodes );
  15908. } );
  15909. return this;
  15910. }
  15911. } );
  15912. jQuery.expr.pseudos.hidden = function( elem ) {
  15913. return !jQuery.expr.pseudos.visible( elem );
  15914. };
  15915. jQuery.expr.pseudos.visible = function( elem ) {
  15916. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  15917. };
  15918. jQuery.ajaxSettings.xhr = function() {
  15919. try {
  15920. return new window.XMLHttpRequest();
  15921. } catch ( e ) {}
  15922. };
  15923. var xhrSuccessStatus = {
  15924. // File protocol always yields status code 0, assume 200
  15925. 0: 200,
  15926. // Support: IE <=9 only
  15927. // #1450: sometimes IE returns 1223 when it should be 204
  15928. 1223: 204
  15929. },
  15930. xhrSupported = jQuery.ajaxSettings.xhr();
  15931. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  15932. support.ajax = xhrSupported = !!xhrSupported;
  15933. jQuery.ajaxTransport( function( options ) {
  15934. var callback, errorCallback;
  15935. // Cross domain only allowed if supported through XMLHttpRequest
  15936. if ( support.cors || xhrSupported && !options.crossDomain ) {
  15937. return {
  15938. send: function( headers, complete ) {
  15939. var i,
  15940. xhr = options.xhr();
  15941. xhr.open(
  15942. options.type,
  15943. options.url,
  15944. options.async,
  15945. options.username,
  15946. options.password
  15947. );
  15948. // Apply custom fields if provided
  15949. if ( options.xhrFields ) {
  15950. for ( i in options.xhrFields ) {
  15951. xhr[ i ] = options.xhrFields[ i ];
  15952. }
  15953. }
  15954. // Override mime type if needed
  15955. if ( options.mimeType && xhr.overrideMimeType ) {
  15956. xhr.overrideMimeType( options.mimeType );
  15957. }
  15958. // X-Requested-With header
  15959. // For cross-domain requests, seeing as conditions for a preflight are
  15960. // akin to a jigsaw puzzle, we simply never set it to be sure.
  15961. // (it can always be set on a per-request basis or even using ajaxSetup)
  15962. // For same-domain requests, won't change header if already provided.
  15963. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  15964. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  15965. }
  15966. // Set headers
  15967. for ( i in headers ) {
  15968. xhr.setRequestHeader( i, headers[ i ] );
  15969. }
  15970. // Callback
  15971. callback = function( type ) {
  15972. return function() {
  15973. if ( callback ) {
  15974. callback = errorCallback = xhr.onload =
  15975. xhr.onerror = xhr.onabort = xhr.ontimeout =
  15976. xhr.onreadystatechange = null;
  15977. if ( type === "abort" ) {
  15978. xhr.abort();
  15979. } else if ( type === "error" ) {
  15980. // Support: IE <=9 only
  15981. // On a manual native abort, IE9 throws
  15982. // errors on any property access that is not readyState
  15983. if ( typeof xhr.status !== "number" ) {
  15984. complete( 0, "error" );
  15985. } else {
  15986. complete(
  15987. // File: protocol always yields status 0; see #8605, #14207
  15988. xhr.status,
  15989. xhr.statusText
  15990. );
  15991. }
  15992. } else {
  15993. complete(
  15994. xhrSuccessStatus[ xhr.status ] || xhr.status,
  15995. xhr.statusText,
  15996. // Support: IE <=9 only
  15997. // IE9 has no XHR2 but throws on binary (trac-11426)
  15998. // For XHR2 non-text, let the caller handle it (gh-2498)
  15999. ( xhr.responseType || "text" ) !== "text" ||
  16000. typeof xhr.responseText !== "string" ?
  16001. { binary: xhr.response } :
  16002. { text: xhr.responseText },
  16003. xhr.getAllResponseHeaders()
  16004. );
  16005. }
  16006. }
  16007. };
  16008. };
  16009. // Listen to events
  16010. xhr.onload = callback();
  16011. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  16012. // Support: IE 9 only
  16013. // Use onreadystatechange to replace onabort
  16014. // to handle uncaught aborts
  16015. if ( xhr.onabort !== undefined ) {
  16016. xhr.onabort = errorCallback;
  16017. } else {
  16018. xhr.onreadystatechange = function() {
  16019. // Check readyState before timeout as it changes
  16020. if ( xhr.readyState === 4 ) {
  16021. // Allow onerror to be called first,
  16022. // but that will not handle a native abort
  16023. // Also, save errorCallback to a variable
  16024. // as xhr.onerror cannot be accessed
  16025. window.setTimeout( function() {
  16026. if ( callback ) {
  16027. errorCallback();
  16028. }
  16029. } );
  16030. }
  16031. };
  16032. }
  16033. // Create the abort callback
  16034. callback = callback( "abort" );
  16035. try {
  16036. // Do send the request (this may raise an exception)
  16037. xhr.send( options.hasContent && options.data || null );
  16038. } catch ( e ) {
  16039. // #14683: Only rethrow if this hasn't been notified as an error yet
  16040. if ( callback ) {
  16041. throw e;
  16042. }
  16043. }
  16044. },
  16045. abort: function() {
  16046. if ( callback ) {
  16047. callback();
  16048. }
  16049. }
  16050. };
  16051. }
  16052. } );
  16053. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  16054. jQuery.ajaxPrefilter( function( s ) {
  16055. if ( s.crossDomain ) {
  16056. s.contents.script = false;
  16057. }
  16058. } );
  16059. // Install script dataType
  16060. jQuery.ajaxSetup( {
  16061. accepts: {
  16062. script: "text/javascript, application/javascript, " +
  16063. "application/ecmascript, application/x-ecmascript"
  16064. },
  16065. contents: {
  16066. script: /\b(?:java|ecma)script\b/
  16067. },
  16068. converters: {
  16069. "text script": function( text ) {
  16070. jQuery.globalEval( text );
  16071. return text;
  16072. }
  16073. }
  16074. } );
  16075. // Handle cache's special case and crossDomain
  16076. jQuery.ajaxPrefilter( "script", function( s ) {
  16077. if ( s.cache === undefined ) {
  16078. s.cache = false;
  16079. }
  16080. if ( s.crossDomain ) {
  16081. s.type = "GET";
  16082. }
  16083. } );
  16084. // Bind script tag hack transport
  16085. jQuery.ajaxTransport( "script", function( s ) {
  16086. // This transport only deals with cross domain or forced-by-attrs requests
  16087. if ( s.crossDomain || s.scriptAttrs ) {
  16088. var script, callback;
  16089. return {
  16090. send: function( _, complete ) {
  16091. script = jQuery( "<script>" )
  16092. .attr( s.scriptAttrs || {} )
  16093. .prop( { charset: s.scriptCharset, src: s.url } )
  16094. .on( "load error", callback = function( evt ) {
  16095. script.remove();
  16096. callback = null;
  16097. if ( evt ) {
  16098. complete( evt.type === "error" ? 404 : 200, evt.type );
  16099. }
  16100. } );
  16101. // Use native DOM manipulation to avoid our domManip AJAX trickery
  16102. document.head.appendChild( script[ 0 ] );
  16103. },
  16104. abort: function() {
  16105. if ( callback ) {
  16106. callback();
  16107. }
  16108. }
  16109. };
  16110. }
  16111. } );
  16112. var oldCallbacks = [],
  16113. rjsonp = /(=)\?(?=&|$)|\?\?/;
  16114. // Default jsonp settings
  16115. jQuery.ajaxSetup( {
  16116. jsonp: "callback",
  16117. jsonpCallback: function() {
  16118. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  16119. this[ callback ] = true;
  16120. return callback;
  16121. }
  16122. } );
  16123. // Detect, normalize options and install callbacks for jsonp requests
  16124. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  16125. var callbackName, overwritten, responseContainer,
  16126. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  16127. "url" :
  16128. typeof s.data === "string" &&
  16129. ( s.contentType || "" )
  16130. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  16131. rjsonp.test( s.data ) && "data"
  16132. );
  16133. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  16134. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  16135. // Get callback name, remembering preexisting value associated with it
  16136. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  16137. s.jsonpCallback() :
  16138. s.jsonpCallback;
  16139. // Insert callback into url or form data
  16140. if ( jsonProp ) {
  16141. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  16142. } else if ( s.jsonp !== false ) {
  16143. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  16144. }
  16145. // Use data converter to retrieve json after script execution
  16146. s.converters[ "script json" ] = function() {
  16147. if ( !responseContainer ) {
  16148. jQuery.error( callbackName + " was not called" );
  16149. }
  16150. return responseContainer[ 0 ];
  16151. };
  16152. // Force json dataType
  16153. s.dataTypes[ 0 ] = "json";
  16154. // Install callback
  16155. overwritten = window[ callbackName ];
  16156. window[ callbackName ] = function() {
  16157. responseContainer = arguments;
  16158. };
  16159. // Clean-up function (fires after converters)
  16160. jqXHR.always( function() {
  16161. // If previous value didn't exist - remove it
  16162. if ( overwritten === undefined ) {
  16163. jQuery( window ).removeProp( callbackName );
  16164. // Otherwise restore preexisting value
  16165. } else {
  16166. window[ callbackName ] = overwritten;
  16167. }
  16168. // Save back as free
  16169. if ( s[ callbackName ] ) {
  16170. // Make sure that re-using the options doesn't screw things around
  16171. s.jsonpCallback = originalSettings.jsonpCallback;
  16172. // Save the callback name for future use
  16173. oldCallbacks.push( callbackName );
  16174. }
  16175. // Call if it was a function and we have a response
  16176. if ( responseContainer && isFunction( overwritten ) ) {
  16177. overwritten( responseContainer[ 0 ] );
  16178. }
  16179. responseContainer = overwritten = undefined;
  16180. } );
  16181. // Delegate to script
  16182. return "script";
  16183. }
  16184. } );
  16185. // Support: Safari 8 only
  16186. // In Safari 8 documents created via document.implementation.createHTMLDocument
  16187. // collapse sibling forms: the second one becomes a child of the first one.
  16188. // Because of that, this security measure has to be disabled in Safari 8.
  16189. // https://bugs.webkit.org/show_bug.cgi?id=137337
  16190. support.createHTMLDocument = ( function() {
  16191. var body = document.implementation.createHTMLDocument( "" ).body;
  16192. body.innerHTML = "<form></form><form></form>";
  16193. return body.childNodes.length === 2;
  16194. } )();
  16195. // Argument "data" should be string of html
  16196. // context (optional): If specified, the fragment will be created in this context,
  16197. // defaults to document
  16198. // keepScripts (optional): If true, will include scripts passed in the html string
  16199. jQuery.parseHTML = function( data, context, keepScripts ) {
  16200. if ( typeof data !== "string" ) {
  16201. return [];
  16202. }
  16203. if ( typeof context === "boolean" ) {
  16204. keepScripts = context;
  16205. context = false;
  16206. }
  16207. var base, parsed, scripts;
  16208. if ( !context ) {
  16209. // Stop scripts or inline event handlers from being executed immediately
  16210. // by using document.implementation
  16211. if ( support.createHTMLDocument ) {
  16212. context = document.implementation.createHTMLDocument( "" );
  16213. // Set the base href for the created document
  16214. // so any parsed elements with URLs
  16215. // are based on the document's URL (gh-2965)
  16216. base = context.createElement( "base" );
  16217. base.href = document.location.href;
  16218. context.head.appendChild( base );
  16219. } else {
  16220. context = document;
  16221. }
  16222. }
  16223. parsed = rsingleTag.exec( data );
  16224. scripts = !keepScripts && [];
  16225. // Single tag
  16226. if ( parsed ) {
  16227. return [ context.createElement( parsed[ 1 ] ) ];
  16228. }
  16229. parsed = buildFragment( [ data ], context, scripts );
  16230. if ( scripts && scripts.length ) {
  16231. jQuery( scripts ).remove();
  16232. }
  16233. return jQuery.merge( [], parsed.childNodes );
  16234. };
  16235. /**
  16236. * Load a url into a page
  16237. */
  16238. jQuery.fn.load = function( url, params, callback ) {
  16239. var selector, type, response,
  16240. self = this,
  16241. off = url.indexOf( " " );
  16242. if ( off > -1 ) {
  16243. selector = stripAndCollapse( url.slice( off ) );
  16244. url = url.slice( 0, off );
  16245. }
  16246. // If it's a function
  16247. if ( isFunction( params ) ) {
  16248. // We assume that it's the callback
  16249. callback = params;
  16250. params = undefined;
  16251. // Otherwise, build a param string
  16252. } else if ( params && typeof params === "object" ) {
  16253. type = "POST";
  16254. }
  16255. // If we have elements to modify, make the request
  16256. if ( self.length > 0 ) {
  16257. jQuery.ajax( {
  16258. url: url,
  16259. // If "type" variable is undefined, then "GET" method will be used.
  16260. // Make value of this field explicit since
  16261. // user can override it through ajaxSetup method
  16262. type: type || "GET",
  16263. dataType: "html",
  16264. data: params
  16265. } ).done( function( responseText ) {
  16266. // Save response for use in complete callback
  16267. response = arguments;
  16268. self.html( selector ?
  16269. // If a selector was specified, locate the right elements in a dummy div
  16270. // Exclude scripts to avoid IE 'Permission Denied' errors
  16271. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  16272. // Otherwise use the full result
  16273. responseText );
  16274. // If the request succeeds, this function gets "data", "status", "jqXHR"
  16275. // but they are ignored because response was set above.
  16276. // If it fails, this function gets "jqXHR", "status", "error"
  16277. } ).always( callback && function( jqXHR, status ) {
  16278. self.each( function() {
  16279. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  16280. } );
  16281. } );
  16282. }
  16283. return this;
  16284. };
  16285. // Attach a bunch of functions for handling common AJAX events
  16286. jQuery.each( [
  16287. "ajaxStart",
  16288. "ajaxStop",
  16289. "ajaxComplete",
  16290. "ajaxError",
  16291. "ajaxSuccess",
  16292. "ajaxSend"
  16293. ], function( i, type ) {
  16294. jQuery.fn[ type ] = function( fn ) {
  16295. return this.on( type, fn );
  16296. };
  16297. } );
  16298. jQuery.expr.pseudos.animated = function( elem ) {
  16299. return jQuery.grep( jQuery.timers, function( fn ) {
  16300. return elem === fn.elem;
  16301. } ).length;
  16302. };
  16303. jQuery.offset = {
  16304. setOffset: function( elem, options, i ) {
  16305. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  16306. position = jQuery.css( elem, "position" ),
  16307. curElem = jQuery( elem ),
  16308. props = {};
  16309. // Set position first, in-case top/left are set even on static elem
  16310. if ( position === "static" ) {
  16311. elem.style.position = "relative";
  16312. }
  16313. curOffset = curElem.offset();
  16314. curCSSTop = jQuery.css( elem, "top" );
  16315. curCSSLeft = jQuery.css( elem, "left" );
  16316. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  16317. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  16318. // Need to be able to calculate position if either
  16319. // top or left is auto and position is either absolute or fixed
  16320. if ( calculatePosition ) {
  16321. curPosition = curElem.position();
  16322. curTop = curPosition.top;
  16323. curLeft = curPosition.left;
  16324. } else {
  16325. curTop = parseFloat( curCSSTop ) || 0;
  16326. curLeft = parseFloat( curCSSLeft ) || 0;
  16327. }
  16328. if ( isFunction( options ) ) {
  16329. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  16330. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  16331. }
  16332. if ( options.top != null ) {
  16333. props.top = ( options.top - curOffset.top ) + curTop;
  16334. }
  16335. if ( options.left != null ) {
  16336. props.left = ( options.left - curOffset.left ) + curLeft;
  16337. }
  16338. if ( "using" in options ) {
  16339. options.using.call( elem, props );
  16340. } else {
  16341. curElem.css( props );
  16342. }
  16343. }
  16344. };
  16345. jQuery.fn.extend( {
  16346. // offset() relates an element's border box to the document origin
  16347. offset: function( options ) {
  16348. // Preserve chaining for setter
  16349. if ( arguments.length ) {
  16350. return options === undefined ?
  16351. this :
  16352. this.each( function( i ) {
  16353. jQuery.offset.setOffset( this, options, i );
  16354. } );
  16355. }
  16356. var rect, win,
  16357. elem = this[ 0 ];
  16358. if ( !elem ) {
  16359. return;
  16360. }
  16361. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  16362. // Support: IE <=11 only
  16363. // Running getBoundingClientRect on a
  16364. // disconnected node in IE throws an error
  16365. if ( !elem.getClientRects().length ) {
  16366. return { top: 0, left: 0 };
  16367. }
  16368. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  16369. rect = elem.getBoundingClientRect();
  16370. win = elem.ownerDocument.defaultView;
  16371. return {
  16372. top: rect.top + win.pageYOffset,
  16373. left: rect.left + win.pageXOffset
  16374. };
  16375. },
  16376. // position() relates an element's margin box to its offset parent's padding box
  16377. // This corresponds to the behavior of CSS absolute positioning
  16378. position: function() {
  16379. if ( !this[ 0 ] ) {
  16380. return;
  16381. }
  16382. var offsetParent, offset, doc,
  16383. elem = this[ 0 ],
  16384. parentOffset = { top: 0, left: 0 };
  16385. // position:fixed elements are offset from the viewport, which itself always has zero offset
  16386. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  16387. // Assume position:fixed implies availability of getBoundingClientRect
  16388. offset = elem.getBoundingClientRect();
  16389. } else {
  16390. offset = this.offset();
  16391. // Account for the *real* offset parent, which can be the document or its root element
  16392. // when a statically positioned element is identified
  16393. doc = elem.ownerDocument;
  16394. offsetParent = elem.offsetParent || doc.documentElement;
  16395. while ( offsetParent &&
  16396. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  16397. jQuery.css( offsetParent, "position" ) === "static" ) {
  16398. offsetParent = offsetParent.parentNode;
  16399. }
  16400. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  16401. // Incorporate borders into its offset, since they are outside its content origin
  16402. parentOffset = jQuery( offsetParent ).offset();
  16403. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  16404. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  16405. }
  16406. }
  16407. // Subtract parent offsets and element margins
  16408. return {
  16409. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  16410. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  16411. };
  16412. },
  16413. // This method will return documentElement in the following cases:
  16414. // 1) For the element inside the iframe without offsetParent, this method will return
  16415. // documentElement of the parent window
  16416. // 2) For the hidden or detached element
  16417. // 3) For body or html element, i.e. in case of the html node - it will return itself
  16418. //
  16419. // but those exceptions were never presented as a real life use-cases
  16420. // and might be considered as more preferable results.
  16421. //
  16422. // This logic, however, is not guaranteed and can change at any point in the future
  16423. offsetParent: function() {
  16424. return this.map( function() {
  16425. var offsetParent = this.offsetParent;
  16426. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  16427. offsetParent = offsetParent.offsetParent;
  16428. }
  16429. return offsetParent || documentElement;
  16430. } );
  16431. }
  16432. } );
  16433. // Create scrollLeft and scrollTop methods
  16434. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  16435. var top = "pageYOffset" === prop;
  16436. jQuery.fn[ method ] = function( val ) {
  16437. return access( this, function( elem, method, val ) {
  16438. // Coalesce documents and windows
  16439. var win;
  16440. if ( isWindow( elem ) ) {
  16441. win = elem;
  16442. } else if ( elem.nodeType === 9 ) {
  16443. win = elem.defaultView;
  16444. }
  16445. if ( val === undefined ) {
  16446. return win ? win[ prop ] : elem[ method ];
  16447. }
  16448. if ( win ) {
  16449. win.scrollTo(
  16450. !top ? val : win.pageXOffset,
  16451. top ? val : win.pageYOffset
  16452. );
  16453. } else {
  16454. elem[ method ] = val;
  16455. }
  16456. }, method, val, arguments.length );
  16457. };
  16458. } );
  16459. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  16460. // Add the top/left cssHooks using jQuery.fn.position
  16461. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  16462. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  16463. // getComputedStyle returns percent when specified for top/left/bottom/right;
  16464. // rather than make the css module depend on the offset module, just check for it here
  16465. jQuery.each( [ "top", "left" ], function( i, prop ) {
  16466. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  16467. function( elem, computed ) {
  16468. if ( computed ) {
  16469. computed = curCSS( elem, prop );
  16470. // If curCSS returns percentage, fallback to offset
  16471. return rnumnonpx.test( computed ) ?
  16472. jQuery( elem ).position()[ prop ] + "px" :
  16473. computed;
  16474. }
  16475. }
  16476. );
  16477. } );
  16478. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  16479. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  16480. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  16481. function( defaultExtra, funcName ) {
  16482. // Margin is only for outerHeight, outerWidth
  16483. jQuery.fn[ funcName ] = function( margin, value ) {
  16484. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  16485. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  16486. return access( this, function( elem, type, value ) {
  16487. var doc;
  16488. if ( isWindow( elem ) ) {
  16489. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  16490. return funcName.indexOf( "outer" ) === 0 ?
  16491. elem[ "inner" + name ] :
  16492. elem.document.documentElement[ "client" + name ];
  16493. }
  16494. // Get document width or height
  16495. if ( elem.nodeType === 9 ) {
  16496. doc = elem.documentElement;
  16497. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  16498. // whichever is greatest
  16499. return Math.max(
  16500. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  16501. elem.body[ "offset" + name ], doc[ "offset" + name ],
  16502. doc[ "client" + name ]
  16503. );
  16504. }
  16505. return value === undefined ?
  16506. // Get width or height on the element, requesting but not forcing parseFloat
  16507. jQuery.css( elem, type, extra ) :
  16508. // Set width or height on the element
  16509. jQuery.style( elem, type, value, extra );
  16510. }, type, chainable ? margin : undefined, chainable );
  16511. };
  16512. } );
  16513. } );
  16514. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  16515. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  16516. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  16517. function( i, name ) {
  16518. // Handle event binding
  16519. jQuery.fn[ name ] = function( data, fn ) {
  16520. return arguments.length > 0 ?
  16521. this.on( name, null, data, fn ) :
  16522. this.trigger( name );
  16523. };
  16524. } );
  16525. jQuery.fn.extend( {
  16526. hover: function( fnOver, fnOut ) {
  16527. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  16528. }
  16529. } );
  16530. jQuery.fn.extend( {
  16531. bind: function( types, data, fn ) {
  16532. return this.on( types, null, data, fn );
  16533. },
  16534. unbind: function( types, fn ) {
  16535. return this.off( types, null, fn );
  16536. },
  16537. delegate: function( selector, types, data, fn ) {
  16538. return this.on( types, selector, data, fn );
  16539. },
  16540. undelegate: function( selector, types, fn ) {
  16541. // ( namespace ) or ( selector, types [, fn] )
  16542. return arguments.length === 1 ?
  16543. this.off( selector, "**" ) :
  16544. this.off( types, selector || "**", fn );
  16545. }
  16546. } );
  16547. // Bind a function to a context, optionally partially applying any
  16548. // arguments.
  16549. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  16550. // However, it is not slated for removal any time soon
  16551. jQuery.proxy = function( fn, context ) {
  16552. var tmp, args, proxy;
  16553. if ( typeof context === "string" ) {
  16554. tmp = fn[ context ];
  16555. context = fn;
  16556. fn = tmp;
  16557. }
  16558. // Quick check to determine if target is callable, in the spec
  16559. // this throws a TypeError, but we will just return undefined.
  16560. if ( !isFunction( fn ) ) {
  16561. return undefined;
  16562. }
  16563. // Simulated bind
  16564. args = slice.call( arguments, 2 );
  16565. proxy = function() {
  16566. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  16567. };
  16568. // Set the guid of unique handler to the same of original handler, so it can be removed
  16569. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  16570. return proxy;
  16571. };
  16572. jQuery.holdReady = function( hold ) {
  16573. if ( hold ) {
  16574. jQuery.readyWait++;
  16575. } else {
  16576. jQuery.ready( true );
  16577. }
  16578. };
  16579. jQuery.isArray = Array.isArray;
  16580. jQuery.parseJSON = JSON.parse;
  16581. jQuery.nodeName = nodeName;
  16582. jQuery.isFunction = isFunction;
  16583. jQuery.isWindow = isWindow;
  16584. jQuery.camelCase = camelCase;
  16585. jQuery.type = toType;
  16586. jQuery.now = Date.now;
  16587. jQuery.isNumeric = function( obj ) {
  16588. // As of jQuery 3.0, isNumeric is limited to
  16589. // strings and numbers (primitives or objects)
  16590. // that can be coerced to finite numbers (gh-2662)
  16591. var type = jQuery.type( obj );
  16592. return ( type === "number" || type === "string" ) &&
  16593. // parseFloat NaNs numeric-cast false positives ("")
  16594. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  16595. // subtraction forces infinities to NaN
  16596. !isNaN( obj - parseFloat( obj ) );
  16597. };
  16598. // Register as a named AMD module, since jQuery can be concatenated with other
  16599. // files that may use define, but not via a proper concatenation script that
  16600. // understands anonymous AMD modules. A named AMD is safest and most robust
  16601. // way to register. Lowercase jquery is used because AMD module names are
  16602. // derived from file names, and jQuery is normally delivered in a lowercase
  16603. // file name. Do this after creating the global so that if an AMD module wants
  16604. // to call noConflict to hide this version of jQuery, it will work.
  16605. // Note that for maximum portability, libraries that are not jQuery should
  16606. // declare themselves as anonymous modules, and avoid setting a global if an
  16607. // AMD loader is present. jQuery is a special case. For more information, see
  16608. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  16609. if ( true ) {
  16610. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  16611. return jQuery;
  16612. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  16613. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16614. }
  16615. var
  16616. // Map over jQuery in case of overwrite
  16617. _jQuery = window.jQuery,
  16618. // Map over the $ in case of overwrite
  16619. _$ = window.$;
  16620. jQuery.noConflict = function( deep ) {
  16621. if ( window.$ === jQuery ) {
  16622. window.$ = _$;
  16623. }
  16624. if ( deep && window.jQuery === jQuery ) {
  16625. window.jQuery = _jQuery;
  16626. }
  16627. return jQuery;
  16628. };
  16629. // Expose jQuery and $ identifiers, even in AMD
  16630. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  16631. // and CommonJS for browser emulators (#13566)
  16632. if ( !noGlobal ) {
  16633. window.jQuery = window.$ = jQuery;
  16634. }
  16635. return jQuery;
  16636. } );
  16637. /***/ }),
  16638. /***/ "./node_modules/laravel-echo/dist/echo.js":
  16639. /*!************************************************!*\
  16640. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  16641. \************************************************/
  16642. /*! exports provided: default */
  16643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16644. "use strict";
  16645. __webpack_require__.r(__webpack_exports__);
  16646. var classCallCheck = function (instance, Constructor) {
  16647. if (!(instance instanceof Constructor)) {
  16648. throw new TypeError("Cannot call a class as a function");
  16649. }
  16650. };
  16651. var createClass = function () {
  16652. function defineProperties(target, props) {
  16653. for (var i = 0; i < props.length; i++) {
  16654. var descriptor = props[i];
  16655. descriptor.enumerable = descriptor.enumerable || false;
  16656. descriptor.configurable = true;
  16657. if ("value" in descriptor) descriptor.writable = true;
  16658. Object.defineProperty(target, descriptor.key, descriptor);
  16659. }
  16660. }
  16661. return function (Constructor, protoProps, staticProps) {
  16662. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  16663. if (staticProps) defineProperties(Constructor, staticProps);
  16664. return Constructor;
  16665. };
  16666. }();
  16667. var _extends = Object.assign || function (target) {
  16668. for (var i = 1; i < arguments.length; i++) {
  16669. var source = arguments[i];
  16670. for (var key in source) {
  16671. if (Object.prototype.hasOwnProperty.call(source, key)) {
  16672. target[key] = source[key];
  16673. }
  16674. }
  16675. }
  16676. return target;
  16677. };
  16678. var inherits = function (subClass, superClass) {
  16679. if (typeof superClass !== "function" && superClass !== null) {
  16680. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  16681. }
  16682. subClass.prototype = Object.create(superClass && superClass.prototype, {
  16683. constructor: {
  16684. value: subClass,
  16685. enumerable: false,
  16686. writable: true,
  16687. configurable: true
  16688. }
  16689. });
  16690. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  16691. };
  16692. var possibleConstructorReturn = function (self, call) {
  16693. if (!self) {
  16694. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  16695. }
  16696. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  16697. };
  16698. var Connector = function () {
  16699. /**
  16700. * Create a new class instance.
  16701. */
  16702. function Connector(options) {
  16703. classCallCheck(this, Connector);
  16704. /**
  16705. * Default connector options.
  16706. */
  16707. this._defaultOptions = {
  16708. auth: {
  16709. headers: {}
  16710. },
  16711. authEndpoint: '/broadcasting/auth',
  16712. broadcaster: 'pusher',
  16713. csrfToken: null,
  16714. host: null,
  16715. key: null,
  16716. namespace: 'App.Events'
  16717. };
  16718. this.setOptions(options);
  16719. this.connect();
  16720. }
  16721. /**
  16722. * Merge the custom options with the defaults.
  16723. */
  16724. createClass(Connector, [{
  16725. key: 'setOptions',
  16726. value: function setOptions(options) {
  16727. this.options = _extends(this._defaultOptions, options);
  16728. if (this.csrfToken()) {
  16729. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  16730. }
  16731. return options;
  16732. }
  16733. /**
  16734. * Extract the CSRF token from the page.
  16735. */
  16736. }, {
  16737. key: 'csrfToken',
  16738. value: function csrfToken() {
  16739. var selector = void 0;
  16740. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  16741. return window['Laravel'].csrfToken;
  16742. } else if (this.options.csrfToken) {
  16743. return this.options.csrfToken;
  16744. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  16745. return selector.getAttribute('content');
  16746. }
  16747. return null;
  16748. }
  16749. }]);
  16750. return Connector;
  16751. }();
  16752. /**
  16753. * This class represents a basic channel.
  16754. */
  16755. var Channel = function () {
  16756. function Channel() {
  16757. classCallCheck(this, Channel);
  16758. }
  16759. createClass(Channel, [{
  16760. key: 'listenForWhisper',
  16761. /**
  16762. * Listen for a whisper event on the channel instance.
  16763. */
  16764. value: function listenForWhisper(event, callback) {
  16765. return this.listen('.client-' + event, callback);
  16766. }
  16767. /**
  16768. * Listen for an event on the channel instance.
  16769. */
  16770. }, {
  16771. key: 'notification',
  16772. value: function notification(callback) {
  16773. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  16774. }
  16775. /**
  16776. * Stop listening for a whispser event on the channel instance.
  16777. */
  16778. }, {
  16779. key: 'stopListeningForWhisper',
  16780. value: function stopListeningForWhisper(event) {
  16781. return this.stopListening('.client-' + event);
  16782. }
  16783. }]);
  16784. return Channel;
  16785. }();
  16786. /**
  16787. * Event name formatter
  16788. */
  16789. var EventFormatter = function () {
  16790. /**
  16791. * Create a new class instance.
  16792. */
  16793. function EventFormatter(namespace) {
  16794. classCallCheck(this, EventFormatter);
  16795. this.setNamespace(namespace);
  16796. }
  16797. /**
  16798. * Format the given event name.
  16799. */
  16800. createClass(EventFormatter, [{
  16801. key: 'format',
  16802. value: function format(event) {
  16803. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  16804. return event.substr(1);
  16805. } else if (this.namespace) {
  16806. event = this.namespace + '.' + event;
  16807. }
  16808. return event.replace(/\./g, '\\');
  16809. }
  16810. /**
  16811. * Set the event namespace.
  16812. */
  16813. }, {
  16814. key: 'setNamespace',
  16815. value: function setNamespace(value) {
  16816. this.namespace = value;
  16817. }
  16818. }]);
  16819. return EventFormatter;
  16820. }();
  16821. /**
  16822. * This class represents a Pusher channel.
  16823. */
  16824. var PusherChannel = function (_Channel) {
  16825. inherits(PusherChannel, _Channel);
  16826. /**
  16827. * Create a new class instance.
  16828. */
  16829. function PusherChannel(pusher, name, options) {
  16830. classCallCheck(this, PusherChannel);
  16831. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  16832. _this.name = name;
  16833. _this.pusher = pusher;
  16834. _this.options = options;
  16835. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16836. _this.subscribe();
  16837. return _this;
  16838. }
  16839. /**
  16840. * Subscribe to a Pusher channel.
  16841. */
  16842. createClass(PusherChannel, [{
  16843. key: 'subscribe',
  16844. value: function subscribe() {
  16845. this.subscription = this.pusher.subscribe(this.name);
  16846. }
  16847. /**
  16848. * Unsubscribe from a Pusher channel.
  16849. */
  16850. }, {
  16851. key: 'unsubscribe',
  16852. value: function unsubscribe() {
  16853. this.pusher.unsubscribe(this.name);
  16854. }
  16855. /**
  16856. * Listen for an event on the channel instance.
  16857. */
  16858. }, {
  16859. key: 'listen',
  16860. value: function listen(event, callback) {
  16861. this.on(this.eventFormatter.format(event), callback);
  16862. return this;
  16863. }
  16864. /**
  16865. * Stop listening for an event on the channel instance.
  16866. */
  16867. }, {
  16868. key: 'stopListening',
  16869. value: function stopListening(event) {
  16870. this.subscription.unbind(this.eventFormatter.format(event));
  16871. return this;
  16872. }
  16873. /**
  16874. * Bind a channel to an event.
  16875. */
  16876. }, {
  16877. key: 'on',
  16878. value: function on(event, callback) {
  16879. this.subscription.bind(event, callback);
  16880. return this;
  16881. }
  16882. }]);
  16883. return PusherChannel;
  16884. }(Channel);
  16885. /**
  16886. * This class represents a Pusher private channel.
  16887. */
  16888. var PusherPrivateChannel = function (_PusherChannel) {
  16889. inherits(PusherPrivateChannel, _PusherChannel);
  16890. function PusherPrivateChannel() {
  16891. classCallCheck(this, PusherPrivateChannel);
  16892. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  16893. }
  16894. createClass(PusherPrivateChannel, [{
  16895. key: 'whisper',
  16896. /**
  16897. * Trigger client event on the channel.
  16898. */
  16899. value: function whisper(eventName, data) {
  16900. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16901. return this;
  16902. }
  16903. }]);
  16904. return PusherPrivateChannel;
  16905. }(PusherChannel);
  16906. /**
  16907. * This class represents a Pusher presence channel.
  16908. */
  16909. var PusherPresenceChannel = function (_PusherChannel) {
  16910. inherits(PusherPresenceChannel, _PusherChannel);
  16911. function PusherPresenceChannel() {
  16912. classCallCheck(this, PusherPresenceChannel);
  16913. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  16914. }
  16915. createClass(PusherPresenceChannel, [{
  16916. key: 'here',
  16917. /**
  16918. * Register a callback to be called anytime the member list changes.
  16919. */
  16920. value: function here(callback) {
  16921. this.on('pusher:subscription_succeeded', function (data) {
  16922. callback(Object.keys(data.members).map(function (k) {
  16923. return data.members[k];
  16924. }));
  16925. });
  16926. return this;
  16927. }
  16928. /**
  16929. * Listen for someone joining the channel.
  16930. */
  16931. }, {
  16932. key: 'joining',
  16933. value: function joining(callback) {
  16934. this.on('pusher:member_added', function (member) {
  16935. callback(member.info);
  16936. });
  16937. return this;
  16938. }
  16939. /**
  16940. * Listen for someone leaving the channel.
  16941. */
  16942. }, {
  16943. key: 'leaving',
  16944. value: function leaving(callback) {
  16945. this.on('pusher:member_removed', function (member) {
  16946. callback(member.info);
  16947. });
  16948. return this;
  16949. }
  16950. /**
  16951. * Trigger client event on the channel.
  16952. */
  16953. }, {
  16954. key: 'whisper',
  16955. value: function whisper(eventName, data) {
  16956. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16957. return this;
  16958. }
  16959. }]);
  16960. return PusherPresenceChannel;
  16961. }(PusherChannel);
  16962. /**
  16963. * This class represents a Socket.io channel.
  16964. */
  16965. var SocketIoChannel = function (_Channel) {
  16966. inherits(SocketIoChannel, _Channel);
  16967. /**
  16968. * Create a new class instance.
  16969. */
  16970. function SocketIoChannel(socket, name, options) {
  16971. classCallCheck(this, SocketIoChannel);
  16972. /**
  16973. * The event callbacks applied to the channel.
  16974. */
  16975. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  16976. _this.events = {};
  16977. _this.name = name;
  16978. _this.socket = socket;
  16979. _this.options = options;
  16980. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16981. _this.subscribe();
  16982. _this.configureReconnector();
  16983. return _this;
  16984. }
  16985. /**
  16986. * Subscribe to a Socket.io channel.
  16987. */
  16988. createClass(SocketIoChannel, [{
  16989. key: 'subscribe',
  16990. value: function subscribe() {
  16991. this.socket.emit('subscribe', {
  16992. channel: this.name,
  16993. auth: this.options.auth || {}
  16994. });
  16995. }
  16996. /**
  16997. * Unsubscribe from channel and ubind event callbacks.
  16998. */
  16999. }, {
  17000. key: 'unsubscribe',
  17001. value: function unsubscribe() {
  17002. this.unbind();
  17003. this.socket.emit('unsubscribe', {
  17004. channel: this.name,
  17005. auth: this.options.auth || {}
  17006. });
  17007. }
  17008. /**
  17009. * Listen for an event on the channel instance.
  17010. */
  17011. }, {
  17012. key: 'listen',
  17013. value: function listen(event, callback) {
  17014. this.on(this.eventFormatter.format(event), callback);
  17015. return this;
  17016. }
  17017. /**
  17018. * Stop listening for an event on the channel instance.
  17019. */
  17020. }, {
  17021. key: 'stopListening',
  17022. value: function stopListening(event) {
  17023. var name = this.eventFormatter.format(event);
  17024. this.socket.removeListener(name);
  17025. delete this.events[name];
  17026. return this;
  17027. }
  17028. /**
  17029. * Bind the channel's socket to an event and store the callback.
  17030. */
  17031. }, {
  17032. key: 'on',
  17033. value: function on(event, callback) {
  17034. var _this2 = this;
  17035. var listener = function listener(channel, data) {
  17036. if (_this2.name == channel) {
  17037. callback(data);
  17038. }
  17039. };
  17040. this.socket.on(event, listener);
  17041. this.bind(event, listener);
  17042. }
  17043. /**
  17044. * Attach a 'reconnect' listener and bind the event.
  17045. */
  17046. }, {
  17047. key: 'configureReconnector',
  17048. value: function configureReconnector() {
  17049. var _this3 = this;
  17050. var listener = function listener() {
  17051. _this3.subscribe();
  17052. };
  17053. this.socket.on('reconnect', listener);
  17054. this.bind('reconnect', listener);
  17055. }
  17056. /**
  17057. * Bind the channel's socket to an event and store the callback.
  17058. */
  17059. }, {
  17060. key: 'bind',
  17061. value: function bind(event, callback) {
  17062. this.events[event] = this.events[event] || [];
  17063. this.events[event].push(callback);
  17064. }
  17065. /**
  17066. * Unbind the channel's socket from all stored event callbacks.
  17067. */
  17068. }, {
  17069. key: 'unbind',
  17070. value: function unbind() {
  17071. var _this4 = this;
  17072. Object.keys(this.events).forEach(function (event) {
  17073. _this4.events[event].forEach(function (callback) {
  17074. _this4.socket.removeListener(event, callback);
  17075. });
  17076. delete _this4.events[event];
  17077. });
  17078. }
  17079. }]);
  17080. return SocketIoChannel;
  17081. }(Channel);
  17082. /**
  17083. * This class represents a Socket.io presence channel.
  17084. */
  17085. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  17086. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  17087. function SocketIoPrivateChannel() {
  17088. classCallCheck(this, SocketIoPrivateChannel);
  17089. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  17090. }
  17091. createClass(SocketIoPrivateChannel, [{
  17092. key: 'whisper',
  17093. /**
  17094. * Trigger client event on the channel.
  17095. */
  17096. value: function whisper(eventName, data) {
  17097. this.socket.emit('client event', {
  17098. channel: this.name,
  17099. event: 'client-' + eventName,
  17100. data: data
  17101. });
  17102. return this;
  17103. }
  17104. }]);
  17105. return SocketIoPrivateChannel;
  17106. }(SocketIoChannel);
  17107. /**
  17108. * This class represents a Socket.io presence channel.
  17109. */
  17110. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  17111. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  17112. function SocketIoPresenceChannel() {
  17113. classCallCheck(this, SocketIoPresenceChannel);
  17114. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  17115. }
  17116. createClass(SocketIoPresenceChannel, [{
  17117. key: 'here',
  17118. /**
  17119. * Register a callback to be called anytime the member list changes.
  17120. */
  17121. value: function here(callback) {
  17122. this.on('presence:subscribed', function (members) {
  17123. callback(members.map(function (m) {
  17124. return m.user_info;
  17125. }));
  17126. });
  17127. return this;
  17128. }
  17129. /**
  17130. * Listen for someone joining the channel.
  17131. */
  17132. }, {
  17133. key: 'joining',
  17134. value: function joining(callback) {
  17135. this.on('presence:joining', function (member) {
  17136. return callback(member.user_info);
  17137. });
  17138. return this;
  17139. }
  17140. /**
  17141. * Listen for someone leaving the channel.
  17142. */
  17143. }, {
  17144. key: 'leaving',
  17145. value: function leaving(callback) {
  17146. this.on('presence:leaving', function (member) {
  17147. return callback(member.user_info);
  17148. });
  17149. return this;
  17150. }
  17151. }]);
  17152. return SocketIoPresenceChannel;
  17153. }(SocketIoPrivateChannel);
  17154. /**
  17155. * This class represents a null channel.
  17156. */
  17157. var NullChannel = function (_Channel) {
  17158. inherits(NullChannel, _Channel);
  17159. function NullChannel() {
  17160. classCallCheck(this, NullChannel);
  17161. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  17162. }
  17163. createClass(NullChannel, [{
  17164. key: 'subscribe',
  17165. /**
  17166. * Subscribe to a channel.
  17167. */
  17168. value: function subscribe() {}
  17169. //
  17170. /**
  17171. * Unsubscribe from a channel.
  17172. */
  17173. }, {
  17174. key: 'unsubscribe',
  17175. value: function unsubscribe() {}
  17176. //
  17177. /**
  17178. * Listen for an event on the channel instance.
  17179. */
  17180. }, {
  17181. key: 'listen',
  17182. value: function listen(event, callback) {
  17183. return this;
  17184. }
  17185. /**
  17186. * Stop listening for an event on the channel instance.
  17187. */
  17188. }, {
  17189. key: 'stopListening',
  17190. value: function stopListening(event) {
  17191. return this;
  17192. }
  17193. /**
  17194. * Bind a channel to an event.
  17195. */
  17196. }, {
  17197. key: 'on',
  17198. value: function on(event, callback) {
  17199. return this;
  17200. }
  17201. }]);
  17202. return NullChannel;
  17203. }(Channel);
  17204. /**
  17205. * This class represents a null private channel.
  17206. */
  17207. var NullPrivateChannel = function (_NullChannel) {
  17208. inherits(NullPrivateChannel, _NullChannel);
  17209. function NullPrivateChannel() {
  17210. classCallCheck(this, NullPrivateChannel);
  17211. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  17212. }
  17213. createClass(NullPrivateChannel, [{
  17214. key: 'whisper',
  17215. /**
  17216. * Trigger client event on the channel.
  17217. */
  17218. value: function whisper(eventName, data) {
  17219. return this;
  17220. }
  17221. }]);
  17222. return NullPrivateChannel;
  17223. }(NullChannel);
  17224. /**
  17225. * This class represents a null presence channel.
  17226. */
  17227. var NullPresenceChannel = function (_NullChannel) {
  17228. inherits(NullPresenceChannel, _NullChannel);
  17229. function NullPresenceChannel() {
  17230. classCallCheck(this, NullPresenceChannel);
  17231. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  17232. }
  17233. createClass(NullPresenceChannel, [{
  17234. key: 'here',
  17235. /**
  17236. * Register a callback to be called anytime the member list changes.
  17237. */
  17238. value: function here(callback) {
  17239. return this;
  17240. }
  17241. /**
  17242. * Listen for someone joining the channel.
  17243. */
  17244. }, {
  17245. key: 'joining',
  17246. value: function joining(callback) {
  17247. return this;
  17248. }
  17249. /**
  17250. * Listen for someone leaving the channel.
  17251. */
  17252. }, {
  17253. key: 'leaving',
  17254. value: function leaving(callback) {
  17255. return this;
  17256. }
  17257. /**
  17258. * Trigger client event on the channel.
  17259. */
  17260. }, {
  17261. key: 'whisper',
  17262. value: function whisper(eventName, data) {
  17263. return this;
  17264. }
  17265. }]);
  17266. return NullPresenceChannel;
  17267. }(NullChannel);
  17268. /**
  17269. * This class creates a connector to Pusher.
  17270. */
  17271. var PusherConnector = function (_Connector) {
  17272. inherits(PusherConnector, _Connector);
  17273. function PusherConnector() {
  17274. classCallCheck(this, PusherConnector);
  17275. /**
  17276. * All of the subscribed channel names.
  17277. */
  17278. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  17279. _this.channels = {};
  17280. return _this;
  17281. }
  17282. /**
  17283. * Create a fresh Pusher connection.
  17284. */
  17285. createClass(PusherConnector, [{
  17286. key: 'connect',
  17287. value: function connect() {
  17288. if (typeof this.options.client !== 'undefined') {
  17289. this.pusher = this.options.client;
  17290. } else {
  17291. this.pusher = new Pusher(this.options.key, this.options);
  17292. }
  17293. }
  17294. /**
  17295. * Listen for an event on a channel instance.
  17296. */
  17297. }, {
  17298. key: 'listen',
  17299. value: function listen(name, event, callback) {
  17300. return this.channel(name).listen(event, callback);
  17301. }
  17302. /**
  17303. * Get a channel instance by name.
  17304. */
  17305. }, {
  17306. key: 'channel',
  17307. value: function channel(name) {
  17308. if (!this.channels[name]) {
  17309. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  17310. }
  17311. return this.channels[name];
  17312. }
  17313. /**
  17314. * Get a private channel instance by name.
  17315. */
  17316. }, {
  17317. key: 'privateChannel',
  17318. value: function privateChannel(name) {
  17319. if (!this.channels['private-' + name]) {
  17320. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  17321. }
  17322. return this.channels['private-' + name];
  17323. }
  17324. /**
  17325. * Get a presence channel instance by name.
  17326. */
  17327. }, {
  17328. key: 'presenceChannel',
  17329. value: function presenceChannel(name) {
  17330. if (!this.channels['presence-' + name]) {
  17331. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  17332. }
  17333. return this.channels['presence-' + name];
  17334. }
  17335. /**
  17336. * Leave the given channel, as well as its private and presence variants.
  17337. */
  17338. }, {
  17339. key: 'leave',
  17340. value: function leave(name) {
  17341. var _this2 = this;
  17342. var channels = [name, 'private-' + name, 'presence-' + name];
  17343. channels.forEach(function (name, index) {
  17344. _this2.leaveChannel(name);
  17345. });
  17346. }
  17347. /**
  17348. * Leave the given channel.
  17349. */
  17350. }, {
  17351. key: 'leaveChannel',
  17352. value: function leaveChannel(name) {
  17353. if (this.channels[name]) {
  17354. this.channels[name].unsubscribe();
  17355. delete this.channels[name];
  17356. }
  17357. }
  17358. /**
  17359. * Get the socket ID for the connection.
  17360. */
  17361. }, {
  17362. key: 'socketId',
  17363. value: function socketId() {
  17364. return this.pusher.connection.socket_id;
  17365. }
  17366. /**
  17367. * Disconnect Pusher connection.
  17368. */
  17369. }, {
  17370. key: 'disconnect',
  17371. value: function disconnect() {
  17372. this.pusher.disconnect();
  17373. }
  17374. }]);
  17375. return PusherConnector;
  17376. }(Connector);
  17377. /**
  17378. * This class creates a connnector to a Socket.io server.
  17379. */
  17380. var SocketIoConnector = function (_Connector) {
  17381. inherits(SocketIoConnector, _Connector);
  17382. function SocketIoConnector() {
  17383. classCallCheck(this, SocketIoConnector);
  17384. /**
  17385. * All of the subscribed channel names.
  17386. */
  17387. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  17388. _this.channels = {};
  17389. return _this;
  17390. }
  17391. /**
  17392. * Create a fresh Socket.io connection.
  17393. */
  17394. createClass(SocketIoConnector, [{
  17395. key: 'connect',
  17396. value: function connect() {
  17397. var io = this.getSocketIO();
  17398. this.socket = io(this.options.host, this.options);
  17399. return this.socket;
  17400. }
  17401. /**
  17402. * Get socket.io module from global scope or options.
  17403. */
  17404. }, {
  17405. key: 'getSocketIO',
  17406. value: function getSocketIO() {
  17407. if (typeof this.options.client !== 'undefined') {
  17408. return this.options.client;
  17409. }
  17410. if (typeof io !== 'undefined') {
  17411. return io;
  17412. }
  17413. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  17414. }
  17415. /**
  17416. * Listen for an event on a channel instance.
  17417. */
  17418. }, {
  17419. key: 'listen',
  17420. value: function listen(name, event, callback) {
  17421. return this.channel(name).listen(event, callback);
  17422. }
  17423. /**
  17424. * Get a channel instance by name.
  17425. */
  17426. }, {
  17427. key: 'channel',
  17428. value: function channel(name) {
  17429. if (!this.channels[name]) {
  17430. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  17431. }
  17432. return this.channels[name];
  17433. }
  17434. /**
  17435. * Get a private channel instance by name.
  17436. */
  17437. }, {
  17438. key: 'privateChannel',
  17439. value: function privateChannel(name) {
  17440. if (!this.channels['private-' + name]) {
  17441. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  17442. }
  17443. return this.channels['private-' + name];
  17444. }
  17445. /**
  17446. * Get a presence channel instance by name.
  17447. */
  17448. }, {
  17449. key: 'presenceChannel',
  17450. value: function presenceChannel(name) {
  17451. if (!this.channels['presence-' + name]) {
  17452. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  17453. }
  17454. return this.channels['presence-' + name];
  17455. }
  17456. /**
  17457. * Leave the given channel, as well as its private and presence variants.
  17458. */
  17459. }, {
  17460. key: 'leave',
  17461. value: function leave(name) {
  17462. var _this2 = this;
  17463. var channels = [name, 'private-' + name, 'presence-' + name];
  17464. channels.forEach(function (name) {
  17465. _this2.leaveChannel(name);
  17466. });
  17467. }
  17468. /**
  17469. * Leave the given channel.
  17470. */
  17471. }, {
  17472. key: 'leaveChannel',
  17473. value: function leaveChannel(name) {
  17474. if (this.channels[name]) {
  17475. this.channels[name].unsubscribe();
  17476. delete this.channels[name];
  17477. }
  17478. }
  17479. /**
  17480. * Get the socket ID for the connection.
  17481. */
  17482. }, {
  17483. key: 'socketId',
  17484. value: function socketId() {
  17485. return this.socket.id;
  17486. }
  17487. /**
  17488. * Disconnect Socketio connection.
  17489. */
  17490. }, {
  17491. key: 'disconnect',
  17492. value: function disconnect() {
  17493. this.socket.disconnect();
  17494. }
  17495. }]);
  17496. return SocketIoConnector;
  17497. }(Connector);
  17498. /**
  17499. * This class creates a null connector.
  17500. */
  17501. var NullConnector = function (_Connector) {
  17502. inherits(NullConnector, _Connector);
  17503. function NullConnector() {
  17504. classCallCheck(this, NullConnector);
  17505. /**
  17506. * All of the subscribed channel names.
  17507. */
  17508. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  17509. _this.channels = {};
  17510. return _this;
  17511. }
  17512. /**
  17513. * Create a fresh connection.
  17514. */
  17515. createClass(NullConnector, [{
  17516. key: 'connect',
  17517. value: function connect() {}
  17518. //
  17519. /**
  17520. * Listen for an event on a channel instance.
  17521. */
  17522. }, {
  17523. key: 'listen',
  17524. value: function listen(name, event, callback) {
  17525. return new NullChannel();
  17526. }
  17527. /**
  17528. * Get a channel instance by name.
  17529. */
  17530. }, {
  17531. key: 'channel',
  17532. value: function channel(name) {
  17533. return new NullChannel();
  17534. }
  17535. /**
  17536. * Get a private channel instance by name.
  17537. */
  17538. }, {
  17539. key: 'privateChannel',
  17540. value: function privateChannel(name) {
  17541. return new NullPrivateChannel();
  17542. }
  17543. /**
  17544. * Get a presence channel instance by name.
  17545. */
  17546. }, {
  17547. key: 'presenceChannel',
  17548. value: function presenceChannel(name) {
  17549. return new NullPresenceChannel();
  17550. }
  17551. /**
  17552. * Leave the given channel, as well as its private and presence variants.
  17553. */
  17554. }, {
  17555. key: 'leave',
  17556. value: function leave(name) {}
  17557. //
  17558. /**
  17559. * Leave the given channel.
  17560. */
  17561. }, {
  17562. key: 'leaveChannel',
  17563. value: function leaveChannel(name) {}
  17564. //
  17565. /**
  17566. * Get the socket ID for the connection.
  17567. */
  17568. }, {
  17569. key: 'socketId',
  17570. value: function socketId() {
  17571. return 'fake-socket-id';
  17572. }
  17573. /**
  17574. * Disconnect the connection.
  17575. */
  17576. }, {
  17577. key: 'disconnect',
  17578. value: function disconnect() {
  17579. //
  17580. }
  17581. }]);
  17582. return NullConnector;
  17583. }(Connector);
  17584. /**
  17585. * This class is the primary API for interacting with broadcasting.
  17586. */
  17587. var Echo = function () {
  17588. /**
  17589. * Create a new class instance.
  17590. */
  17591. function Echo(options) {
  17592. classCallCheck(this, Echo);
  17593. this.options = options;
  17594. this.connect();
  17595. if (!this.options.withoutInterceptors) {
  17596. this.registerInterceptors();
  17597. }
  17598. }
  17599. /**
  17600. * Get a channel instance by name.
  17601. */
  17602. createClass(Echo, [{
  17603. key: 'channel',
  17604. value: function channel(_channel) {
  17605. return this.connector.channel(_channel);
  17606. }
  17607. /**
  17608. * Create a new connection.
  17609. */
  17610. }, {
  17611. key: 'connect',
  17612. value: function connect() {
  17613. if (this.options.broadcaster == 'pusher') {
  17614. this.connector = new PusherConnector(this.options);
  17615. } else if (this.options.broadcaster == 'socket.io') {
  17616. this.connector = new SocketIoConnector(this.options);
  17617. } else if (this.options.broadcaster == 'null') {
  17618. this.connector = new NullConnector(this.options);
  17619. } else if (typeof this.options.broadcaster == 'function') {
  17620. this.connector = new this.options.broadcaster(this.options);
  17621. }
  17622. }
  17623. /**
  17624. * Disconnect from the Echo server.
  17625. */
  17626. }, {
  17627. key: 'disconnect',
  17628. value: function disconnect() {
  17629. this.connector.disconnect();
  17630. }
  17631. /**
  17632. * Get a presence channel instance by name.
  17633. */
  17634. }, {
  17635. key: 'join',
  17636. value: function join(channel) {
  17637. return this.connector.presenceChannel(channel);
  17638. }
  17639. /**
  17640. * Leave the given channel, as well as its private and presence variants.
  17641. */
  17642. }, {
  17643. key: 'leave',
  17644. value: function leave(channel) {
  17645. this.connector.leave(channel);
  17646. }
  17647. /**
  17648. * Leave the given channel.
  17649. */
  17650. }, {
  17651. key: 'leaveChannel',
  17652. value: function leaveChannel(channel) {
  17653. this.connector.leaveChannel(channel);
  17654. }
  17655. /**
  17656. * Listen for an event on a channel instance.
  17657. */
  17658. }, {
  17659. key: 'listen',
  17660. value: function listen(channel, event, callback) {
  17661. return this.connector.listen(channel, event, callback);
  17662. }
  17663. /**
  17664. * Get a private channel instance by name.
  17665. */
  17666. }, {
  17667. key: 'private',
  17668. value: function _private(channel) {
  17669. return this.connector.privateChannel(channel);
  17670. }
  17671. /**
  17672. * Get the Socket ID for the connection.
  17673. */
  17674. }, {
  17675. key: 'socketId',
  17676. value: function socketId() {
  17677. return this.connector.socketId();
  17678. }
  17679. /**
  17680. * Register 3rd party request interceptiors. These are used to automatically
  17681. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  17682. */
  17683. }, {
  17684. key: 'registerInterceptors',
  17685. value: function registerInterceptors() {
  17686. if (typeof Vue === 'function' && Vue.http) {
  17687. this.registerVueRequestInterceptor();
  17688. }
  17689. if (typeof axios === 'function') {
  17690. this.registerAxiosRequestInterceptor();
  17691. }
  17692. if (typeof jQuery === 'function') {
  17693. this.registerjQueryAjaxSetup();
  17694. }
  17695. }
  17696. /**
  17697. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  17698. */
  17699. }, {
  17700. key: 'registerVueRequestInterceptor',
  17701. value: function registerVueRequestInterceptor() {
  17702. var _this = this;
  17703. Vue.http.interceptors.push(function (request, next) {
  17704. if (_this.socketId()) {
  17705. request.headers.set('X-Socket-ID', _this.socketId());
  17706. }
  17707. next();
  17708. });
  17709. }
  17710. /**
  17711. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  17712. */
  17713. }, {
  17714. key: 'registerAxiosRequestInterceptor',
  17715. value: function registerAxiosRequestInterceptor() {
  17716. var _this2 = this;
  17717. axios.interceptors.request.use(function (config) {
  17718. if (_this2.socketId()) {
  17719. config.headers['X-Socket-Id'] = _this2.socketId();
  17720. }
  17721. return config;
  17722. });
  17723. }
  17724. /**
  17725. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  17726. */
  17727. }, {
  17728. key: 'registerjQueryAjaxSetup',
  17729. value: function registerjQueryAjaxSetup() {
  17730. var _this3 = this;
  17731. if (typeof jQuery.ajax != 'undefined') {
  17732. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  17733. if (_this3.socketId()) {
  17734. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  17735. }
  17736. });
  17737. }
  17738. }
  17739. }]);
  17740. return Echo;
  17741. }();
  17742. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  17743. /***/ }),
  17744. /***/ "./node_modules/lodash/lodash.js":
  17745. /*!***************************************!*\
  17746. !*** ./node_modules/lodash/lodash.js ***!
  17747. \***************************************/
  17748. /*! no static exports found */
  17749. /***/ (function(module, exports, __webpack_require__) {
  17750. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  17751. * @license
  17752. * Lodash <https://lodash.com/>
  17753. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  17754. * Released under MIT license <https://lodash.com/license>
  17755. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  17756. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  17757. */
  17758. ;(function() {
  17759. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  17760. var undefined;
  17761. /** Used as the semantic version number. */
  17762. var VERSION = '4.17.15';
  17763. /** Used as the size to enable large array optimizations. */
  17764. var LARGE_ARRAY_SIZE = 200;
  17765. /** Error message constants. */
  17766. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  17767. FUNC_ERROR_TEXT = 'Expected a function';
  17768. /** Used to stand-in for `undefined` hash values. */
  17769. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  17770. /** Used as the maximum memoize cache size. */
  17771. var MAX_MEMOIZE_SIZE = 500;
  17772. /** Used as the internal argument placeholder. */
  17773. var PLACEHOLDER = '__lodash_placeholder__';
  17774. /** Used to compose bitmasks for cloning. */
  17775. var CLONE_DEEP_FLAG = 1,
  17776. CLONE_FLAT_FLAG = 2,
  17777. CLONE_SYMBOLS_FLAG = 4;
  17778. /** Used to compose bitmasks for value comparisons. */
  17779. var COMPARE_PARTIAL_FLAG = 1,
  17780. COMPARE_UNORDERED_FLAG = 2;
  17781. /** Used to compose bitmasks for function metadata. */
  17782. var WRAP_BIND_FLAG = 1,
  17783. WRAP_BIND_KEY_FLAG = 2,
  17784. WRAP_CURRY_BOUND_FLAG = 4,
  17785. WRAP_CURRY_FLAG = 8,
  17786. WRAP_CURRY_RIGHT_FLAG = 16,
  17787. WRAP_PARTIAL_FLAG = 32,
  17788. WRAP_PARTIAL_RIGHT_FLAG = 64,
  17789. WRAP_ARY_FLAG = 128,
  17790. WRAP_REARG_FLAG = 256,
  17791. WRAP_FLIP_FLAG = 512;
  17792. /** Used as default options for `_.truncate`. */
  17793. var DEFAULT_TRUNC_LENGTH = 30,
  17794. DEFAULT_TRUNC_OMISSION = '...';
  17795. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  17796. var HOT_COUNT = 800,
  17797. HOT_SPAN = 16;
  17798. /** Used to indicate the type of lazy iteratees. */
  17799. var LAZY_FILTER_FLAG = 1,
  17800. LAZY_MAP_FLAG = 2,
  17801. LAZY_WHILE_FLAG = 3;
  17802. /** Used as references for various `Number` constants. */
  17803. var INFINITY = 1 / 0,
  17804. MAX_SAFE_INTEGER = 9007199254740991,
  17805. MAX_INTEGER = 1.7976931348623157e+308,
  17806. NAN = 0 / 0;
  17807. /** Used as references for the maximum length and index of an array. */
  17808. var MAX_ARRAY_LENGTH = 4294967295,
  17809. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  17810. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  17811. /** Used to associate wrap methods with their bit flags. */
  17812. var wrapFlags = [
  17813. ['ary', WRAP_ARY_FLAG],
  17814. ['bind', WRAP_BIND_FLAG],
  17815. ['bindKey', WRAP_BIND_KEY_FLAG],
  17816. ['curry', WRAP_CURRY_FLAG],
  17817. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  17818. ['flip', WRAP_FLIP_FLAG],
  17819. ['partial', WRAP_PARTIAL_FLAG],
  17820. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  17821. ['rearg', WRAP_REARG_FLAG]
  17822. ];
  17823. /** `Object#toString` result references. */
  17824. var argsTag = '[object Arguments]',
  17825. arrayTag = '[object Array]',
  17826. asyncTag = '[object AsyncFunction]',
  17827. boolTag = '[object Boolean]',
  17828. dateTag = '[object Date]',
  17829. domExcTag = '[object DOMException]',
  17830. errorTag = '[object Error]',
  17831. funcTag = '[object Function]',
  17832. genTag = '[object GeneratorFunction]',
  17833. mapTag = '[object Map]',
  17834. numberTag = '[object Number]',
  17835. nullTag = '[object Null]',
  17836. objectTag = '[object Object]',
  17837. promiseTag = '[object Promise]',
  17838. proxyTag = '[object Proxy]',
  17839. regexpTag = '[object RegExp]',
  17840. setTag = '[object Set]',
  17841. stringTag = '[object String]',
  17842. symbolTag = '[object Symbol]',
  17843. undefinedTag = '[object Undefined]',
  17844. weakMapTag = '[object WeakMap]',
  17845. weakSetTag = '[object WeakSet]';
  17846. var arrayBufferTag = '[object ArrayBuffer]',
  17847. dataViewTag = '[object DataView]',
  17848. float32Tag = '[object Float32Array]',
  17849. float64Tag = '[object Float64Array]',
  17850. int8Tag = '[object Int8Array]',
  17851. int16Tag = '[object Int16Array]',
  17852. int32Tag = '[object Int32Array]',
  17853. uint8Tag = '[object Uint8Array]',
  17854. uint8ClampedTag = '[object Uint8ClampedArray]',
  17855. uint16Tag = '[object Uint16Array]',
  17856. uint32Tag = '[object Uint32Array]';
  17857. /** Used to match empty string literals in compiled template source. */
  17858. var reEmptyStringLeading = /\b__p \+= '';/g,
  17859. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  17860. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  17861. /** Used to match HTML entities and HTML characters. */
  17862. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  17863. reUnescapedHtml = /[&<>"']/g,
  17864. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  17865. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  17866. /** Used to match template delimiters. */
  17867. var reEscape = /<%-([\s\S]+?)%>/g,
  17868. reEvaluate = /<%([\s\S]+?)%>/g,
  17869. reInterpolate = /<%=([\s\S]+?)%>/g;
  17870. /** Used to match property names within property paths. */
  17871. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  17872. reIsPlainProp = /^\w*$/,
  17873. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  17874. /**
  17875. * Used to match `RegExp`
  17876. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  17877. */
  17878. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  17879. reHasRegExpChar = RegExp(reRegExpChar.source);
  17880. /** Used to match leading and trailing whitespace. */
  17881. var reTrim = /^\s+|\s+$/g,
  17882. reTrimStart = /^\s+/,
  17883. reTrimEnd = /\s+$/;
  17884. /** Used to match wrap detail comments. */
  17885. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  17886. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  17887. reSplitDetails = /,? & /;
  17888. /** Used to match words composed of alphanumeric characters. */
  17889. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  17890. /** Used to match backslashes in property paths. */
  17891. var reEscapeChar = /\\(\\)?/g;
  17892. /**
  17893. * Used to match
  17894. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  17895. */
  17896. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  17897. /** Used to match `RegExp` flags from their coerced string values. */
  17898. var reFlags = /\w*$/;
  17899. /** Used to detect bad signed hexadecimal string values. */
  17900. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  17901. /** Used to detect binary string values. */
  17902. var reIsBinary = /^0b[01]+$/i;
  17903. /** Used to detect host constructors (Safari). */
  17904. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  17905. /** Used to detect octal string values. */
  17906. var reIsOctal = /^0o[0-7]+$/i;
  17907. /** Used to detect unsigned integer values. */
  17908. var reIsUint = /^(?:0|[1-9]\d*)$/;
  17909. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  17910. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  17911. /** Used to ensure capturing order of template delimiters. */
  17912. var reNoMatch = /($^)/;
  17913. /** Used to match unescaped characters in compiled string literals. */
  17914. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  17915. /** Used to compose unicode character classes. */
  17916. var rsAstralRange = '\\ud800-\\udfff',
  17917. rsComboMarksRange = '\\u0300-\\u036f',
  17918. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  17919. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  17920. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  17921. rsDingbatRange = '\\u2700-\\u27bf',
  17922. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  17923. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  17924. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  17925. rsPunctuationRange = '\\u2000-\\u206f',
  17926. 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',
  17927. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  17928. rsVarRange = '\\ufe0e\\ufe0f',
  17929. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  17930. /** Used to compose unicode capture groups. */
  17931. var rsApos = "['\u2019]",
  17932. rsAstral = '[' + rsAstralRange + ']',
  17933. rsBreak = '[' + rsBreakRange + ']',
  17934. rsCombo = '[' + rsComboRange + ']',
  17935. rsDigits = '\\d+',
  17936. rsDingbat = '[' + rsDingbatRange + ']',
  17937. rsLower = '[' + rsLowerRange + ']',
  17938. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  17939. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  17940. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  17941. rsNonAstral = '[^' + rsAstralRange + ']',
  17942. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  17943. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  17944. rsUpper = '[' + rsUpperRange + ']',
  17945. rsZWJ = '\\u200d';
  17946. /** Used to compose unicode regexes. */
  17947. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  17948. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  17949. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  17950. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  17951. reOptMod = rsModifier + '?',
  17952. rsOptVar = '[' + rsVarRange + ']?',
  17953. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  17954. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  17955. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  17956. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  17957. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  17958. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  17959. /** Used to match apostrophes. */
  17960. var reApos = RegExp(rsApos, 'g');
  17961. /**
  17962. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  17963. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  17964. */
  17965. var reComboMark = RegExp(rsCombo, 'g');
  17966. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  17967. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  17968. /** Used to match complex or compound words. */
  17969. var reUnicodeWord = RegExp([
  17970. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  17971. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  17972. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  17973. rsUpper + '+' + rsOptContrUpper,
  17974. rsOrdUpper,
  17975. rsOrdLower,
  17976. rsDigits,
  17977. rsEmoji
  17978. ].join('|'), 'g');
  17979. /** 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/). */
  17980. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  17981. /** Used to detect strings that need a more robust regexp to match words. */
  17982. 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 ]/;
  17983. /** Used to assign default `context` object properties. */
  17984. var contextProps = [
  17985. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  17986. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  17987. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  17988. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  17989. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  17990. ];
  17991. /** Used to make template sourceURLs easier to identify. */
  17992. var templateCounter = -1;
  17993. /** Used to identify `toStringTag` values of typed arrays. */
  17994. var typedArrayTags = {};
  17995. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  17996. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  17997. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  17998. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  17999. typedArrayTags[uint32Tag] = true;
  18000. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  18001. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  18002. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  18003. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  18004. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  18005. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  18006. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  18007. typedArrayTags[weakMapTag] = false;
  18008. /** Used to identify `toStringTag` values supported by `_.clone`. */
  18009. var cloneableTags = {};
  18010. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  18011. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  18012. cloneableTags[boolTag] = cloneableTags[dateTag] =
  18013. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  18014. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  18015. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  18016. cloneableTags[numberTag] = cloneableTags[objectTag] =
  18017. cloneableTags[regexpTag] = cloneableTags[setTag] =
  18018. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  18019. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  18020. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  18021. cloneableTags[errorTag] = cloneableTags[funcTag] =
  18022. cloneableTags[weakMapTag] = false;
  18023. /** Used to map Latin Unicode letters to basic Latin letters. */
  18024. var deburredLetters = {
  18025. // Latin-1 Supplement block.
  18026. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  18027. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  18028. '\xc7': 'C', '\xe7': 'c',
  18029. '\xd0': 'D', '\xf0': 'd',
  18030. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  18031. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  18032. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  18033. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  18034. '\xd1': 'N', '\xf1': 'n',
  18035. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  18036. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  18037. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  18038. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  18039. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  18040. '\xc6': 'Ae', '\xe6': 'ae',
  18041. '\xde': 'Th', '\xfe': 'th',
  18042. '\xdf': 'ss',
  18043. // Latin Extended-A block.
  18044. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  18045. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  18046. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  18047. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  18048. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  18049. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  18050. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  18051. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  18052. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  18053. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  18054. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  18055. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  18056. '\u0134': 'J', '\u0135': 'j',
  18057. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  18058. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  18059. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  18060. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  18061. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  18062. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  18063. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  18064. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  18065. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  18066. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  18067. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  18068. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  18069. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  18070. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  18071. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  18072. '\u0174': 'W', '\u0175': 'w',
  18073. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  18074. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  18075. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  18076. '\u0132': 'IJ', '\u0133': 'ij',
  18077. '\u0152': 'Oe', '\u0153': 'oe',
  18078. '\u0149': "'n", '\u017f': 's'
  18079. };
  18080. /** Used to map characters to HTML entities. */
  18081. var htmlEscapes = {
  18082. '&': '&amp;',
  18083. '<': '&lt;',
  18084. '>': '&gt;',
  18085. '"': '&quot;',
  18086. "'": '&#39;'
  18087. };
  18088. /** Used to map HTML entities to characters. */
  18089. var htmlUnescapes = {
  18090. '&amp;': '&',
  18091. '&lt;': '<',
  18092. '&gt;': '>',
  18093. '&quot;': '"',
  18094. '&#39;': "'"
  18095. };
  18096. /** Used to escape characters for inclusion in compiled string literals. */
  18097. var stringEscapes = {
  18098. '\\': '\\',
  18099. "'": "'",
  18100. '\n': 'n',
  18101. '\r': 'r',
  18102. '\u2028': 'u2028',
  18103. '\u2029': 'u2029'
  18104. };
  18105. /** Built-in method references without a dependency on `root`. */
  18106. var freeParseFloat = parseFloat,
  18107. freeParseInt = parseInt;
  18108. /** Detect free variable `global` from Node.js. */
  18109. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  18110. /** Detect free variable `self`. */
  18111. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  18112. /** Used as a reference to the global object. */
  18113. var root = freeGlobal || freeSelf || Function('return this')();
  18114. /** Detect free variable `exports`. */
  18115. var freeExports = true && exports && !exports.nodeType && exports;
  18116. /** Detect free variable `module`. */
  18117. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  18118. /** Detect the popular CommonJS extension `module.exports`. */
  18119. var moduleExports = freeModule && freeModule.exports === freeExports;
  18120. /** Detect free variable `process` from Node.js. */
  18121. var freeProcess = moduleExports && freeGlobal.process;
  18122. /** Used to access faster Node.js helpers. */
  18123. var nodeUtil = (function() {
  18124. try {
  18125. // Use `util.types` for Node.js 10+.
  18126. var types = freeModule && freeModule.require && freeModule.require('util').types;
  18127. if (types) {
  18128. return types;
  18129. }
  18130. // Legacy `process.binding('util')` for Node.js < 10.
  18131. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  18132. } catch (e) {}
  18133. }());
  18134. /* Node.js helper references. */
  18135. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  18136. nodeIsDate = nodeUtil && nodeUtil.isDate,
  18137. nodeIsMap = nodeUtil && nodeUtil.isMap,
  18138. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  18139. nodeIsSet = nodeUtil && nodeUtil.isSet,
  18140. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  18141. /*--------------------------------------------------------------------------*/
  18142. /**
  18143. * A faster alternative to `Function#apply`, this function invokes `func`
  18144. * with the `this` binding of `thisArg` and the arguments of `args`.
  18145. *
  18146. * @private
  18147. * @param {Function} func The function to invoke.
  18148. * @param {*} thisArg The `this` binding of `func`.
  18149. * @param {Array} args The arguments to invoke `func` with.
  18150. * @returns {*} Returns the result of `func`.
  18151. */
  18152. function apply(func, thisArg, args) {
  18153. switch (args.length) {
  18154. case 0: return func.call(thisArg);
  18155. case 1: return func.call(thisArg, args[0]);
  18156. case 2: return func.call(thisArg, args[0], args[1]);
  18157. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  18158. }
  18159. return func.apply(thisArg, args);
  18160. }
  18161. /**
  18162. * A specialized version of `baseAggregator` for arrays.
  18163. *
  18164. * @private
  18165. * @param {Array} [array] The array to iterate over.
  18166. * @param {Function} setter The function to set `accumulator` values.
  18167. * @param {Function} iteratee The iteratee to transform keys.
  18168. * @param {Object} accumulator The initial aggregated object.
  18169. * @returns {Function} Returns `accumulator`.
  18170. */
  18171. function arrayAggregator(array, setter, iteratee, accumulator) {
  18172. var index = -1,
  18173. length = array == null ? 0 : array.length;
  18174. while (++index < length) {
  18175. var value = array[index];
  18176. setter(accumulator, value, iteratee(value), array);
  18177. }
  18178. return accumulator;
  18179. }
  18180. /**
  18181. * A specialized version of `_.forEach` for arrays without support for
  18182. * iteratee shorthands.
  18183. *
  18184. * @private
  18185. * @param {Array} [array] The array to iterate over.
  18186. * @param {Function} iteratee The function invoked per iteration.
  18187. * @returns {Array} Returns `array`.
  18188. */
  18189. function arrayEach(array, iteratee) {
  18190. var index = -1,
  18191. length = array == null ? 0 : array.length;
  18192. while (++index < length) {
  18193. if (iteratee(array[index], index, array) === false) {
  18194. break;
  18195. }
  18196. }
  18197. return array;
  18198. }
  18199. /**
  18200. * A specialized version of `_.forEachRight` for arrays without support for
  18201. * iteratee shorthands.
  18202. *
  18203. * @private
  18204. * @param {Array} [array] The array to iterate over.
  18205. * @param {Function} iteratee The function invoked per iteration.
  18206. * @returns {Array} Returns `array`.
  18207. */
  18208. function arrayEachRight(array, iteratee) {
  18209. var length = array == null ? 0 : array.length;
  18210. while (length--) {
  18211. if (iteratee(array[length], length, array) === false) {
  18212. break;
  18213. }
  18214. }
  18215. return array;
  18216. }
  18217. /**
  18218. * A specialized version of `_.every` for arrays without support for
  18219. * iteratee shorthands.
  18220. *
  18221. * @private
  18222. * @param {Array} [array] The array to iterate over.
  18223. * @param {Function} predicate The function invoked per iteration.
  18224. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  18225. * else `false`.
  18226. */
  18227. function arrayEvery(array, predicate) {
  18228. var index = -1,
  18229. length = array == null ? 0 : array.length;
  18230. while (++index < length) {
  18231. if (!predicate(array[index], index, array)) {
  18232. return false;
  18233. }
  18234. }
  18235. return true;
  18236. }
  18237. /**
  18238. * A specialized version of `_.filter` for arrays without support for
  18239. * iteratee shorthands.
  18240. *
  18241. * @private
  18242. * @param {Array} [array] The array to iterate over.
  18243. * @param {Function} predicate The function invoked per iteration.
  18244. * @returns {Array} Returns the new filtered array.
  18245. */
  18246. function arrayFilter(array, predicate) {
  18247. var index = -1,
  18248. length = array == null ? 0 : array.length,
  18249. resIndex = 0,
  18250. result = [];
  18251. while (++index < length) {
  18252. var value = array[index];
  18253. if (predicate(value, index, array)) {
  18254. result[resIndex++] = value;
  18255. }
  18256. }
  18257. return result;
  18258. }
  18259. /**
  18260. * A specialized version of `_.includes` for arrays without support for
  18261. * specifying an index to search from.
  18262. *
  18263. * @private
  18264. * @param {Array} [array] The array to inspect.
  18265. * @param {*} target The value to search for.
  18266. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18267. */
  18268. function arrayIncludes(array, value) {
  18269. var length = array == null ? 0 : array.length;
  18270. return !!length && baseIndexOf(array, value, 0) > -1;
  18271. }
  18272. /**
  18273. * This function is like `arrayIncludes` except that it accepts a comparator.
  18274. *
  18275. * @private
  18276. * @param {Array} [array] The array to inspect.
  18277. * @param {*} target The value to search for.
  18278. * @param {Function} comparator The comparator invoked per element.
  18279. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18280. */
  18281. function arrayIncludesWith(array, value, comparator) {
  18282. var index = -1,
  18283. length = array == null ? 0 : array.length;
  18284. while (++index < length) {
  18285. if (comparator(value, array[index])) {
  18286. return true;
  18287. }
  18288. }
  18289. return false;
  18290. }
  18291. /**
  18292. * A specialized version of `_.map` for arrays without support for iteratee
  18293. * shorthands.
  18294. *
  18295. * @private
  18296. * @param {Array} [array] The array to iterate over.
  18297. * @param {Function} iteratee The function invoked per iteration.
  18298. * @returns {Array} Returns the new mapped array.
  18299. */
  18300. function arrayMap(array, iteratee) {
  18301. var index = -1,
  18302. length = array == null ? 0 : array.length,
  18303. result = Array(length);
  18304. while (++index < length) {
  18305. result[index] = iteratee(array[index], index, array);
  18306. }
  18307. return result;
  18308. }
  18309. /**
  18310. * Appends the elements of `values` to `array`.
  18311. *
  18312. * @private
  18313. * @param {Array} array The array to modify.
  18314. * @param {Array} values The values to append.
  18315. * @returns {Array} Returns `array`.
  18316. */
  18317. function arrayPush(array, values) {
  18318. var index = -1,
  18319. length = values.length,
  18320. offset = array.length;
  18321. while (++index < length) {
  18322. array[offset + index] = values[index];
  18323. }
  18324. return array;
  18325. }
  18326. /**
  18327. * A specialized version of `_.reduce` for arrays without support for
  18328. * iteratee shorthands.
  18329. *
  18330. * @private
  18331. * @param {Array} [array] The array to iterate over.
  18332. * @param {Function} iteratee The function invoked per iteration.
  18333. * @param {*} [accumulator] The initial value.
  18334. * @param {boolean} [initAccum] Specify using the first element of `array` as
  18335. * the initial value.
  18336. * @returns {*} Returns the accumulated value.
  18337. */
  18338. function arrayReduce(array, iteratee, accumulator, initAccum) {
  18339. var index = -1,
  18340. length = array == null ? 0 : array.length;
  18341. if (initAccum && length) {
  18342. accumulator = array[++index];
  18343. }
  18344. while (++index < length) {
  18345. accumulator = iteratee(accumulator, array[index], index, array);
  18346. }
  18347. return accumulator;
  18348. }
  18349. /**
  18350. * A specialized version of `_.reduceRight` for arrays without support for
  18351. * iteratee shorthands.
  18352. *
  18353. * @private
  18354. * @param {Array} [array] The array to iterate over.
  18355. * @param {Function} iteratee The function invoked per iteration.
  18356. * @param {*} [accumulator] The initial value.
  18357. * @param {boolean} [initAccum] Specify using the last element of `array` as
  18358. * the initial value.
  18359. * @returns {*} Returns the accumulated value.
  18360. */
  18361. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  18362. var length = array == null ? 0 : array.length;
  18363. if (initAccum && length) {
  18364. accumulator = array[--length];
  18365. }
  18366. while (length--) {
  18367. accumulator = iteratee(accumulator, array[length], length, array);
  18368. }
  18369. return accumulator;
  18370. }
  18371. /**
  18372. * A specialized version of `_.some` for arrays without support for iteratee
  18373. * shorthands.
  18374. *
  18375. * @private
  18376. * @param {Array} [array] The array to iterate over.
  18377. * @param {Function} predicate The function invoked per iteration.
  18378. * @returns {boolean} Returns `true` if any element passes the predicate check,
  18379. * else `false`.
  18380. */
  18381. function arraySome(array, predicate) {
  18382. var index = -1,
  18383. length = array == null ? 0 : array.length;
  18384. while (++index < length) {
  18385. if (predicate(array[index], index, array)) {
  18386. return true;
  18387. }
  18388. }
  18389. return false;
  18390. }
  18391. /**
  18392. * Gets the size of an ASCII `string`.
  18393. *
  18394. * @private
  18395. * @param {string} string The string inspect.
  18396. * @returns {number} Returns the string size.
  18397. */
  18398. var asciiSize = baseProperty('length');
  18399. /**
  18400. * Converts an ASCII `string` to an array.
  18401. *
  18402. * @private
  18403. * @param {string} string The string to convert.
  18404. * @returns {Array} Returns the converted array.
  18405. */
  18406. function asciiToArray(string) {
  18407. return string.split('');
  18408. }
  18409. /**
  18410. * Splits an ASCII `string` into an array of its words.
  18411. *
  18412. * @private
  18413. * @param {string} The string to inspect.
  18414. * @returns {Array} Returns the words of `string`.
  18415. */
  18416. function asciiWords(string) {
  18417. return string.match(reAsciiWord) || [];
  18418. }
  18419. /**
  18420. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  18421. * without support for iteratee shorthands, which iterates over `collection`
  18422. * using `eachFunc`.
  18423. *
  18424. * @private
  18425. * @param {Array|Object} collection The collection to inspect.
  18426. * @param {Function} predicate The function invoked per iteration.
  18427. * @param {Function} eachFunc The function to iterate over `collection`.
  18428. * @returns {*} Returns the found element or its key, else `undefined`.
  18429. */
  18430. function baseFindKey(collection, predicate, eachFunc) {
  18431. var result;
  18432. eachFunc(collection, function(value, key, collection) {
  18433. if (predicate(value, key, collection)) {
  18434. result = key;
  18435. return false;
  18436. }
  18437. });
  18438. return result;
  18439. }
  18440. /**
  18441. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  18442. * support for iteratee shorthands.
  18443. *
  18444. * @private
  18445. * @param {Array} array The array to inspect.
  18446. * @param {Function} predicate The function invoked per iteration.
  18447. * @param {number} fromIndex The index to search from.
  18448. * @param {boolean} [fromRight] Specify iterating from right to left.
  18449. * @returns {number} Returns the index of the matched value, else `-1`.
  18450. */
  18451. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  18452. var length = array.length,
  18453. index = fromIndex + (fromRight ? 1 : -1);
  18454. while ((fromRight ? index-- : ++index < length)) {
  18455. if (predicate(array[index], index, array)) {
  18456. return index;
  18457. }
  18458. }
  18459. return -1;
  18460. }
  18461. /**
  18462. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  18463. *
  18464. * @private
  18465. * @param {Array} array The array to inspect.
  18466. * @param {*} value The value to search for.
  18467. * @param {number} fromIndex The index to search from.
  18468. * @returns {number} Returns the index of the matched value, else `-1`.
  18469. */
  18470. function baseIndexOf(array, value, fromIndex) {
  18471. return value === value
  18472. ? strictIndexOf(array, value, fromIndex)
  18473. : baseFindIndex(array, baseIsNaN, fromIndex);
  18474. }
  18475. /**
  18476. * This function is like `baseIndexOf` except that it accepts a comparator.
  18477. *
  18478. * @private
  18479. * @param {Array} array The array to inspect.
  18480. * @param {*} value The value to search for.
  18481. * @param {number} fromIndex The index to search from.
  18482. * @param {Function} comparator The comparator invoked per element.
  18483. * @returns {number} Returns the index of the matched value, else `-1`.
  18484. */
  18485. function baseIndexOfWith(array, value, fromIndex, comparator) {
  18486. var index = fromIndex - 1,
  18487. length = array.length;
  18488. while (++index < length) {
  18489. if (comparator(array[index], value)) {
  18490. return index;
  18491. }
  18492. }
  18493. return -1;
  18494. }
  18495. /**
  18496. * The base implementation of `_.isNaN` without support for number objects.
  18497. *
  18498. * @private
  18499. * @param {*} value The value to check.
  18500. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  18501. */
  18502. function baseIsNaN(value) {
  18503. return value !== value;
  18504. }
  18505. /**
  18506. * The base implementation of `_.mean` and `_.meanBy` without support for
  18507. * iteratee shorthands.
  18508. *
  18509. * @private
  18510. * @param {Array} array The array to iterate over.
  18511. * @param {Function} iteratee The function invoked per iteration.
  18512. * @returns {number} Returns the mean.
  18513. */
  18514. function baseMean(array, iteratee) {
  18515. var length = array == null ? 0 : array.length;
  18516. return length ? (baseSum(array, iteratee) / length) : NAN;
  18517. }
  18518. /**
  18519. * The base implementation of `_.property` without support for deep paths.
  18520. *
  18521. * @private
  18522. * @param {string} key The key of the property to get.
  18523. * @returns {Function} Returns the new accessor function.
  18524. */
  18525. function baseProperty(key) {
  18526. return function(object) {
  18527. return object == null ? undefined : object[key];
  18528. };
  18529. }
  18530. /**
  18531. * The base implementation of `_.propertyOf` without support for deep paths.
  18532. *
  18533. * @private
  18534. * @param {Object} object The object to query.
  18535. * @returns {Function} Returns the new accessor function.
  18536. */
  18537. function basePropertyOf(object) {
  18538. return function(key) {
  18539. return object == null ? undefined : object[key];
  18540. };
  18541. }
  18542. /**
  18543. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  18544. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  18545. *
  18546. * @private
  18547. * @param {Array|Object} collection The collection to iterate over.
  18548. * @param {Function} iteratee The function invoked per iteration.
  18549. * @param {*} accumulator The initial value.
  18550. * @param {boolean} initAccum Specify using the first or last element of
  18551. * `collection` as the initial value.
  18552. * @param {Function} eachFunc The function to iterate over `collection`.
  18553. * @returns {*} Returns the accumulated value.
  18554. */
  18555. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  18556. eachFunc(collection, function(value, index, collection) {
  18557. accumulator = initAccum
  18558. ? (initAccum = false, value)
  18559. : iteratee(accumulator, value, index, collection);
  18560. });
  18561. return accumulator;
  18562. }
  18563. /**
  18564. * The base implementation of `_.sortBy` which uses `comparer` to define the
  18565. * sort order of `array` and replaces criteria objects with their corresponding
  18566. * values.
  18567. *
  18568. * @private
  18569. * @param {Array} array The array to sort.
  18570. * @param {Function} comparer The function to define sort order.
  18571. * @returns {Array} Returns `array`.
  18572. */
  18573. function baseSortBy(array, comparer) {
  18574. var length = array.length;
  18575. array.sort(comparer);
  18576. while (length--) {
  18577. array[length] = array[length].value;
  18578. }
  18579. return array;
  18580. }
  18581. /**
  18582. * The base implementation of `_.sum` and `_.sumBy` without support for
  18583. * iteratee shorthands.
  18584. *
  18585. * @private
  18586. * @param {Array} array The array to iterate over.
  18587. * @param {Function} iteratee The function invoked per iteration.
  18588. * @returns {number} Returns the sum.
  18589. */
  18590. function baseSum(array, iteratee) {
  18591. var result,
  18592. index = -1,
  18593. length = array.length;
  18594. while (++index < length) {
  18595. var current = iteratee(array[index]);
  18596. if (current !== undefined) {
  18597. result = result === undefined ? current : (result + current);
  18598. }
  18599. }
  18600. return result;
  18601. }
  18602. /**
  18603. * The base implementation of `_.times` without support for iteratee shorthands
  18604. * or max array length checks.
  18605. *
  18606. * @private
  18607. * @param {number} n The number of times to invoke `iteratee`.
  18608. * @param {Function} iteratee The function invoked per iteration.
  18609. * @returns {Array} Returns the array of results.
  18610. */
  18611. function baseTimes(n, iteratee) {
  18612. var index = -1,
  18613. result = Array(n);
  18614. while (++index < n) {
  18615. result[index] = iteratee(index);
  18616. }
  18617. return result;
  18618. }
  18619. /**
  18620. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  18621. * of key-value pairs for `object` corresponding to the property names of `props`.
  18622. *
  18623. * @private
  18624. * @param {Object} object The object to query.
  18625. * @param {Array} props The property names to get values for.
  18626. * @returns {Object} Returns the key-value pairs.
  18627. */
  18628. function baseToPairs(object, props) {
  18629. return arrayMap(props, function(key) {
  18630. return [key, object[key]];
  18631. });
  18632. }
  18633. /**
  18634. * The base implementation of `_.unary` without support for storing metadata.
  18635. *
  18636. * @private
  18637. * @param {Function} func The function to cap arguments for.
  18638. * @returns {Function} Returns the new capped function.
  18639. */
  18640. function baseUnary(func) {
  18641. return function(value) {
  18642. return func(value);
  18643. };
  18644. }
  18645. /**
  18646. * The base implementation of `_.values` and `_.valuesIn` which creates an
  18647. * array of `object` property values corresponding to the property names
  18648. * of `props`.
  18649. *
  18650. * @private
  18651. * @param {Object} object The object to query.
  18652. * @param {Array} props The property names to get values for.
  18653. * @returns {Object} Returns the array of property values.
  18654. */
  18655. function baseValues(object, props) {
  18656. return arrayMap(props, function(key) {
  18657. return object[key];
  18658. });
  18659. }
  18660. /**
  18661. * Checks if a `cache` value for `key` exists.
  18662. *
  18663. * @private
  18664. * @param {Object} cache The cache to query.
  18665. * @param {string} key The key of the entry to check.
  18666. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18667. */
  18668. function cacheHas(cache, key) {
  18669. return cache.has(key);
  18670. }
  18671. /**
  18672. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  18673. * that is not found in the character symbols.
  18674. *
  18675. * @private
  18676. * @param {Array} strSymbols The string symbols to inspect.
  18677. * @param {Array} chrSymbols The character symbols to find.
  18678. * @returns {number} Returns the index of the first unmatched string symbol.
  18679. */
  18680. function charsStartIndex(strSymbols, chrSymbols) {
  18681. var index = -1,
  18682. length = strSymbols.length;
  18683. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18684. return index;
  18685. }
  18686. /**
  18687. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  18688. * that is not found in the character symbols.
  18689. *
  18690. * @private
  18691. * @param {Array} strSymbols The string symbols to inspect.
  18692. * @param {Array} chrSymbols The character symbols to find.
  18693. * @returns {number} Returns the index of the last unmatched string symbol.
  18694. */
  18695. function charsEndIndex(strSymbols, chrSymbols) {
  18696. var index = strSymbols.length;
  18697. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18698. return index;
  18699. }
  18700. /**
  18701. * Gets the number of `placeholder` occurrences in `array`.
  18702. *
  18703. * @private
  18704. * @param {Array} array The array to inspect.
  18705. * @param {*} placeholder The placeholder to search for.
  18706. * @returns {number} Returns the placeholder count.
  18707. */
  18708. function countHolders(array, placeholder) {
  18709. var length = array.length,
  18710. result = 0;
  18711. while (length--) {
  18712. if (array[length] === placeholder) {
  18713. ++result;
  18714. }
  18715. }
  18716. return result;
  18717. }
  18718. /**
  18719. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  18720. * letters to basic Latin letters.
  18721. *
  18722. * @private
  18723. * @param {string} letter The matched letter to deburr.
  18724. * @returns {string} Returns the deburred letter.
  18725. */
  18726. var deburrLetter = basePropertyOf(deburredLetters);
  18727. /**
  18728. * Used by `_.escape` to convert characters to HTML entities.
  18729. *
  18730. * @private
  18731. * @param {string} chr The matched character to escape.
  18732. * @returns {string} Returns the escaped character.
  18733. */
  18734. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  18735. /**
  18736. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  18737. *
  18738. * @private
  18739. * @param {string} chr The matched character to escape.
  18740. * @returns {string} Returns the escaped character.
  18741. */
  18742. function escapeStringChar(chr) {
  18743. return '\\' + stringEscapes[chr];
  18744. }
  18745. /**
  18746. * Gets the value at `key` of `object`.
  18747. *
  18748. * @private
  18749. * @param {Object} [object] The object to query.
  18750. * @param {string} key The key of the property to get.
  18751. * @returns {*} Returns the property value.
  18752. */
  18753. function getValue(object, key) {
  18754. return object == null ? undefined : object[key];
  18755. }
  18756. /**
  18757. * Checks if `string` contains Unicode symbols.
  18758. *
  18759. * @private
  18760. * @param {string} string The string to inspect.
  18761. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  18762. */
  18763. function hasUnicode(string) {
  18764. return reHasUnicode.test(string);
  18765. }
  18766. /**
  18767. * Checks if `string` contains a word composed of Unicode symbols.
  18768. *
  18769. * @private
  18770. * @param {string} string The string to inspect.
  18771. * @returns {boolean} Returns `true` if a word is found, else `false`.
  18772. */
  18773. function hasUnicodeWord(string) {
  18774. return reHasUnicodeWord.test(string);
  18775. }
  18776. /**
  18777. * Converts `iterator` to an array.
  18778. *
  18779. * @private
  18780. * @param {Object} iterator The iterator to convert.
  18781. * @returns {Array} Returns the converted array.
  18782. */
  18783. function iteratorToArray(iterator) {
  18784. var data,
  18785. result = [];
  18786. while (!(data = iterator.next()).done) {
  18787. result.push(data.value);
  18788. }
  18789. return result;
  18790. }
  18791. /**
  18792. * Converts `map` to its key-value pairs.
  18793. *
  18794. * @private
  18795. * @param {Object} map The map to convert.
  18796. * @returns {Array} Returns the key-value pairs.
  18797. */
  18798. function mapToArray(map) {
  18799. var index = -1,
  18800. result = Array(map.size);
  18801. map.forEach(function(value, key) {
  18802. result[++index] = [key, value];
  18803. });
  18804. return result;
  18805. }
  18806. /**
  18807. * Creates a unary function that invokes `func` with its argument transformed.
  18808. *
  18809. * @private
  18810. * @param {Function} func The function to wrap.
  18811. * @param {Function} transform The argument transform.
  18812. * @returns {Function} Returns the new function.
  18813. */
  18814. function overArg(func, transform) {
  18815. return function(arg) {
  18816. return func(transform(arg));
  18817. };
  18818. }
  18819. /**
  18820. * Replaces all `placeholder` elements in `array` with an internal placeholder
  18821. * and returns an array of their indexes.
  18822. *
  18823. * @private
  18824. * @param {Array} array The array to modify.
  18825. * @param {*} placeholder The placeholder to replace.
  18826. * @returns {Array} Returns the new array of placeholder indexes.
  18827. */
  18828. function replaceHolders(array, placeholder) {
  18829. var index = -1,
  18830. length = array.length,
  18831. resIndex = 0,
  18832. result = [];
  18833. while (++index < length) {
  18834. var value = array[index];
  18835. if (value === placeholder || value === PLACEHOLDER) {
  18836. array[index] = PLACEHOLDER;
  18837. result[resIndex++] = index;
  18838. }
  18839. }
  18840. return result;
  18841. }
  18842. /**
  18843. * Converts `set` to an array of its values.
  18844. *
  18845. * @private
  18846. * @param {Object} set The set to convert.
  18847. * @returns {Array} Returns the values.
  18848. */
  18849. function setToArray(set) {
  18850. var index = -1,
  18851. result = Array(set.size);
  18852. set.forEach(function(value) {
  18853. result[++index] = value;
  18854. });
  18855. return result;
  18856. }
  18857. /**
  18858. * Converts `set` to its value-value pairs.
  18859. *
  18860. * @private
  18861. * @param {Object} set The set to convert.
  18862. * @returns {Array} Returns the value-value pairs.
  18863. */
  18864. function setToPairs(set) {
  18865. var index = -1,
  18866. result = Array(set.size);
  18867. set.forEach(function(value) {
  18868. result[++index] = [value, value];
  18869. });
  18870. return result;
  18871. }
  18872. /**
  18873. * A specialized version of `_.indexOf` which performs strict equality
  18874. * comparisons of values, i.e. `===`.
  18875. *
  18876. * @private
  18877. * @param {Array} array The array to inspect.
  18878. * @param {*} value The value to search for.
  18879. * @param {number} fromIndex The index to search from.
  18880. * @returns {number} Returns the index of the matched value, else `-1`.
  18881. */
  18882. function strictIndexOf(array, value, fromIndex) {
  18883. var index = fromIndex - 1,
  18884. length = array.length;
  18885. while (++index < length) {
  18886. if (array[index] === value) {
  18887. return index;
  18888. }
  18889. }
  18890. return -1;
  18891. }
  18892. /**
  18893. * A specialized version of `_.lastIndexOf` which performs strict equality
  18894. * comparisons of values, i.e. `===`.
  18895. *
  18896. * @private
  18897. * @param {Array} array The array to inspect.
  18898. * @param {*} value The value to search for.
  18899. * @param {number} fromIndex The index to search from.
  18900. * @returns {number} Returns the index of the matched value, else `-1`.
  18901. */
  18902. function strictLastIndexOf(array, value, fromIndex) {
  18903. var index = fromIndex + 1;
  18904. while (index--) {
  18905. if (array[index] === value) {
  18906. return index;
  18907. }
  18908. }
  18909. return index;
  18910. }
  18911. /**
  18912. * Gets the number of symbols in `string`.
  18913. *
  18914. * @private
  18915. * @param {string} string The string to inspect.
  18916. * @returns {number} Returns the string size.
  18917. */
  18918. function stringSize(string) {
  18919. return hasUnicode(string)
  18920. ? unicodeSize(string)
  18921. : asciiSize(string);
  18922. }
  18923. /**
  18924. * Converts `string` to an array.
  18925. *
  18926. * @private
  18927. * @param {string} string The string to convert.
  18928. * @returns {Array} Returns the converted array.
  18929. */
  18930. function stringToArray(string) {
  18931. return hasUnicode(string)
  18932. ? unicodeToArray(string)
  18933. : asciiToArray(string);
  18934. }
  18935. /**
  18936. * Used by `_.unescape` to convert HTML entities to characters.
  18937. *
  18938. * @private
  18939. * @param {string} chr The matched character to unescape.
  18940. * @returns {string} Returns the unescaped character.
  18941. */
  18942. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  18943. /**
  18944. * Gets the size of a Unicode `string`.
  18945. *
  18946. * @private
  18947. * @param {string} string The string inspect.
  18948. * @returns {number} Returns the string size.
  18949. */
  18950. function unicodeSize(string) {
  18951. var result = reUnicode.lastIndex = 0;
  18952. while (reUnicode.test(string)) {
  18953. ++result;
  18954. }
  18955. return result;
  18956. }
  18957. /**
  18958. * Converts a Unicode `string` to an array.
  18959. *
  18960. * @private
  18961. * @param {string} string The string to convert.
  18962. * @returns {Array} Returns the converted array.
  18963. */
  18964. function unicodeToArray(string) {
  18965. return string.match(reUnicode) || [];
  18966. }
  18967. /**
  18968. * Splits a Unicode `string` into an array of its words.
  18969. *
  18970. * @private
  18971. * @param {string} The string to inspect.
  18972. * @returns {Array} Returns the words of `string`.
  18973. */
  18974. function unicodeWords(string) {
  18975. return string.match(reUnicodeWord) || [];
  18976. }
  18977. /*--------------------------------------------------------------------------*/
  18978. /**
  18979. * Create a new pristine `lodash` function using the `context` object.
  18980. *
  18981. * @static
  18982. * @memberOf _
  18983. * @since 1.1.0
  18984. * @category Util
  18985. * @param {Object} [context=root] The context object.
  18986. * @returns {Function} Returns a new `lodash` function.
  18987. * @example
  18988. *
  18989. * _.mixin({ 'foo': _.constant('foo') });
  18990. *
  18991. * var lodash = _.runInContext();
  18992. * lodash.mixin({ 'bar': lodash.constant('bar') });
  18993. *
  18994. * _.isFunction(_.foo);
  18995. * // => true
  18996. * _.isFunction(_.bar);
  18997. * // => false
  18998. *
  18999. * lodash.isFunction(lodash.foo);
  19000. * // => false
  19001. * lodash.isFunction(lodash.bar);
  19002. * // => true
  19003. *
  19004. * // Create a suped-up `defer` in Node.js.
  19005. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  19006. */
  19007. var runInContext = (function runInContext(context) {
  19008. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  19009. /** Built-in constructor references. */
  19010. var Array = context.Array,
  19011. Date = context.Date,
  19012. Error = context.Error,
  19013. Function = context.Function,
  19014. Math = context.Math,
  19015. Object = context.Object,
  19016. RegExp = context.RegExp,
  19017. String = context.String,
  19018. TypeError = context.TypeError;
  19019. /** Used for built-in method references. */
  19020. var arrayProto = Array.prototype,
  19021. funcProto = Function.prototype,
  19022. objectProto = Object.prototype;
  19023. /** Used to detect overreaching core-js shims. */
  19024. var coreJsData = context['__core-js_shared__'];
  19025. /** Used to resolve the decompiled source of functions. */
  19026. var funcToString = funcProto.toString;
  19027. /** Used to check objects for own properties. */
  19028. var hasOwnProperty = objectProto.hasOwnProperty;
  19029. /** Used to generate unique IDs. */
  19030. var idCounter = 0;
  19031. /** Used to detect methods masquerading as native. */
  19032. var maskSrcKey = (function() {
  19033. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  19034. return uid ? ('Symbol(src)_1.' + uid) : '';
  19035. }());
  19036. /**
  19037. * Used to resolve the
  19038. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  19039. * of values.
  19040. */
  19041. var nativeObjectToString = objectProto.toString;
  19042. /** Used to infer the `Object` constructor. */
  19043. var objectCtorString = funcToString.call(Object);
  19044. /** Used to restore the original `_` reference in `_.noConflict`. */
  19045. var oldDash = root._;
  19046. /** Used to detect if a method is native. */
  19047. var reIsNative = RegExp('^' +
  19048. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  19049. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  19050. );
  19051. /** Built-in value references. */
  19052. var Buffer = moduleExports ? context.Buffer : undefined,
  19053. Symbol = context.Symbol,
  19054. Uint8Array = context.Uint8Array,
  19055. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  19056. getPrototype = overArg(Object.getPrototypeOf, Object),
  19057. objectCreate = Object.create,
  19058. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  19059. splice = arrayProto.splice,
  19060. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  19061. symIterator = Symbol ? Symbol.iterator : undefined,
  19062. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  19063. var defineProperty = (function() {
  19064. try {
  19065. var func = getNative(Object, 'defineProperty');
  19066. func({}, '', {});
  19067. return func;
  19068. } catch (e) {}
  19069. }());
  19070. /** Mocked built-ins. */
  19071. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  19072. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  19073. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  19074. /* Built-in method references for those with the same name as other `lodash` methods. */
  19075. var nativeCeil = Math.ceil,
  19076. nativeFloor = Math.floor,
  19077. nativeGetSymbols = Object.getOwnPropertySymbols,
  19078. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  19079. nativeIsFinite = context.isFinite,
  19080. nativeJoin = arrayProto.join,
  19081. nativeKeys = overArg(Object.keys, Object),
  19082. nativeMax = Math.max,
  19083. nativeMin = Math.min,
  19084. nativeNow = Date.now,
  19085. nativeParseInt = context.parseInt,
  19086. nativeRandom = Math.random,
  19087. nativeReverse = arrayProto.reverse;
  19088. /* Built-in method references that are verified to be native. */
  19089. var DataView = getNative(context, 'DataView'),
  19090. Map = getNative(context, 'Map'),
  19091. Promise = getNative(context, 'Promise'),
  19092. Set = getNative(context, 'Set'),
  19093. WeakMap = getNative(context, 'WeakMap'),
  19094. nativeCreate = getNative(Object, 'create');
  19095. /** Used to store function metadata. */
  19096. var metaMap = WeakMap && new WeakMap;
  19097. /** Used to lookup unminified function names. */
  19098. var realNames = {};
  19099. /** Used to detect maps, sets, and weakmaps. */
  19100. var dataViewCtorString = toSource(DataView),
  19101. mapCtorString = toSource(Map),
  19102. promiseCtorString = toSource(Promise),
  19103. setCtorString = toSource(Set),
  19104. weakMapCtorString = toSource(WeakMap);
  19105. /** Used to convert symbols to primitives and strings. */
  19106. var symbolProto = Symbol ? Symbol.prototype : undefined,
  19107. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  19108. symbolToString = symbolProto ? symbolProto.toString : undefined;
  19109. /*------------------------------------------------------------------------*/
  19110. /**
  19111. * Creates a `lodash` object which wraps `value` to enable implicit method
  19112. * chain sequences. Methods that operate on and return arrays, collections,
  19113. * and functions can be chained together. Methods that retrieve a single value
  19114. * or may return a primitive value will automatically end the chain sequence
  19115. * and return the unwrapped value. Otherwise, the value must be unwrapped
  19116. * with `_#value`.
  19117. *
  19118. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  19119. * enabled using `_.chain`.
  19120. *
  19121. * The execution of chained methods is lazy, that is, it's deferred until
  19122. * `_#value` is implicitly or explicitly called.
  19123. *
  19124. * Lazy evaluation allows several methods to support shortcut fusion.
  19125. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  19126. * the creation of intermediate arrays and can greatly reduce the number of
  19127. * iteratee executions. Sections of a chain sequence qualify for shortcut
  19128. * fusion if the section is applied to an array and iteratees accept only
  19129. * one argument. The heuristic for whether a section qualifies for shortcut
  19130. * fusion is subject to change.
  19131. *
  19132. * Chaining is supported in custom builds as long as the `_#value` method is
  19133. * directly or indirectly included in the build.
  19134. *
  19135. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  19136. *
  19137. * The wrapper `Array` methods are:
  19138. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  19139. *
  19140. * The wrapper `String` methods are:
  19141. * `replace` and `split`
  19142. *
  19143. * The wrapper methods that support shortcut fusion are:
  19144. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  19145. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  19146. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  19147. *
  19148. * The chainable wrapper methods are:
  19149. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  19150. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  19151. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  19152. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  19153. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  19154. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  19155. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  19156. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  19157. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  19158. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  19159. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  19160. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  19161. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  19162. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  19163. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  19164. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  19165. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  19166. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  19167. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  19168. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  19169. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  19170. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  19171. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  19172. * `zipObject`, `zipObjectDeep`, and `zipWith`
  19173. *
  19174. * The wrapper methods that are **not** chainable by default are:
  19175. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  19176. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  19177. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  19178. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  19179. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  19180. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  19181. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  19182. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  19183. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  19184. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  19185. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  19186. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  19187. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  19188. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  19189. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  19190. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  19191. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  19192. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  19193. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  19194. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  19195. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  19196. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  19197. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  19198. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  19199. * `upperFirst`, `value`, and `words`
  19200. *
  19201. * @name _
  19202. * @constructor
  19203. * @category Seq
  19204. * @param {*} value The value to wrap in a `lodash` instance.
  19205. * @returns {Object} Returns the new `lodash` wrapper instance.
  19206. * @example
  19207. *
  19208. * function square(n) {
  19209. * return n * n;
  19210. * }
  19211. *
  19212. * var wrapped = _([1, 2, 3]);
  19213. *
  19214. * // Returns an unwrapped value.
  19215. * wrapped.reduce(_.add);
  19216. * // => 6
  19217. *
  19218. * // Returns a wrapped value.
  19219. * var squares = wrapped.map(square);
  19220. *
  19221. * _.isArray(squares);
  19222. * // => false
  19223. *
  19224. * _.isArray(squares.value());
  19225. * // => true
  19226. */
  19227. function lodash(value) {
  19228. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  19229. if (value instanceof LodashWrapper) {
  19230. return value;
  19231. }
  19232. if (hasOwnProperty.call(value, '__wrapped__')) {
  19233. return wrapperClone(value);
  19234. }
  19235. }
  19236. return new LodashWrapper(value);
  19237. }
  19238. /**
  19239. * The base implementation of `_.create` without support for assigning
  19240. * properties to the created object.
  19241. *
  19242. * @private
  19243. * @param {Object} proto The object to inherit from.
  19244. * @returns {Object} Returns the new object.
  19245. */
  19246. var baseCreate = (function() {
  19247. function object() {}
  19248. return function(proto) {
  19249. if (!isObject(proto)) {
  19250. return {};
  19251. }
  19252. if (objectCreate) {
  19253. return objectCreate(proto);
  19254. }
  19255. object.prototype = proto;
  19256. var result = new object;
  19257. object.prototype = undefined;
  19258. return result;
  19259. };
  19260. }());
  19261. /**
  19262. * The function whose prototype chain sequence wrappers inherit from.
  19263. *
  19264. * @private
  19265. */
  19266. function baseLodash() {
  19267. // No operation performed.
  19268. }
  19269. /**
  19270. * The base constructor for creating `lodash` wrapper objects.
  19271. *
  19272. * @private
  19273. * @param {*} value The value to wrap.
  19274. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  19275. */
  19276. function LodashWrapper(value, chainAll) {
  19277. this.__wrapped__ = value;
  19278. this.__actions__ = [];
  19279. this.__chain__ = !!chainAll;
  19280. this.__index__ = 0;
  19281. this.__values__ = undefined;
  19282. }
  19283. /**
  19284. * By default, the template delimiters used by lodash are like those in
  19285. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  19286. * following template settings to use alternative delimiters.
  19287. *
  19288. * @static
  19289. * @memberOf _
  19290. * @type {Object}
  19291. */
  19292. lodash.templateSettings = {
  19293. /**
  19294. * Used to detect `data` property values to be HTML-escaped.
  19295. *
  19296. * @memberOf _.templateSettings
  19297. * @type {RegExp}
  19298. */
  19299. 'escape': reEscape,
  19300. /**
  19301. * Used to detect code to be evaluated.
  19302. *
  19303. * @memberOf _.templateSettings
  19304. * @type {RegExp}
  19305. */
  19306. 'evaluate': reEvaluate,
  19307. /**
  19308. * Used to detect `data` property values to inject.
  19309. *
  19310. * @memberOf _.templateSettings
  19311. * @type {RegExp}
  19312. */
  19313. 'interpolate': reInterpolate,
  19314. /**
  19315. * Used to reference the data object in the template text.
  19316. *
  19317. * @memberOf _.templateSettings
  19318. * @type {string}
  19319. */
  19320. 'variable': '',
  19321. /**
  19322. * Used to import variables into the compiled template.
  19323. *
  19324. * @memberOf _.templateSettings
  19325. * @type {Object}
  19326. */
  19327. 'imports': {
  19328. /**
  19329. * A reference to the `lodash` function.
  19330. *
  19331. * @memberOf _.templateSettings.imports
  19332. * @type {Function}
  19333. */
  19334. '_': lodash
  19335. }
  19336. };
  19337. // Ensure wrappers are instances of `baseLodash`.
  19338. lodash.prototype = baseLodash.prototype;
  19339. lodash.prototype.constructor = lodash;
  19340. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  19341. LodashWrapper.prototype.constructor = LodashWrapper;
  19342. /*------------------------------------------------------------------------*/
  19343. /**
  19344. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  19345. *
  19346. * @private
  19347. * @constructor
  19348. * @param {*} value The value to wrap.
  19349. */
  19350. function LazyWrapper(value) {
  19351. this.__wrapped__ = value;
  19352. this.__actions__ = [];
  19353. this.__dir__ = 1;
  19354. this.__filtered__ = false;
  19355. this.__iteratees__ = [];
  19356. this.__takeCount__ = MAX_ARRAY_LENGTH;
  19357. this.__views__ = [];
  19358. }
  19359. /**
  19360. * Creates a clone of the lazy wrapper object.
  19361. *
  19362. * @private
  19363. * @name clone
  19364. * @memberOf LazyWrapper
  19365. * @returns {Object} Returns the cloned `LazyWrapper` object.
  19366. */
  19367. function lazyClone() {
  19368. var result = new LazyWrapper(this.__wrapped__);
  19369. result.__actions__ = copyArray(this.__actions__);
  19370. result.__dir__ = this.__dir__;
  19371. result.__filtered__ = this.__filtered__;
  19372. result.__iteratees__ = copyArray(this.__iteratees__);
  19373. result.__takeCount__ = this.__takeCount__;
  19374. result.__views__ = copyArray(this.__views__);
  19375. return result;
  19376. }
  19377. /**
  19378. * Reverses the direction of lazy iteration.
  19379. *
  19380. * @private
  19381. * @name reverse
  19382. * @memberOf LazyWrapper
  19383. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  19384. */
  19385. function lazyReverse() {
  19386. if (this.__filtered__) {
  19387. var result = new LazyWrapper(this);
  19388. result.__dir__ = -1;
  19389. result.__filtered__ = true;
  19390. } else {
  19391. result = this.clone();
  19392. result.__dir__ *= -1;
  19393. }
  19394. return result;
  19395. }
  19396. /**
  19397. * Extracts the unwrapped value from its lazy wrapper.
  19398. *
  19399. * @private
  19400. * @name value
  19401. * @memberOf LazyWrapper
  19402. * @returns {*} Returns the unwrapped value.
  19403. */
  19404. function lazyValue() {
  19405. var array = this.__wrapped__.value(),
  19406. dir = this.__dir__,
  19407. isArr = isArray(array),
  19408. isRight = dir < 0,
  19409. arrLength = isArr ? array.length : 0,
  19410. view = getView(0, arrLength, this.__views__),
  19411. start = view.start,
  19412. end = view.end,
  19413. length = end - start,
  19414. index = isRight ? end : (start - 1),
  19415. iteratees = this.__iteratees__,
  19416. iterLength = iteratees.length,
  19417. resIndex = 0,
  19418. takeCount = nativeMin(length, this.__takeCount__);
  19419. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  19420. return baseWrapperValue(array, this.__actions__);
  19421. }
  19422. var result = [];
  19423. outer:
  19424. while (length-- && resIndex < takeCount) {
  19425. index += dir;
  19426. var iterIndex = -1,
  19427. value = array[index];
  19428. while (++iterIndex < iterLength) {
  19429. var data = iteratees[iterIndex],
  19430. iteratee = data.iteratee,
  19431. type = data.type,
  19432. computed = iteratee(value);
  19433. if (type == LAZY_MAP_FLAG) {
  19434. value = computed;
  19435. } else if (!computed) {
  19436. if (type == LAZY_FILTER_FLAG) {
  19437. continue outer;
  19438. } else {
  19439. break outer;
  19440. }
  19441. }
  19442. }
  19443. result[resIndex++] = value;
  19444. }
  19445. return result;
  19446. }
  19447. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  19448. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  19449. LazyWrapper.prototype.constructor = LazyWrapper;
  19450. /*------------------------------------------------------------------------*/
  19451. /**
  19452. * Creates a hash object.
  19453. *
  19454. * @private
  19455. * @constructor
  19456. * @param {Array} [entries] The key-value pairs to cache.
  19457. */
  19458. function Hash(entries) {
  19459. var index = -1,
  19460. length = entries == null ? 0 : entries.length;
  19461. this.clear();
  19462. while (++index < length) {
  19463. var entry = entries[index];
  19464. this.set(entry[0], entry[1]);
  19465. }
  19466. }
  19467. /**
  19468. * Removes all key-value entries from the hash.
  19469. *
  19470. * @private
  19471. * @name clear
  19472. * @memberOf Hash
  19473. */
  19474. function hashClear() {
  19475. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  19476. this.size = 0;
  19477. }
  19478. /**
  19479. * Removes `key` and its value from the hash.
  19480. *
  19481. * @private
  19482. * @name delete
  19483. * @memberOf Hash
  19484. * @param {Object} hash The hash to modify.
  19485. * @param {string} key The key of the value to remove.
  19486. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19487. */
  19488. function hashDelete(key) {
  19489. var result = this.has(key) && delete this.__data__[key];
  19490. this.size -= result ? 1 : 0;
  19491. return result;
  19492. }
  19493. /**
  19494. * Gets the hash value for `key`.
  19495. *
  19496. * @private
  19497. * @name get
  19498. * @memberOf Hash
  19499. * @param {string} key The key of the value to get.
  19500. * @returns {*} Returns the entry value.
  19501. */
  19502. function hashGet(key) {
  19503. var data = this.__data__;
  19504. if (nativeCreate) {
  19505. var result = data[key];
  19506. return result === HASH_UNDEFINED ? undefined : result;
  19507. }
  19508. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  19509. }
  19510. /**
  19511. * Checks if a hash value for `key` exists.
  19512. *
  19513. * @private
  19514. * @name has
  19515. * @memberOf Hash
  19516. * @param {string} key The key of the entry to check.
  19517. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19518. */
  19519. function hashHas(key) {
  19520. var data = this.__data__;
  19521. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  19522. }
  19523. /**
  19524. * Sets the hash `key` to `value`.
  19525. *
  19526. * @private
  19527. * @name set
  19528. * @memberOf Hash
  19529. * @param {string} key The key of the value to set.
  19530. * @param {*} value The value to set.
  19531. * @returns {Object} Returns the hash instance.
  19532. */
  19533. function hashSet(key, value) {
  19534. var data = this.__data__;
  19535. this.size += this.has(key) ? 0 : 1;
  19536. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  19537. return this;
  19538. }
  19539. // Add methods to `Hash`.
  19540. Hash.prototype.clear = hashClear;
  19541. Hash.prototype['delete'] = hashDelete;
  19542. Hash.prototype.get = hashGet;
  19543. Hash.prototype.has = hashHas;
  19544. Hash.prototype.set = hashSet;
  19545. /*------------------------------------------------------------------------*/
  19546. /**
  19547. * Creates an list cache object.
  19548. *
  19549. * @private
  19550. * @constructor
  19551. * @param {Array} [entries] The key-value pairs to cache.
  19552. */
  19553. function ListCache(entries) {
  19554. var index = -1,
  19555. length = entries == null ? 0 : entries.length;
  19556. this.clear();
  19557. while (++index < length) {
  19558. var entry = entries[index];
  19559. this.set(entry[0], entry[1]);
  19560. }
  19561. }
  19562. /**
  19563. * Removes all key-value entries from the list cache.
  19564. *
  19565. * @private
  19566. * @name clear
  19567. * @memberOf ListCache
  19568. */
  19569. function listCacheClear() {
  19570. this.__data__ = [];
  19571. this.size = 0;
  19572. }
  19573. /**
  19574. * Removes `key` and its value from the list cache.
  19575. *
  19576. * @private
  19577. * @name delete
  19578. * @memberOf ListCache
  19579. * @param {string} key The key of the value to remove.
  19580. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19581. */
  19582. function listCacheDelete(key) {
  19583. var data = this.__data__,
  19584. index = assocIndexOf(data, key);
  19585. if (index < 0) {
  19586. return false;
  19587. }
  19588. var lastIndex = data.length - 1;
  19589. if (index == lastIndex) {
  19590. data.pop();
  19591. } else {
  19592. splice.call(data, index, 1);
  19593. }
  19594. --this.size;
  19595. return true;
  19596. }
  19597. /**
  19598. * Gets the list cache value for `key`.
  19599. *
  19600. * @private
  19601. * @name get
  19602. * @memberOf ListCache
  19603. * @param {string} key The key of the value to get.
  19604. * @returns {*} Returns the entry value.
  19605. */
  19606. function listCacheGet(key) {
  19607. var data = this.__data__,
  19608. index = assocIndexOf(data, key);
  19609. return index < 0 ? undefined : data[index][1];
  19610. }
  19611. /**
  19612. * Checks if a list cache value for `key` exists.
  19613. *
  19614. * @private
  19615. * @name has
  19616. * @memberOf ListCache
  19617. * @param {string} key The key of the entry to check.
  19618. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19619. */
  19620. function listCacheHas(key) {
  19621. return assocIndexOf(this.__data__, key) > -1;
  19622. }
  19623. /**
  19624. * Sets the list cache `key` to `value`.
  19625. *
  19626. * @private
  19627. * @name set
  19628. * @memberOf ListCache
  19629. * @param {string} key The key of the value to set.
  19630. * @param {*} value The value to set.
  19631. * @returns {Object} Returns the list cache instance.
  19632. */
  19633. function listCacheSet(key, value) {
  19634. var data = this.__data__,
  19635. index = assocIndexOf(data, key);
  19636. if (index < 0) {
  19637. ++this.size;
  19638. data.push([key, value]);
  19639. } else {
  19640. data[index][1] = value;
  19641. }
  19642. return this;
  19643. }
  19644. // Add methods to `ListCache`.
  19645. ListCache.prototype.clear = listCacheClear;
  19646. ListCache.prototype['delete'] = listCacheDelete;
  19647. ListCache.prototype.get = listCacheGet;
  19648. ListCache.prototype.has = listCacheHas;
  19649. ListCache.prototype.set = listCacheSet;
  19650. /*------------------------------------------------------------------------*/
  19651. /**
  19652. * Creates a map cache object to store key-value pairs.
  19653. *
  19654. * @private
  19655. * @constructor
  19656. * @param {Array} [entries] The key-value pairs to cache.
  19657. */
  19658. function MapCache(entries) {
  19659. var index = -1,
  19660. length = entries == null ? 0 : entries.length;
  19661. this.clear();
  19662. while (++index < length) {
  19663. var entry = entries[index];
  19664. this.set(entry[0], entry[1]);
  19665. }
  19666. }
  19667. /**
  19668. * Removes all key-value entries from the map.
  19669. *
  19670. * @private
  19671. * @name clear
  19672. * @memberOf MapCache
  19673. */
  19674. function mapCacheClear() {
  19675. this.size = 0;
  19676. this.__data__ = {
  19677. 'hash': new Hash,
  19678. 'map': new (Map || ListCache),
  19679. 'string': new Hash
  19680. };
  19681. }
  19682. /**
  19683. * Removes `key` and its value from the map.
  19684. *
  19685. * @private
  19686. * @name delete
  19687. * @memberOf MapCache
  19688. * @param {string} key The key of the value to remove.
  19689. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19690. */
  19691. function mapCacheDelete(key) {
  19692. var result = getMapData(this, key)['delete'](key);
  19693. this.size -= result ? 1 : 0;
  19694. return result;
  19695. }
  19696. /**
  19697. * Gets the map value for `key`.
  19698. *
  19699. * @private
  19700. * @name get
  19701. * @memberOf MapCache
  19702. * @param {string} key The key of the value to get.
  19703. * @returns {*} Returns the entry value.
  19704. */
  19705. function mapCacheGet(key) {
  19706. return getMapData(this, key).get(key);
  19707. }
  19708. /**
  19709. * Checks if a map value for `key` exists.
  19710. *
  19711. * @private
  19712. * @name has
  19713. * @memberOf MapCache
  19714. * @param {string} key The key of the entry to check.
  19715. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19716. */
  19717. function mapCacheHas(key) {
  19718. return getMapData(this, key).has(key);
  19719. }
  19720. /**
  19721. * Sets the map `key` to `value`.
  19722. *
  19723. * @private
  19724. * @name set
  19725. * @memberOf MapCache
  19726. * @param {string} key The key of the value to set.
  19727. * @param {*} value The value to set.
  19728. * @returns {Object} Returns the map cache instance.
  19729. */
  19730. function mapCacheSet(key, value) {
  19731. var data = getMapData(this, key),
  19732. size = data.size;
  19733. data.set(key, value);
  19734. this.size += data.size == size ? 0 : 1;
  19735. return this;
  19736. }
  19737. // Add methods to `MapCache`.
  19738. MapCache.prototype.clear = mapCacheClear;
  19739. MapCache.prototype['delete'] = mapCacheDelete;
  19740. MapCache.prototype.get = mapCacheGet;
  19741. MapCache.prototype.has = mapCacheHas;
  19742. MapCache.prototype.set = mapCacheSet;
  19743. /*------------------------------------------------------------------------*/
  19744. /**
  19745. *
  19746. * Creates an array cache object to store unique values.
  19747. *
  19748. * @private
  19749. * @constructor
  19750. * @param {Array} [values] The values to cache.
  19751. */
  19752. function SetCache(values) {
  19753. var index = -1,
  19754. length = values == null ? 0 : values.length;
  19755. this.__data__ = new MapCache;
  19756. while (++index < length) {
  19757. this.add(values[index]);
  19758. }
  19759. }
  19760. /**
  19761. * Adds `value` to the array cache.
  19762. *
  19763. * @private
  19764. * @name add
  19765. * @memberOf SetCache
  19766. * @alias push
  19767. * @param {*} value The value to cache.
  19768. * @returns {Object} Returns the cache instance.
  19769. */
  19770. function setCacheAdd(value) {
  19771. this.__data__.set(value, HASH_UNDEFINED);
  19772. return this;
  19773. }
  19774. /**
  19775. * Checks if `value` is in the array cache.
  19776. *
  19777. * @private
  19778. * @name has
  19779. * @memberOf SetCache
  19780. * @param {*} value The value to search for.
  19781. * @returns {number} Returns `true` if `value` is found, else `false`.
  19782. */
  19783. function setCacheHas(value) {
  19784. return this.__data__.has(value);
  19785. }
  19786. // Add methods to `SetCache`.
  19787. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  19788. SetCache.prototype.has = setCacheHas;
  19789. /*------------------------------------------------------------------------*/
  19790. /**
  19791. * Creates a stack cache object to store key-value pairs.
  19792. *
  19793. * @private
  19794. * @constructor
  19795. * @param {Array} [entries] The key-value pairs to cache.
  19796. */
  19797. function Stack(entries) {
  19798. var data = this.__data__ = new ListCache(entries);
  19799. this.size = data.size;
  19800. }
  19801. /**
  19802. * Removes all key-value entries from the stack.
  19803. *
  19804. * @private
  19805. * @name clear
  19806. * @memberOf Stack
  19807. */
  19808. function stackClear() {
  19809. this.__data__ = new ListCache;
  19810. this.size = 0;
  19811. }
  19812. /**
  19813. * Removes `key` and its value from the stack.
  19814. *
  19815. * @private
  19816. * @name delete
  19817. * @memberOf Stack
  19818. * @param {string} key The key of the value to remove.
  19819. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19820. */
  19821. function stackDelete(key) {
  19822. var data = this.__data__,
  19823. result = data['delete'](key);
  19824. this.size = data.size;
  19825. return result;
  19826. }
  19827. /**
  19828. * Gets the stack value for `key`.
  19829. *
  19830. * @private
  19831. * @name get
  19832. * @memberOf Stack
  19833. * @param {string} key The key of the value to get.
  19834. * @returns {*} Returns the entry value.
  19835. */
  19836. function stackGet(key) {
  19837. return this.__data__.get(key);
  19838. }
  19839. /**
  19840. * Checks if a stack value for `key` exists.
  19841. *
  19842. * @private
  19843. * @name has
  19844. * @memberOf Stack
  19845. * @param {string} key The key of the entry to check.
  19846. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19847. */
  19848. function stackHas(key) {
  19849. return this.__data__.has(key);
  19850. }
  19851. /**
  19852. * Sets the stack `key` to `value`.
  19853. *
  19854. * @private
  19855. * @name set
  19856. * @memberOf Stack
  19857. * @param {string} key The key of the value to set.
  19858. * @param {*} value The value to set.
  19859. * @returns {Object} Returns the stack cache instance.
  19860. */
  19861. function stackSet(key, value) {
  19862. var data = this.__data__;
  19863. if (data instanceof ListCache) {
  19864. var pairs = data.__data__;
  19865. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  19866. pairs.push([key, value]);
  19867. this.size = ++data.size;
  19868. return this;
  19869. }
  19870. data = this.__data__ = new MapCache(pairs);
  19871. }
  19872. data.set(key, value);
  19873. this.size = data.size;
  19874. return this;
  19875. }
  19876. // Add methods to `Stack`.
  19877. Stack.prototype.clear = stackClear;
  19878. Stack.prototype['delete'] = stackDelete;
  19879. Stack.prototype.get = stackGet;
  19880. Stack.prototype.has = stackHas;
  19881. Stack.prototype.set = stackSet;
  19882. /*------------------------------------------------------------------------*/
  19883. /**
  19884. * Creates an array of the enumerable property names of the array-like `value`.
  19885. *
  19886. * @private
  19887. * @param {*} value The value to query.
  19888. * @param {boolean} inherited Specify returning inherited property names.
  19889. * @returns {Array} Returns the array of property names.
  19890. */
  19891. function arrayLikeKeys(value, inherited) {
  19892. var isArr = isArray(value),
  19893. isArg = !isArr && isArguments(value),
  19894. isBuff = !isArr && !isArg && isBuffer(value),
  19895. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  19896. skipIndexes = isArr || isArg || isBuff || isType,
  19897. result = skipIndexes ? baseTimes(value.length, String) : [],
  19898. length = result.length;
  19899. for (var key in value) {
  19900. if ((inherited || hasOwnProperty.call(value, key)) &&
  19901. !(skipIndexes && (
  19902. // Safari 9 has enumerable `arguments.length` in strict mode.
  19903. key == 'length' ||
  19904. // Node.js 0.10 has enumerable non-index properties on buffers.
  19905. (isBuff && (key == 'offset' || key == 'parent')) ||
  19906. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  19907. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  19908. // Skip index properties.
  19909. isIndex(key, length)
  19910. ))) {
  19911. result.push(key);
  19912. }
  19913. }
  19914. return result;
  19915. }
  19916. /**
  19917. * A specialized version of `_.sample` for arrays.
  19918. *
  19919. * @private
  19920. * @param {Array} array The array to sample.
  19921. * @returns {*} Returns the random element.
  19922. */
  19923. function arraySample(array) {
  19924. var length = array.length;
  19925. return length ? array[baseRandom(0, length - 1)] : undefined;
  19926. }
  19927. /**
  19928. * A specialized version of `_.sampleSize` for arrays.
  19929. *
  19930. * @private
  19931. * @param {Array} array The array to sample.
  19932. * @param {number} n The number of elements to sample.
  19933. * @returns {Array} Returns the random elements.
  19934. */
  19935. function arraySampleSize(array, n) {
  19936. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  19937. }
  19938. /**
  19939. * A specialized version of `_.shuffle` for arrays.
  19940. *
  19941. * @private
  19942. * @param {Array} array The array to shuffle.
  19943. * @returns {Array} Returns the new shuffled array.
  19944. */
  19945. function arrayShuffle(array) {
  19946. return shuffleSelf(copyArray(array));
  19947. }
  19948. /**
  19949. * This function is like `assignValue` except that it doesn't assign
  19950. * `undefined` values.
  19951. *
  19952. * @private
  19953. * @param {Object} object The object to modify.
  19954. * @param {string} key The key of the property to assign.
  19955. * @param {*} value The value to assign.
  19956. */
  19957. function assignMergeValue(object, key, value) {
  19958. if ((value !== undefined && !eq(object[key], value)) ||
  19959. (value === undefined && !(key in object))) {
  19960. baseAssignValue(object, key, value);
  19961. }
  19962. }
  19963. /**
  19964. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  19965. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  19966. * for equality comparisons.
  19967. *
  19968. * @private
  19969. * @param {Object} object The object to modify.
  19970. * @param {string} key The key of the property to assign.
  19971. * @param {*} value The value to assign.
  19972. */
  19973. function assignValue(object, key, value) {
  19974. var objValue = object[key];
  19975. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  19976. (value === undefined && !(key in object))) {
  19977. baseAssignValue(object, key, value);
  19978. }
  19979. }
  19980. /**
  19981. * Gets the index at which the `key` is found in `array` of key-value pairs.
  19982. *
  19983. * @private
  19984. * @param {Array} array The array to inspect.
  19985. * @param {*} key The key to search for.
  19986. * @returns {number} Returns the index of the matched value, else `-1`.
  19987. */
  19988. function assocIndexOf(array, key) {
  19989. var length = array.length;
  19990. while (length--) {
  19991. if (eq(array[length][0], key)) {
  19992. return length;
  19993. }
  19994. }
  19995. return -1;
  19996. }
  19997. /**
  19998. * Aggregates elements of `collection` on `accumulator` with keys transformed
  19999. * by `iteratee` and values set by `setter`.
  20000. *
  20001. * @private
  20002. * @param {Array|Object} collection The collection to iterate over.
  20003. * @param {Function} setter The function to set `accumulator` values.
  20004. * @param {Function} iteratee The iteratee to transform keys.
  20005. * @param {Object} accumulator The initial aggregated object.
  20006. * @returns {Function} Returns `accumulator`.
  20007. */
  20008. function baseAggregator(collection, setter, iteratee, accumulator) {
  20009. baseEach(collection, function(value, key, collection) {
  20010. setter(accumulator, value, iteratee(value), collection);
  20011. });
  20012. return accumulator;
  20013. }
  20014. /**
  20015. * The base implementation of `_.assign` without support for multiple sources
  20016. * or `customizer` functions.
  20017. *
  20018. * @private
  20019. * @param {Object} object The destination object.
  20020. * @param {Object} source The source object.
  20021. * @returns {Object} Returns `object`.
  20022. */
  20023. function baseAssign(object, source) {
  20024. return object && copyObject(source, keys(source), object);
  20025. }
  20026. /**
  20027. * The base implementation of `_.assignIn` without support for multiple sources
  20028. * or `customizer` functions.
  20029. *
  20030. * @private
  20031. * @param {Object} object The destination object.
  20032. * @param {Object} source The source object.
  20033. * @returns {Object} Returns `object`.
  20034. */
  20035. function baseAssignIn(object, source) {
  20036. return object && copyObject(source, keysIn(source), object);
  20037. }
  20038. /**
  20039. * The base implementation of `assignValue` and `assignMergeValue` without
  20040. * value checks.
  20041. *
  20042. * @private
  20043. * @param {Object} object The object to modify.
  20044. * @param {string} key The key of the property to assign.
  20045. * @param {*} value The value to assign.
  20046. */
  20047. function baseAssignValue(object, key, value) {
  20048. if (key == '__proto__' && defineProperty) {
  20049. defineProperty(object, key, {
  20050. 'configurable': true,
  20051. 'enumerable': true,
  20052. 'value': value,
  20053. 'writable': true
  20054. });
  20055. } else {
  20056. object[key] = value;
  20057. }
  20058. }
  20059. /**
  20060. * The base implementation of `_.at` without support for individual paths.
  20061. *
  20062. * @private
  20063. * @param {Object} object The object to iterate over.
  20064. * @param {string[]} paths The property paths to pick.
  20065. * @returns {Array} Returns the picked elements.
  20066. */
  20067. function baseAt(object, paths) {
  20068. var index = -1,
  20069. length = paths.length,
  20070. result = Array(length),
  20071. skip = object == null;
  20072. while (++index < length) {
  20073. result[index] = skip ? undefined : get(object, paths[index]);
  20074. }
  20075. return result;
  20076. }
  20077. /**
  20078. * The base implementation of `_.clamp` which doesn't coerce arguments.
  20079. *
  20080. * @private
  20081. * @param {number} number The number to clamp.
  20082. * @param {number} [lower] The lower bound.
  20083. * @param {number} upper The upper bound.
  20084. * @returns {number} Returns the clamped number.
  20085. */
  20086. function baseClamp(number, lower, upper) {
  20087. if (number === number) {
  20088. if (upper !== undefined) {
  20089. number = number <= upper ? number : upper;
  20090. }
  20091. if (lower !== undefined) {
  20092. number = number >= lower ? number : lower;
  20093. }
  20094. }
  20095. return number;
  20096. }
  20097. /**
  20098. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  20099. * traversed objects.
  20100. *
  20101. * @private
  20102. * @param {*} value The value to clone.
  20103. * @param {boolean} bitmask The bitmask flags.
  20104. * 1 - Deep clone
  20105. * 2 - Flatten inherited properties
  20106. * 4 - Clone symbols
  20107. * @param {Function} [customizer] The function to customize cloning.
  20108. * @param {string} [key] The key of `value`.
  20109. * @param {Object} [object] The parent object of `value`.
  20110. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  20111. * @returns {*} Returns the cloned value.
  20112. */
  20113. function baseClone(value, bitmask, customizer, key, object, stack) {
  20114. var result,
  20115. isDeep = bitmask & CLONE_DEEP_FLAG,
  20116. isFlat = bitmask & CLONE_FLAT_FLAG,
  20117. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  20118. if (customizer) {
  20119. result = object ? customizer(value, key, object, stack) : customizer(value);
  20120. }
  20121. if (result !== undefined) {
  20122. return result;
  20123. }
  20124. if (!isObject(value)) {
  20125. return value;
  20126. }
  20127. var isArr = isArray(value);
  20128. if (isArr) {
  20129. result = initCloneArray(value);
  20130. if (!isDeep) {
  20131. return copyArray(value, result);
  20132. }
  20133. } else {
  20134. var tag = getTag(value),
  20135. isFunc = tag == funcTag || tag == genTag;
  20136. if (isBuffer(value)) {
  20137. return cloneBuffer(value, isDeep);
  20138. }
  20139. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  20140. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  20141. if (!isDeep) {
  20142. return isFlat
  20143. ? copySymbolsIn(value, baseAssignIn(result, value))
  20144. : copySymbols(value, baseAssign(result, value));
  20145. }
  20146. } else {
  20147. if (!cloneableTags[tag]) {
  20148. return object ? value : {};
  20149. }
  20150. result = initCloneByTag(value, tag, isDeep);
  20151. }
  20152. }
  20153. // Check for circular references and return its corresponding clone.
  20154. stack || (stack = new Stack);
  20155. var stacked = stack.get(value);
  20156. if (stacked) {
  20157. return stacked;
  20158. }
  20159. stack.set(value, result);
  20160. if (isSet(value)) {
  20161. value.forEach(function(subValue) {
  20162. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  20163. });
  20164. } else if (isMap(value)) {
  20165. value.forEach(function(subValue, key) {
  20166. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20167. });
  20168. }
  20169. var keysFunc = isFull
  20170. ? (isFlat ? getAllKeysIn : getAllKeys)
  20171. : (isFlat ? keysIn : keys);
  20172. var props = isArr ? undefined : keysFunc(value);
  20173. arrayEach(props || value, function(subValue, key) {
  20174. if (props) {
  20175. key = subValue;
  20176. subValue = value[key];
  20177. }
  20178. // Recursively populate clone (susceptible to call stack limits).
  20179. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20180. });
  20181. return result;
  20182. }
  20183. /**
  20184. * The base implementation of `_.conforms` which doesn't clone `source`.
  20185. *
  20186. * @private
  20187. * @param {Object} source The object of property predicates to conform to.
  20188. * @returns {Function} Returns the new spec function.
  20189. */
  20190. function baseConforms(source) {
  20191. var props = keys(source);
  20192. return function(object) {
  20193. return baseConformsTo(object, source, props);
  20194. };
  20195. }
  20196. /**
  20197. * The base implementation of `_.conformsTo` which accepts `props` to check.
  20198. *
  20199. * @private
  20200. * @param {Object} object The object to inspect.
  20201. * @param {Object} source The object of property predicates to conform to.
  20202. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  20203. */
  20204. function baseConformsTo(object, source, props) {
  20205. var length = props.length;
  20206. if (object == null) {
  20207. return !length;
  20208. }
  20209. object = Object(object);
  20210. while (length--) {
  20211. var key = props[length],
  20212. predicate = source[key],
  20213. value = object[key];
  20214. if ((value === undefined && !(key in object)) || !predicate(value)) {
  20215. return false;
  20216. }
  20217. }
  20218. return true;
  20219. }
  20220. /**
  20221. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  20222. * to provide to `func`.
  20223. *
  20224. * @private
  20225. * @param {Function} func The function to delay.
  20226. * @param {number} wait The number of milliseconds to delay invocation.
  20227. * @param {Array} args The arguments to provide to `func`.
  20228. * @returns {number|Object} Returns the timer id or timeout object.
  20229. */
  20230. function baseDelay(func, wait, args) {
  20231. if (typeof func != 'function') {
  20232. throw new TypeError(FUNC_ERROR_TEXT);
  20233. }
  20234. return setTimeout(function() { func.apply(undefined, args); }, wait);
  20235. }
  20236. /**
  20237. * The base implementation of methods like `_.difference` without support
  20238. * for excluding multiple arrays or iteratee shorthands.
  20239. *
  20240. * @private
  20241. * @param {Array} array The array to inspect.
  20242. * @param {Array} values The values to exclude.
  20243. * @param {Function} [iteratee] The iteratee invoked per element.
  20244. * @param {Function} [comparator] The comparator invoked per element.
  20245. * @returns {Array} Returns the new array of filtered values.
  20246. */
  20247. function baseDifference(array, values, iteratee, comparator) {
  20248. var index = -1,
  20249. includes = arrayIncludes,
  20250. isCommon = true,
  20251. length = array.length,
  20252. result = [],
  20253. valuesLength = values.length;
  20254. if (!length) {
  20255. return result;
  20256. }
  20257. if (iteratee) {
  20258. values = arrayMap(values, baseUnary(iteratee));
  20259. }
  20260. if (comparator) {
  20261. includes = arrayIncludesWith;
  20262. isCommon = false;
  20263. }
  20264. else if (values.length >= LARGE_ARRAY_SIZE) {
  20265. includes = cacheHas;
  20266. isCommon = false;
  20267. values = new SetCache(values);
  20268. }
  20269. outer:
  20270. while (++index < length) {
  20271. var value = array[index],
  20272. computed = iteratee == null ? value : iteratee(value);
  20273. value = (comparator || value !== 0) ? value : 0;
  20274. if (isCommon && computed === computed) {
  20275. var valuesIndex = valuesLength;
  20276. while (valuesIndex--) {
  20277. if (values[valuesIndex] === computed) {
  20278. continue outer;
  20279. }
  20280. }
  20281. result.push(value);
  20282. }
  20283. else if (!includes(values, computed, comparator)) {
  20284. result.push(value);
  20285. }
  20286. }
  20287. return result;
  20288. }
  20289. /**
  20290. * The base implementation of `_.forEach` without support for iteratee shorthands.
  20291. *
  20292. * @private
  20293. * @param {Array|Object} collection The collection to iterate over.
  20294. * @param {Function} iteratee The function invoked per iteration.
  20295. * @returns {Array|Object} Returns `collection`.
  20296. */
  20297. var baseEach = createBaseEach(baseForOwn);
  20298. /**
  20299. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  20300. *
  20301. * @private
  20302. * @param {Array|Object} collection The collection to iterate over.
  20303. * @param {Function} iteratee The function invoked per iteration.
  20304. * @returns {Array|Object} Returns `collection`.
  20305. */
  20306. var baseEachRight = createBaseEach(baseForOwnRight, true);
  20307. /**
  20308. * The base implementation of `_.every` without support for iteratee shorthands.
  20309. *
  20310. * @private
  20311. * @param {Array|Object} collection The collection to iterate over.
  20312. * @param {Function} predicate The function invoked per iteration.
  20313. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20314. * else `false`
  20315. */
  20316. function baseEvery(collection, predicate) {
  20317. var result = true;
  20318. baseEach(collection, function(value, index, collection) {
  20319. result = !!predicate(value, index, collection);
  20320. return result;
  20321. });
  20322. return result;
  20323. }
  20324. /**
  20325. * The base implementation of methods like `_.max` and `_.min` which accepts a
  20326. * `comparator` to determine the extremum value.
  20327. *
  20328. * @private
  20329. * @param {Array} array The array to iterate over.
  20330. * @param {Function} iteratee The iteratee invoked per iteration.
  20331. * @param {Function} comparator The comparator used to compare values.
  20332. * @returns {*} Returns the extremum value.
  20333. */
  20334. function baseExtremum(array, iteratee, comparator) {
  20335. var index = -1,
  20336. length = array.length;
  20337. while (++index < length) {
  20338. var value = array[index],
  20339. current = iteratee(value);
  20340. if (current != null && (computed === undefined
  20341. ? (current === current && !isSymbol(current))
  20342. : comparator(current, computed)
  20343. )) {
  20344. var computed = current,
  20345. result = value;
  20346. }
  20347. }
  20348. return result;
  20349. }
  20350. /**
  20351. * The base implementation of `_.fill` without an iteratee call guard.
  20352. *
  20353. * @private
  20354. * @param {Array} array The array to fill.
  20355. * @param {*} value The value to fill `array` with.
  20356. * @param {number} [start=0] The start position.
  20357. * @param {number} [end=array.length] The end position.
  20358. * @returns {Array} Returns `array`.
  20359. */
  20360. function baseFill(array, value, start, end) {
  20361. var length = array.length;
  20362. start = toInteger(start);
  20363. if (start < 0) {
  20364. start = -start > length ? 0 : (length + start);
  20365. }
  20366. end = (end === undefined || end > length) ? length : toInteger(end);
  20367. if (end < 0) {
  20368. end += length;
  20369. }
  20370. end = start > end ? 0 : toLength(end);
  20371. while (start < end) {
  20372. array[start++] = value;
  20373. }
  20374. return array;
  20375. }
  20376. /**
  20377. * The base implementation of `_.filter` without support for iteratee shorthands.
  20378. *
  20379. * @private
  20380. * @param {Array|Object} collection The collection to iterate over.
  20381. * @param {Function} predicate The function invoked per iteration.
  20382. * @returns {Array} Returns the new filtered array.
  20383. */
  20384. function baseFilter(collection, predicate) {
  20385. var result = [];
  20386. baseEach(collection, function(value, index, collection) {
  20387. if (predicate(value, index, collection)) {
  20388. result.push(value);
  20389. }
  20390. });
  20391. return result;
  20392. }
  20393. /**
  20394. * The base implementation of `_.flatten` with support for restricting flattening.
  20395. *
  20396. * @private
  20397. * @param {Array} array The array to flatten.
  20398. * @param {number} depth The maximum recursion depth.
  20399. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  20400. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  20401. * @param {Array} [result=[]] The initial result value.
  20402. * @returns {Array} Returns the new flattened array.
  20403. */
  20404. function baseFlatten(array, depth, predicate, isStrict, result) {
  20405. var index = -1,
  20406. length = array.length;
  20407. predicate || (predicate = isFlattenable);
  20408. result || (result = []);
  20409. while (++index < length) {
  20410. var value = array[index];
  20411. if (depth > 0 && predicate(value)) {
  20412. if (depth > 1) {
  20413. // Recursively flatten arrays (susceptible to call stack limits).
  20414. baseFlatten(value, depth - 1, predicate, isStrict, result);
  20415. } else {
  20416. arrayPush(result, value);
  20417. }
  20418. } else if (!isStrict) {
  20419. result[result.length] = value;
  20420. }
  20421. }
  20422. return result;
  20423. }
  20424. /**
  20425. * The base implementation of `baseForOwn` which iterates over `object`
  20426. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  20427. * Iteratee functions may exit iteration early by explicitly returning `false`.
  20428. *
  20429. * @private
  20430. * @param {Object} object The object to iterate over.
  20431. * @param {Function} iteratee The function invoked per iteration.
  20432. * @param {Function} keysFunc The function to get the keys of `object`.
  20433. * @returns {Object} Returns `object`.
  20434. */
  20435. var baseFor = createBaseFor();
  20436. /**
  20437. * This function is like `baseFor` except that it iterates over properties
  20438. * in the opposite order.
  20439. *
  20440. * @private
  20441. * @param {Object} object The object to iterate over.
  20442. * @param {Function} iteratee The function invoked per iteration.
  20443. * @param {Function} keysFunc The function to get the keys of `object`.
  20444. * @returns {Object} Returns `object`.
  20445. */
  20446. var baseForRight = createBaseFor(true);
  20447. /**
  20448. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  20449. *
  20450. * @private
  20451. * @param {Object} object The object to iterate over.
  20452. * @param {Function} iteratee The function invoked per iteration.
  20453. * @returns {Object} Returns `object`.
  20454. */
  20455. function baseForOwn(object, iteratee) {
  20456. return object && baseFor(object, iteratee, keys);
  20457. }
  20458. /**
  20459. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  20460. *
  20461. * @private
  20462. * @param {Object} object The object to iterate over.
  20463. * @param {Function} iteratee The function invoked per iteration.
  20464. * @returns {Object} Returns `object`.
  20465. */
  20466. function baseForOwnRight(object, iteratee) {
  20467. return object && baseForRight(object, iteratee, keys);
  20468. }
  20469. /**
  20470. * The base implementation of `_.functions` which creates an array of
  20471. * `object` function property names filtered from `props`.
  20472. *
  20473. * @private
  20474. * @param {Object} object The object to inspect.
  20475. * @param {Array} props The property names to filter.
  20476. * @returns {Array} Returns the function names.
  20477. */
  20478. function baseFunctions(object, props) {
  20479. return arrayFilter(props, function(key) {
  20480. return isFunction(object[key]);
  20481. });
  20482. }
  20483. /**
  20484. * The base implementation of `_.get` without support for default values.
  20485. *
  20486. * @private
  20487. * @param {Object} object The object to query.
  20488. * @param {Array|string} path The path of the property to get.
  20489. * @returns {*} Returns the resolved value.
  20490. */
  20491. function baseGet(object, path) {
  20492. path = castPath(path, object);
  20493. var index = 0,
  20494. length = path.length;
  20495. while (object != null && index < length) {
  20496. object = object[toKey(path[index++])];
  20497. }
  20498. return (index && index == length) ? object : undefined;
  20499. }
  20500. /**
  20501. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  20502. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  20503. * symbols of `object`.
  20504. *
  20505. * @private
  20506. * @param {Object} object The object to query.
  20507. * @param {Function} keysFunc The function to get the keys of `object`.
  20508. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  20509. * @returns {Array} Returns the array of property names and symbols.
  20510. */
  20511. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  20512. var result = keysFunc(object);
  20513. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  20514. }
  20515. /**
  20516. * The base implementation of `getTag` without fallbacks for buggy environments.
  20517. *
  20518. * @private
  20519. * @param {*} value The value to query.
  20520. * @returns {string} Returns the `toStringTag`.
  20521. */
  20522. function baseGetTag(value) {
  20523. if (value == null) {
  20524. return value === undefined ? undefinedTag : nullTag;
  20525. }
  20526. return (symToStringTag && symToStringTag in Object(value))
  20527. ? getRawTag(value)
  20528. : objectToString(value);
  20529. }
  20530. /**
  20531. * The base implementation of `_.gt` which doesn't coerce arguments.
  20532. *
  20533. * @private
  20534. * @param {*} value The value to compare.
  20535. * @param {*} other The other value to compare.
  20536. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  20537. * else `false`.
  20538. */
  20539. function baseGt(value, other) {
  20540. return value > other;
  20541. }
  20542. /**
  20543. * The base implementation of `_.has` without support for deep paths.
  20544. *
  20545. * @private
  20546. * @param {Object} [object] The object to query.
  20547. * @param {Array|string} key The key to check.
  20548. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20549. */
  20550. function baseHas(object, key) {
  20551. return object != null && hasOwnProperty.call(object, key);
  20552. }
  20553. /**
  20554. * The base implementation of `_.hasIn` without support for deep paths.
  20555. *
  20556. * @private
  20557. * @param {Object} [object] The object to query.
  20558. * @param {Array|string} key The key to check.
  20559. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20560. */
  20561. function baseHasIn(object, key) {
  20562. return object != null && key in Object(object);
  20563. }
  20564. /**
  20565. * The base implementation of `_.inRange` which doesn't coerce arguments.
  20566. *
  20567. * @private
  20568. * @param {number} number The number to check.
  20569. * @param {number} start The start of the range.
  20570. * @param {number} end The end of the range.
  20571. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  20572. */
  20573. function baseInRange(number, start, end) {
  20574. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  20575. }
  20576. /**
  20577. * The base implementation of methods like `_.intersection`, without support
  20578. * for iteratee shorthands, that accepts an array of arrays to inspect.
  20579. *
  20580. * @private
  20581. * @param {Array} arrays The arrays to inspect.
  20582. * @param {Function} [iteratee] The iteratee invoked per element.
  20583. * @param {Function} [comparator] The comparator invoked per element.
  20584. * @returns {Array} Returns the new array of shared values.
  20585. */
  20586. function baseIntersection(arrays, iteratee, comparator) {
  20587. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  20588. length = arrays[0].length,
  20589. othLength = arrays.length,
  20590. othIndex = othLength,
  20591. caches = Array(othLength),
  20592. maxLength = Infinity,
  20593. result = [];
  20594. while (othIndex--) {
  20595. var array = arrays[othIndex];
  20596. if (othIndex && iteratee) {
  20597. array = arrayMap(array, baseUnary(iteratee));
  20598. }
  20599. maxLength = nativeMin(array.length, maxLength);
  20600. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  20601. ? new SetCache(othIndex && array)
  20602. : undefined;
  20603. }
  20604. array = arrays[0];
  20605. var index = -1,
  20606. seen = caches[0];
  20607. outer:
  20608. while (++index < length && result.length < maxLength) {
  20609. var value = array[index],
  20610. computed = iteratee ? iteratee(value) : value;
  20611. value = (comparator || value !== 0) ? value : 0;
  20612. if (!(seen
  20613. ? cacheHas(seen, computed)
  20614. : includes(result, computed, comparator)
  20615. )) {
  20616. othIndex = othLength;
  20617. while (--othIndex) {
  20618. var cache = caches[othIndex];
  20619. if (!(cache
  20620. ? cacheHas(cache, computed)
  20621. : includes(arrays[othIndex], computed, comparator))
  20622. ) {
  20623. continue outer;
  20624. }
  20625. }
  20626. if (seen) {
  20627. seen.push(computed);
  20628. }
  20629. result.push(value);
  20630. }
  20631. }
  20632. return result;
  20633. }
  20634. /**
  20635. * The base implementation of `_.invert` and `_.invertBy` which inverts
  20636. * `object` with values transformed by `iteratee` and set by `setter`.
  20637. *
  20638. * @private
  20639. * @param {Object} object The object to iterate over.
  20640. * @param {Function} setter The function to set `accumulator` values.
  20641. * @param {Function} iteratee The iteratee to transform values.
  20642. * @param {Object} accumulator The initial inverted object.
  20643. * @returns {Function} Returns `accumulator`.
  20644. */
  20645. function baseInverter(object, setter, iteratee, accumulator) {
  20646. baseForOwn(object, function(value, key, object) {
  20647. setter(accumulator, iteratee(value), key, object);
  20648. });
  20649. return accumulator;
  20650. }
  20651. /**
  20652. * The base implementation of `_.invoke` without support for individual
  20653. * method arguments.
  20654. *
  20655. * @private
  20656. * @param {Object} object The object to query.
  20657. * @param {Array|string} path The path of the method to invoke.
  20658. * @param {Array} args The arguments to invoke the method with.
  20659. * @returns {*} Returns the result of the invoked method.
  20660. */
  20661. function baseInvoke(object, path, args) {
  20662. path = castPath(path, object);
  20663. object = parent(object, path);
  20664. var func = object == null ? object : object[toKey(last(path))];
  20665. return func == null ? undefined : apply(func, object, args);
  20666. }
  20667. /**
  20668. * The base implementation of `_.isArguments`.
  20669. *
  20670. * @private
  20671. * @param {*} value The value to check.
  20672. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  20673. */
  20674. function baseIsArguments(value) {
  20675. return isObjectLike(value) && baseGetTag(value) == argsTag;
  20676. }
  20677. /**
  20678. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  20679. *
  20680. * @private
  20681. * @param {*} value The value to check.
  20682. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  20683. */
  20684. function baseIsArrayBuffer(value) {
  20685. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  20686. }
  20687. /**
  20688. * The base implementation of `_.isDate` without Node.js optimizations.
  20689. *
  20690. * @private
  20691. * @param {*} value The value to check.
  20692. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  20693. */
  20694. function baseIsDate(value) {
  20695. return isObjectLike(value) && baseGetTag(value) == dateTag;
  20696. }
  20697. /**
  20698. * The base implementation of `_.isEqual` which supports partial comparisons
  20699. * and tracks traversed objects.
  20700. *
  20701. * @private
  20702. * @param {*} value The value to compare.
  20703. * @param {*} other The other value to compare.
  20704. * @param {boolean} bitmask The bitmask flags.
  20705. * 1 - Unordered comparison
  20706. * 2 - Partial comparison
  20707. * @param {Function} [customizer] The function to customize comparisons.
  20708. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  20709. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  20710. */
  20711. function baseIsEqual(value, other, bitmask, customizer, stack) {
  20712. if (value === other) {
  20713. return true;
  20714. }
  20715. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  20716. return value !== value && other !== other;
  20717. }
  20718. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  20719. }
  20720. /**
  20721. * A specialized version of `baseIsEqual` for arrays and objects which performs
  20722. * deep comparisons and tracks traversed objects enabling objects with circular
  20723. * references to be compared.
  20724. *
  20725. * @private
  20726. * @param {Object} object The object to compare.
  20727. * @param {Object} other The other object to compare.
  20728. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  20729. * @param {Function} customizer The function to customize comparisons.
  20730. * @param {Function} equalFunc The function to determine equivalents of values.
  20731. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  20732. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  20733. */
  20734. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  20735. var objIsArr = isArray(object),
  20736. othIsArr = isArray(other),
  20737. objTag = objIsArr ? arrayTag : getTag(object),
  20738. othTag = othIsArr ? arrayTag : getTag(other);
  20739. objTag = objTag == argsTag ? objectTag : objTag;
  20740. othTag = othTag == argsTag ? objectTag : othTag;
  20741. var objIsObj = objTag == objectTag,
  20742. othIsObj = othTag == objectTag,
  20743. isSameTag = objTag == othTag;
  20744. if (isSameTag && isBuffer(object)) {
  20745. if (!isBuffer(other)) {
  20746. return false;
  20747. }
  20748. objIsArr = true;
  20749. objIsObj = false;
  20750. }
  20751. if (isSameTag && !objIsObj) {
  20752. stack || (stack = new Stack);
  20753. return (objIsArr || isTypedArray(object))
  20754. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  20755. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  20756. }
  20757. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  20758. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  20759. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  20760. if (objIsWrapped || othIsWrapped) {
  20761. var objUnwrapped = objIsWrapped ? object.value() : object,
  20762. othUnwrapped = othIsWrapped ? other.value() : other;
  20763. stack || (stack = new Stack);
  20764. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  20765. }
  20766. }
  20767. if (!isSameTag) {
  20768. return false;
  20769. }
  20770. stack || (stack = new Stack);
  20771. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  20772. }
  20773. /**
  20774. * The base implementation of `_.isMap` without Node.js optimizations.
  20775. *
  20776. * @private
  20777. * @param {*} value The value to check.
  20778. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  20779. */
  20780. function baseIsMap(value) {
  20781. return isObjectLike(value) && getTag(value) == mapTag;
  20782. }
  20783. /**
  20784. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  20785. *
  20786. * @private
  20787. * @param {Object} object The object to inspect.
  20788. * @param {Object} source The object of property values to match.
  20789. * @param {Array} matchData The property names, values, and compare flags to match.
  20790. * @param {Function} [customizer] The function to customize comparisons.
  20791. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  20792. */
  20793. function baseIsMatch(object, source, matchData, customizer) {
  20794. var index = matchData.length,
  20795. length = index,
  20796. noCustomizer = !customizer;
  20797. if (object == null) {
  20798. return !length;
  20799. }
  20800. object = Object(object);
  20801. while (index--) {
  20802. var data = matchData[index];
  20803. if ((noCustomizer && data[2])
  20804. ? data[1] !== object[data[0]]
  20805. : !(data[0] in object)
  20806. ) {
  20807. return false;
  20808. }
  20809. }
  20810. while (++index < length) {
  20811. data = matchData[index];
  20812. var key = data[0],
  20813. objValue = object[key],
  20814. srcValue = data[1];
  20815. if (noCustomizer && data[2]) {
  20816. if (objValue === undefined && !(key in object)) {
  20817. return false;
  20818. }
  20819. } else {
  20820. var stack = new Stack;
  20821. if (customizer) {
  20822. var result = customizer(objValue, srcValue, key, object, source, stack);
  20823. }
  20824. if (!(result === undefined
  20825. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  20826. : result
  20827. )) {
  20828. return false;
  20829. }
  20830. }
  20831. }
  20832. return true;
  20833. }
  20834. /**
  20835. * The base implementation of `_.isNative` without bad shim checks.
  20836. *
  20837. * @private
  20838. * @param {*} value The value to check.
  20839. * @returns {boolean} Returns `true` if `value` is a native function,
  20840. * else `false`.
  20841. */
  20842. function baseIsNative(value) {
  20843. if (!isObject(value) || isMasked(value)) {
  20844. return false;
  20845. }
  20846. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  20847. return pattern.test(toSource(value));
  20848. }
  20849. /**
  20850. * The base implementation of `_.isRegExp` without Node.js optimizations.
  20851. *
  20852. * @private
  20853. * @param {*} value The value to check.
  20854. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  20855. */
  20856. function baseIsRegExp(value) {
  20857. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  20858. }
  20859. /**
  20860. * The base implementation of `_.isSet` without Node.js optimizations.
  20861. *
  20862. * @private
  20863. * @param {*} value The value to check.
  20864. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  20865. */
  20866. function baseIsSet(value) {
  20867. return isObjectLike(value) && getTag(value) == setTag;
  20868. }
  20869. /**
  20870. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  20871. *
  20872. * @private
  20873. * @param {*} value The value to check.
  20874. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  20875. */
  20876. function baseIsTypedArray(value) {
  20877. return isObjectLike(value) &&
  20878. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  20879. }
  20880. /**
  20881. * The base implementation of `_.iteratee`.
  20882. *
  20883. * @private
  20884. * @param {*} [value=_.identity] The value to convert to an iteratee.
  20885. * @returns {Function} Returns the iteratee.
  20886. */
  20887. function baseIteratee(value) {
  20888. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  20889. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  20890. if (typeof value == 'function') {
  20891. return value;
  20892. }
  20893. if (value == null) {
  20894. return identity;
  20895. }
  20896. if (typeof value == 'object') {
  20897. return isArray(value)
  20898. ? baseMatchesProperty(value[0], value[1])
  20899. : baseMatches(value);
  20900. }
  20901. return property(value);
  20902. }
  20903. /**
  20904. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  20905. *
  20906. * @private
  20907. * @param {Object} object The object to query.
  20908. * @returns {Array} Returns the array of property names.
  20909. */
  20910. function baseKeys(object) {
  20911. if (!isPrototype(object)) {
  20912. return nativeKeys(object);
  20913. }
  20914. var result = [];
  20915. for (var key in Object(object)) {
  20916. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  20917. result.push(key);
  20918. }
  20919. }
  20920. return result;
  20921. }
  20922. /**
  20923. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  20924. *
  20925. * @private
  20926. * @param {Object} object The object to query.
  20927. * @returns {Array} Returns the array of property names.
  20928. */
  20929. function baseKeysIn(object) {
  20930. if (!isObject(object)) {
  20931. return nativeKeysIn(object);
  20932. }
  20933. var isProto = isPrototype(object),
  20934. result = [];
  20935. for (var key in object) {
  20936. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  20937. result.push(key);
  20938. }
  20939. }
  20940. return result;
  20941. }
  20942. /**
  20943. * The base implementation of `_.lt` which doesn't coerce arguments.
  20944. *
  20945. * @private
  20946. * @param {*} value The value to compare.
  20947. * @param {*} other The other value to compare.
  20948. * @returns {boolean} Returns `true` if `value` is less than `other`,
  20949. * else `false`.
  20950. */
  20951. function baseLt(value, other) {
  20952. return value < other;
  20953. }
  20954. /**
  20955. * The base implementation of `_.map` without support for iteratee shorthands.
  20956. *
  20957. * @private
  20958. * @param {Array|Object} collection The collection to iterate over.
  20959. * @param {Function} iteratee The function invoked per iteration.
  20960. * @returns {Array} Returns the new mapped array.
  20961. */
  20962. function baseMap(collection, iteratee) {
  20963. var index = -1,
  20964. result = isArrayLike(collection) ? Array(collection.length) : [];
  20965. baseEach(collection, function(value, key, collection) {
  20966. result[++index] = iteratee(value, key, collection);
  20967. });
  20968. return result;
  20969. }
  20970. /**
  20971. * The base implementation of `_.matches` which doesn't clone `source`.
  20972. *
  20973. * @private
  20974. * @param {Object} source The object of property values to match.
  20975. * @returns {Function} Returns the new spec function.
  20976. */
  20977. function baseMatches(source) {
  20978. var matchData = getMatchData(source);
  20979. if (matchData.length == 1 && matchData[0][2]) {
  20980. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  20981. }
  20982. return function(object) {
  20983. return object === source || baseIsMatch(object, source, matchData);
  20984. };
  20985. }
  20986. /**
  20987. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  20988. *
  20989. * @private
  20990. * @param {string} path The path of the property to get.
  20991. * @param {*} srcValue The value to match.
  20992. * @returns {Function} Returns the new spec function.
  20993. */
  20994. function baseMatchesProperty(path, srcValue) {
  20995. if (isKey(path) && isStrictComparable(srcValue)) {
  20996. return matchesStrictComparable(toKey(path), srcValue);
  20997. }
  20998. return function(object) {
  20999. var objValue = get(object, path);
  21000. return (objValue === undefined && objValue === srcValue)
  21001. ? hasIn(object, path)
  21002. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  21003. };
  21004. }
  21005. /**
  21006. * The base implementation of `_.merge` without support for multiple sources.
  21007. *
  21008. * @private
  21009. * @param {Object} object The destination object.
  21010. * @param {Object} source The source object.
  21011. * @param {number} srcIndex The index of `source`.
  21012. * @param {Function} [customizer] The function to customize merged values.
  21013. * @param {Object} [stack] Tracks traversed source values and their merged
  21014. * counterparts.
  21015. */
  21016. function baseMerge(object, source, srcIndex, customizer, stack) {
  21017. if (object === source) {
  21018. return;
  21019. }
  21020. baseFor(source, function(srcValue, key) {
  21021. stack || (stack = new Stack);
  21022. if (isObject(srcValue)) {
  21023. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  21024. }
  21025. else {
  21026. var newValue = customizer
  21027. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  21028. : undefined;
  21029. if (newValue === undefined) {
  21030. newValue = srcValue;
  21031. }
  21032. assignMergeValue(object, key, newValue);
  21033. }
  21034. }, keysIn);
  21035. }
  21036. /**
  21037. * A specialized version of `baseMerge` for arrays and objects which performs
  21038. * deep merges and tracks traversed objects enabling objects with circular
  21039. * references to be merged.
  21040. *
  21041. * @private
  21042. * @param {Object} object The destination object.
  21043. * @param {Object} source The source object.
  21044. * @param {string} key The key of the value to merge.
  21045. * @param {number} srcIndex The index of `source`.
  21046. * @param {Function} mergeFunc The function to merge values.
  21047. * @param {Function} [customizer] The function to customize assigned values.
  21048. * @param {Object} [stack] Tracks traversed source values and their merged
  21049. * counterparts.
  21050. */
  21051. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  21052. var objValue = safeGet(object, key),
  21053. srcValue = safeGet(source, key),
  21054. stacked = stack.get(srcValue);
  21055. if (stacked) {
  21056. assignMergeValue(object, key, stacked);
  21057. return;
  21058. }
  21059. var newValue = customizer
  21060. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  21061. : undefined;
  21062. var isCommon = newValue === undefined;
  21063. if (isCommon) {
  21064. var isArr = isArray(srcValue),
  21065. isBuff = !isArr && isBuffer(srcValue),
  21066. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  21067. newValue = srcValue;
  21068. if (isArr || isBuff || isTyped) {
  21069. if (isArray(objValue)) {
  21070. newValue = objValue;
  21071. }
  21072. else if (isArrayLikeObject(objValue)) {
  21073. newValue = copyArray(objValue);
  21074. }
  21075. else if (isBuff) {
  21076. isCommon = false;
  21077. newValue = cloneBuffer(srcValue, true);
  21078. }
  21079. else if (isTyped) {
  21080. isCommon = false;
  21081. newValue = cloneTypedArray(srcValue, true);
  21082. }
  21083. else {
  21084. newValue = [];
  21085. }
  21086. }
  21087. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  21088. newValue = objValue;
  21089. if (isArguments(objValue)) {
  21090. newValue = toPlainObject(objValue);
  21091. }
  21092. else if (!isObject(objValue) || isFunction(objValue)) {
  21093. newValue = initCloneObject(srcValue);
  21094. }
  21095. }
  21096. else {
  21097. isCommon = false;
  21098. }
  21099. }
  21100. if (isCommon) {
  21101. // Recursively merge objects and arrays (susceptible to call stack limits).
  21102. stack.set(srcValue, newValue);
  21103. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  21104. stack['delete'](srcValue);
  21105. }
  21106. assignMergeValue(object, key, newValue);
  21107. }
  21108. /**
  21109. * The base implementation of `_.nth` which doesn't coerce arguments.
  21110. *
  21111. * @private
  21112. * @param {Array} array The array to query.
  21113. * @param {number} n The index of the element to return.
  21114. * @returns {*} Returns the nth element of `array`.
  21115. */
  21116. function baseNth(array, n) {
  21117. var length = array.length;
  21118. if (!length) {
  21119. return;
  21120. }
  21121. n += n < 0 ? length : 0;
  21122. return isIndex(n, length) ? array[n] : undefined;
  21123. }
  21124. /**
  21125. * The base implementation of `_.orderBy` without param guards.
  21126. *
  21127. * @private
  21128. * @param {Array|Object} collection The collection to iterate over.
  21129. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  21130. * @param {string[]} orders The sort orders of `iteratees`.
  21131. * @returns {Array} Returns the new sorted array.
  21132. */
  21133. function baseOrderBy(collection, iteratees, orders) {
  21134. var index = -1;
  21135. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  21136. var result = baseMap(collection, function(value, key, collection) {
  21137. var criteria = arrayMap(iteratees, function(iteratee) {
  21138. return iteratee(value);
  21139. });
  21140. return { 'criteria': criteria, 'index': ++index, 'value': value };
  21141. });
  21142. return baseSortBy(result, function(object, other) {
  21143. return compareMultiple(object, other, orders);
  21144. });
  21145. }
  21146. /**
  21147. * The base implementation of `_.pick` without support for individual
  21148. * property identifiers.
  21149. *
  21150. * @private
  21151. * @param {Object} object The source object.
  21152. * @param {string[]} paths The property paths to pick.
  21153. * @returns {Object} Returns the new object.
  21154. */
  21155. function basePick(object, paths) {
  21156. return basePickBy(object, paths, function(value, path) {
  21157. return hasIn(object, path);
  21158. });
  21159. }
  21160. /**
  21161. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  21162. *
  21163. * @private
  21164. * @param {Object} object The source object.
  21165. * @param {string[]} paths The property paths to pick.
  21166. * @param {Function} predicate The function invoked per property.
  21167. * @returns {Object} Returns the new object.
  21168. */
  21169. function basePickBy(object, paths, predicate) {
  21170. var index = -1,
  21171. length = paths.length,
  21172. result = {};
  21173. while (++index < length) {
  21174. var path = paths[index],
  21175. value = baseGet(object, path);
  21176. if (predicate(value, path)) {
  21177. baseSet(result, castPath(path, object), value);
  21178. }
  21179. }
  21180. return result;
  21181. }
  21182. /**
  21183. * A specialized version of `baseProperty` which supports deep paths.
  21184. *
  21185. * @private
  21186. * @param {Array|string} path The path of the property to get.
  21187. * @returns {Function} Returns the new accessor function.
  21188. */
  21189. function basePropertyDeep(path) {
  21190. return function(object) {
  21191. return baseGet(object, path);
  21192. };
  21193. }
  21194. /**
  21195. * The base implementation of `_.pullAllBy` without support for iteratee
  21196. * shorthands.
  21197. *
  21198. * @private
  21199. * @param {Array} array The array to modify.
  21200. * @param {Array} values The values to remove.
  21201. * @param {Function} [iteratee] The iteratee invoked per element.
  21202. * @param {Function} [comparator] The comparator invoked per element.
  21203. * @returns {Array} Returns `array`.
  21204. */
  21205. function basePullAll(array, values, iteratee, comparator) {
  21206. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  21207. index = -1,
  21208. length = values.length,
  21209. seen = array;
  21210. if (array === values) {
  21211. values = copyArray(values);
  21212. }
  21213. if (iteratee) {
  21214. seen = arrayMap(array, baseUnary(iteratee));
  21215. }
  21216. while (++index < length) {
  21217. var fromIndex = 0,
  21218. value = values[index],
  21219. computed = iteratee ? iteratee(value) : value;
  21220. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  21221. if (seen !== array) {
  21222. splice.call(seen, fromIndex, 1);
  21223. }
  21224. splice.call(array, fromIndex, 1);
  21225. }
  21226. }
  21227. return array;
  21228. }
  21229. /**
  21230. * The base implementation of `_.pullAt` without support for individual
  21231. * indexes or capturing the removed elements.
  21232. *
  21233. * @private
  21234. * @param {Array} array The array to modify.
  21235. * @param {number[]} indexes The indexes of elements to remove.
  21236. * @returns {Array} Returns `array`.
  21237. */
  21238. function basePullAt(array, indexes) {
  21239. var length = array ? indexes.length : 0,
  21240. lastIndex = length - 1;
  21241. while (length--) {
  21242. var index = indexes[length];
  21243. if (length == lastIndex || index !== previous) {
  21244. var previous = index;
  21245. if (isIndex(index)) {
  21246. splice.call(array, index, 1);
  21247. } else {
  21248. baseUnset(array, index);
  21249. }
  21250. }
  21251. }
  21252. return array;
  21253. }
  21254. /**
  21255. * The base implementation of `_.random` without support for returning
  21256. * floating-point numbers.
  21257. *
  21258. * @private
  21259. * @param {number} lower The lower bound.
  21260. * @param {number} upper The upper bound.
  21261. * @returns {number} Returns the random number.
  21262. */
  21263. function baseRandom(lower, upper) {
  21264. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  21265. }
  21266. /**
  21267. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  21268. * coerce arguments.
  21269. *
  21270. * @private
  21271. * @param {number} start The start of the range.
  21272. * @param {number} end The end of the range.
  21273. * @param {number} step The value to increment or decrement by.
  21274. * @param {boolean} [fromRight] Specify iterating from right to left.
  21275. * @returns {Array} Returns the range of numbers.
  21276. */
  21277. function baseRange(start, end, step, fromRight) {
  21278. var index = -1,
  21279. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  21280. result = Array(length);
  21281. while (length--) {
  21282. result[fromRight ? length : ++index] = start;
  21283. start += step;
  21284. }
  21285. return result;
  21286. }
  21287. /**
  21288. * The base implementation of `_.repeat` which doesn't coerce arguments.
  21289. *
  21290. * @private
  21291. * @param {string} string The string to repeat.
  21292. * @param {number} n The number of times to repeat the string.
  21293. * @returns {string} Returns the repeated string.
  21294. */
  21295. function baseRepeat(string, n) {
  21296. var result = '';
  21297. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  21298. return result;
  21299. }
  21300. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  21301. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  21302. do {
  21303. if (n % 2) {
  21304. result += string;
  21305. }
  21306. n = nativeFloor(n / 2);
  21307. if (n) {
  21308. string += string;
  21309. }
  21310. } while (n);
  21311. return result;
  21312. }
  21313. /**
  21314. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  21315. *
  21316. * @private
  21317. * @param {Function} func The function to apply a rest parameter to.
  21318. * @param {number} [start=func.length-1] The start position of the rest parameter.
  21319. * @returns {Function} Returns the new function.
  21320. */
  21321. function baseRest(func, start) {
  21322. return setToString(overRest(func, start, identity), func + '');
  21323. }
  21324. /**
  21325. * The base implementation of `_.sample`.
  21326. *
  21327. * @private
  21328. * @param {Array|Object} collection The collection to sample.
  21329. * @returns {*} Returns the random element.
  21330. */
  21331. function baseSample(collection) {
  21332. return arraySample(values(collection));
  21333. }
  21334. /**
  21335. * The base implementation of `_.sampleSize` without param guards.
  21336. *
  21337. * @private
  21338. * @param {Array|Object} collection The collection to sample.
  21339. * @param {number} n The number of elements to sample.
  21340. * @returns {Array} Returns the random elements.
  21341. */
  21342. function baseSampleSize(collection, n) {
  21343. var array = values(collection);
  21344. return shuffleSelf(array, baseClamp(n, 0, array.length));
  21345. }
  21346. /**
  21347. * The base implementation of `_.set`.
  21348. *
  21349. * @private
  21350. * @param {Object} object The object to modify.
  21351. * @param {Array|string} path The path of the property to set.
  21352. * @param {*} value The value to set.
  21353. * @param {Function} [customizer] The function to customize path creation.
  21354. * @returns {Object} Returns `object`.
  21355. */
  21356. function baseSet(object, path, value, customizer) {
  21357. if (!isObject(object)) {
  21358. return object;
  21359. }
  21360. path = castPath(path, object);
  21361. var index = -1,
  21362. length = path.length,
  21363. lastIndex = length - 1,
  21364. nested = object;
  21365. while (nested != null && ++index < length) {
  21366. var key = toKey(path[index]),
  21367. newValue = value;
  21368. if (index != lastIndex) {
  21369. var objValue = nested[key];
  21370. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  21371. if (newValue === undefined) {
  21372. newValue = isObject(objValue)
  21373. ? objValue
  21374. : (isIndex(path[index + 1]) ? [] : {});
  21375. }
  21376. }
  21377. assignValue(nested, key, newValue);
  21378. nested = nested[key];
  21379. }
  21380. return object;
  21381. }
  21382. /**
  21383. * The base implementation of `setData` without support for hot loop shorting.
  21384. *
  21385. * @private
  21386. * @param {Function} func The function to associate metadata with.
  21387. * @param {*} data The metadata.
  21388. * @returns {Function} Returns `func`.
  21389. */
  21390. var baseSetData = !metaMap ? identity : function(func, data) {
  21391. metaMap.set(func, data);
  21392. return func;
  21393. };
  21394. /**
  21395. * The base implementation of `setToString` without support for hot loop shorting.
  21396. *
  21397. * @private
  21398. * @param {Function} func The function to modify.
  21399. * @param {Function} string The `toString` result.
  21400. * @returns {Function} Returns `func`.
  21401. */
  21402. var baseSetToString = !defineProperty ? identity : function(func, string) {
  21403. return defineProperty(func, 'toString', {
  21404. 'configurable': true,
  21405. 'enumerable': false,
  21406. 'value': constant(string),
  21407. 'writable': true
  21408. });
  21409. };
  21410. /**
  21411. * The base implementation of `_.shuffle`.
  21412. *
  21413. * @private
  21414. * @param {Array|Object} collection The collection to shuffle.
  21415. * @returns {Array} Returns the new shuffled array.
  21416. */
  21417. function baseShuffle(collection) {
  21418. return shuffleSelf(values(collection));
  21419. }
  21420. /**
  21421. * The base implementation of `_.slice` without an iteratee call guard.
  21422. *
  21423. * @private
  21424. * @param {Array} array The array to slice.
  21425. * @param {number} [start=0] The start position.
  21426. * @param {number} [end=array.length] The end position.
  21427. * @returns {Array} Returns the slice of `array`.
  21428. */
  21429. function baseSlice(array, start, end) {
  21430. var index = -1,
  21431. length = array.length;
  21432. if (start < 0) {
  21433. start = -start > length ? 0 : (length + start);
  21434. }
  21435. end = end > length ? length : end;
  21436. if (end < 0) {
  21437. end += length;
  21438. }
  21439. length = start > end ? 0 : ((end - start) >>> 0);
  21440. start >>>= 0;
  21441. var result = Array(length);
  21442. while (++index < length) {
  21443. result[index] = array[index + start];
  21444. }
  21445. return result;
  21446. }
  21447. /**
  21448. * The base implementation of `_.some` without support for iteratee shorthands.
  21449. *
  21450. * @private
  21451. * @param {Array|Object} collection The collection to iterate over.
  21452. * @param {Function} predicate The function invoked per iteration.
  21453. * @returns {boolean} Returns `true` if any element passes the predicate check,
  21454. * else `false`.
  21455. */
  21456. function baseSome(collection, predicate) {
  21457. var result;
  21458. baseEach(collection, function(value, index, collection) {
  21459. result = predicate(value, index, collection);
  21460. return !result;
  21461. });
  21462. return !!result;
  21463. }
  21464. /**
  21465. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  21466. * performs a binary search of `array` to determine the index at which `value`
  21467. * should be inserted into `array` in order to maintain its sort order.
  21468. *
  21469. * @private
  21470. * @param {Array} array The sorted array to inspect.
  21471. * @param {*} value The value to evaluate.
  21472. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21473. * @returns {number} Returns the index at which `value` should be inserted
  21474. * into `array`.
  21475. */
  21476. function baseSortedIndex(array, value, retHighest) {
  21477. var low = 0,
  21478. high = array == null ? low : array.length;
  21479. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  21480. while (low < high) {
  21481. var mid = (low + high) >>> 1,
  21482. computed = array[mid];
  21483. if (computed !== null && !isSymbol(computed) &&
  21484. (retHighest ? (computed <= value) : (computed < value))) {
  21485. low = mid + 1;
  21486. } else {
  21487. high = mid;
  21488. }
  21489. }
  21490. return high;
  21491. }
  21492. return baseSortedIndexBy(array, value, identity, retHighest);
  21493. }
  21494. /**
  21495. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  21496. * which invokes `iteratee` for `value` and each element of `array` to compute
  21497. * their sort ranking. The iteratee is invoked with one argument; (value).
  21498. *
  21499. * @private
  21500. * @param {Array} array The sorted array to inspect.
  21501. * @param {*} value The value to evaluate.
  21502. * @param {Function} iteratee The iteratee invoked per element.
  21503. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21504. * @returns {number} Returns the index at which `value` should be inserted
  21505. * into `array`.
  21506. */
  21507. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  21508. value = iteratee(value);
  21509. var low = 0,
  21510. high = array == null ? 0 : array.length,
  21511. valIsNaN = value !== value,
  21512. valIsNull = value === null,
  21513. valIsSymbol = isSymbol(value),
  21514. valIsUndefined = value === undefined;
  21515. while (low < high) {
  21516. var mid = nativeFloor((low + high) / 2),
  21517. computed = iteratee(array[mid]),
  21518. othIsDefined = computed !== undefined,
  21519. othIsNull = computed === null,
  21520. othIsReflexive = computed === computed,
  21521. othIsSymbol = isSymbol(computed);
  21522. if (valIsNaN) {
  21523. var setLow = retHighest || othIsReflexive;
  21524. } else if (valIsUndefined) {
  21525. setLow = othIsReflexive && (retHighest || othIsDefined);
  21526. } else if (valIsNull) {
  21527. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  21528. } else if (valIsSymbol) {
  21529. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  21530. } else if (othIsNull || othIsSymbol) {
  21531. setLow = false;
  21532. } else {
  21533. setLow = retHighest ? (computed <= value) : (computed < value);
  21534. }
  21535. if (setLow) {
  21536. low = mid + 1;
  21537. } else {
  21538. high = mid;
  21539. }
  21540. }
  21541. return nativeMin(high, MAX_ARRAY_INDEX);
  21542. }
  21543. /**
  21544. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  21545. * support for iteratee shorthands.
  21546. *
  21547. * @private
  21548. * @param {Array} array The array to inspect.
  21549. * @param {Function} [iteratee] The iteratee invoked per element.
  21550. * @returns {Array} Returns the new duplicate free array.
  21551. */
  21552. function baseSortedUniq(array, iteratee) {
  21553. var index = -1,
  21554. length = array.length,
  21555. resIndex = 0,
  21556. result = [];
  21557. while (++index < length) {
  21558. var value = array[index],
  21559. computed = iteratee ? iteratee(value) : value;
  21560. if (!index || !eq(computed, seen)) {
  21561. var seen = computed;
  21562. result[resIndex++] = value === 0 ? 0 : value;
  21563. }
  21564. }
  21565. return result;
  21566. }
  21567. /**
  21568. * The base implementation of `_.toNumber` which doesn't ensure correct
  21569. * conversions of binary, hexadecimal, or octal string values.
  21570. *
  21571. * @private
  21572. * @param {*} value The value to process.
  21573. * @returns {number} Returns the number.
  21574. */
  21575. function baseToNumber(value) {
  21576. if (typeof value == 'number') {
  21577. return value;
  21578. }
  21579. if (isSymbol(value)) {
  21580. return NAN;
  21581. }
  21582. return +value;
  21583. }
  21584. /**
  21585. * The base implementation of `_.toString` which doesn't convert nullish
  21586. * values to empty strings.
  21587. *
  21588. * @private
  21589. * @param {*} value The value to process.
  21590. * @returns {string} Returns the string.
  21591. */
  21592. function baseToString(value) {
  21593. // Exit early for strings to avoid a performance hit in some environments.
  21594. if (typeof value == 'string') {
  21595. return value;
  21596. }
  21597. if (isArray(value)) {
  21598. // Recursively convert values (susceptible to call stack limits).
  21599. return arrayMap(value, baseToString) + '';
  21600. }
  21601. if (isSymbol(value)) {
  21602. return symbolToString ? symbolToString.call(value) : '';
  21603. }
  21604. var result = (value + '');
  21605. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  21606. }
  21607. /**
  21608. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  21609. *
  21610. * @private
  21611. * @param {Array} array The array to inspect.
  21612. * @param {Function} [iteratee] The iteratee invoked per element.
  21613. * @param {Function} [comparator] The comparator invoked per element.
  21614. * @returns {Array} Returns the new duplicate free array.
  21615. */
  21616. function baseUniq(array, iteratee, comparator) {
  21617. var index = -1,
  21618. includes = arrayIncludes,
  21619. length = array.length,
  21620. isCommon = true,
  21621. result = [],
  21622. seen = result;
  21623. if (comparator) {
  21624. isCommon = false;
  21625. includes = arrayIncludesWith;
  21626. }
  21627. else if (length >= LARGE_ARRAY_SIZE) {
  21628. var set = iteratee ? null : createSet(array);
  21629. if (set) {
  21630. return setToArray(set);
  21631. }
  21632. isCommon = false;
  21633. includes = cacheHas;
  21634. seen = new SetCache;
  21635. }
  21636. else {
  21637. seen = iteratee ? [] : result;
  21638. }
  21639. outer:
  21640. while (++index < length) {
  21641. var value = array[index],
  21642. computed = iteratee ? iteratee(value) : value;
  21643. value = (comparator || value !== 0) ? value : 0;
  21644. if (isCommon && computed === computed) {
  21645. var seenIndex = seen.length;
  21646. while (seenIndex--) {
  21647. if (seen[seenIndex] === computed) {
  21648. continue outer;
  21649. }
  21650. }
  21651. if (iteratee) {
  21652. seen.push(computed);
  21653. }
  21654. result.push(value);
  21655. }
  21656. else if (!includes(seen, computed, comparator)) {
  21657. if (seen !== result) {
  21658. seen.push(computed);
  21659. }
  21660. result.push(value);
  21661. }
  21662. }
  21663. return result;
  21664. }
  21665. /**
  21666. * The base implementation of `_.unset`.
  21667. *
  21668. * @private
  21669. * @param {Object} object The object to modify.
  21670. * @param {Array|string} path The property path to unset.
  21671. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  21672. */
  21673. function baseUnset(object, path) {
  21674. path = castPath(path, object);
  21675. object = parent(object, path);
  21676. return object == null || delete object[toKey(last(path))];
  21677. }
  21678. /**
  21679. * The base implementation of `_.update`.
  21680. *
  21681. * @private
  21682. * @param {Object} object The object to modify.
  21683. * @param {Array|string} path The path of the property to update.
  21684. * @param {Function} updater The function to produce the updated value.
  21685. * @param {Function} [customizer] The function to customize path creation.
  21686. * @returns {Object} Returns `object`.
  21687. */
  21688. function baseUpdate(object, path, updater, customizer) {
  21689. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  21690. }
  21691. /**
  21692. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  21693. * without support for iteratee shorthands.
  21694. *
  21695. * @private
  21696. * @param {Array} array The array to query.
  21697. * @param {Function} predicate The function invoked per iteration.
  21698. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  21699. * @param {boolean} [fromRight] Specify iterating from right to left.
  21700. * @returns {Array} Returns the slice of `array`.
  21701. */
  21702. function baseWhile(array, predicate, isDrop, fromRight) {
  21703. var length = array.length,
  21704. index = fromRight ? length : -1;
  21705. while ((fromRight ? index-- : ++index < length) &&
  21706. predicate(array[index], index, array)) {}
  21707. return isDrop
  21708. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  21709. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  21710. }
  21711. /**
  21712. * The base implementation of `wrapperValue` which returns the result of
  21713. * performing a sequence of actions on the unwrapped `value`, where each
  21714. * successive action is supplied the return value of the previous.
  21715. *
  21716. * @private
  21717. * @param {*} value The unwrapped value.
  21718. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  21719. * @returns {*} Returns the resolved value.
  21720. */
  21721. function baseWrapperValue(value, actions) {
  21722. var result = value;
  21723. if (result instanceof LazyWrapper) {
  21724. result = result.value();
  21725. }
  21726. return arrayReduce(actions, function(result, action) {
  21727. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  21728. }, result);
  21729. }
  21730. /**
  21731. * The base implementation of methods like `_.xor`, without support for
  21732. * iteratee shorthands, that accepts an array of arrays to inspect.
  21733. *
  21734. * @private
  21735. * @param {Array} arrays The arrays to inspect.
  21736. * @param {Function} [iteratee] The iteratee invoked per element.
  21737. * @param {Function} [comparator] The comparator invoked per element.
  21738. * @returns {Array} Returns the new array of values.
  21739. */
  21740. function baseXor(arrays, iteratee, comparator) {
  21741. var length = arrays.length;
  21742. if (length < 2) {
  21743. return length ? baseUniq(arrays[0]) : [];
  21744. }
  21745. var index = -1,
  21746. result = Array(length);
  21747. while (++index < length) {
  21748. var array = arrays[index],
  21749. othIndex = -1;
  21750. while (++othIndex < length) {
  21751. if (othIndex != index) {
  21752. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  21753. }
  21754. }
  21755. }
  21756. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  21757. }
  21758. /**
  21759. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  21760. *
  21761. * @private
  21762. * @param {Array} props The property identifiers.
  21763. * @param {Array} values The property values.
  21764. * @param {Function} assignFunc The function to assign values.
  21765. * @returns {Object} Returns the new object.
  21766. */
  21767. function baseZipObject(props, values, assignFunc) {
  21768. var index = -1,
  21769. length = props.length,
  21770. valsLength = values.length,
  21771. result = {};
  21772. while (++index < length) {
  21773. var value = index < valsLength ? values[index] : undefined;
  21774. assignFunc(result, props[index], value);
  21775. }
  21776. return result;
  21777. }
  21778. /**
  21779. * Casts `value` to an empty array if it's not an array like object.
  21780. *
  21781. * @private
  21782. * @param {*} value The value to inspect.
  21783. * @returns {Array|Object} Returns the cast array-like object.
  21784. */
  21785. function castArrayLikeObject(value) {
  21786. return isArrayLikeObject(value) ? value : [];
  21787. }
  21788. /**
  21789. * Casts `value` to `identity` if it's not a function.
  21790. *
  21791. * @private
  21792. * @param {*} value The value to inspect.
  21793. * @returns {Function} Returns cast function.
  21794. */
  21795. function castFunction(value) {
  21796. return typeof value == 'function' ? value : identity;
  21797. }
  21798. /**
  21799. * Casts `value` to a path array if it's not one.
  21800. *
  21801. * @private
  21802. * @param {*} value The value to inspect.
  21803. * @param {Object} [object] The object to query keys on.
  21804. * @returns {Array} Returns the cast property path array.
  21805. */
  21806. function castPath(value, object) {
  21807. if (isArray(value)) {
  21808. return value;
  21809. }
  21810. return isKey(value, object) ? [value] : stringToPath(toString(value));
  21811. }
  21812. /**
  21813. * A `baseRest` alias which can be replaced with `identity` by module
  21814. * replacement plugins.
  21815. *
  21816. * @private
  21817. * @type {Function}
  21818. * @param {Function} func The function to apply a rest parameter to.
  21819. * @returns {Function} Returns the new function.
  21820. */
  21821. var castRest = baseRest;
  21822. /**
  21823. * Casts `array` to a slice if it's needed.
  21824. *
  21825. * @private
  21826. * @param {Array} array The array to inspect.
  21827. * @param {number} start The start position.
  21828. * @param {number} [end=array.length] The end position.
  21829. * @returns {Array} Returns the cast slice.
  21830. */
  21831. function castSlice(array, start, end) {
  21832. var length = array.length;
  21833. end = end === undefined ? length : end;
  21834. return (!start && end >= length) ? array : baseSlice(array, start, end);
  21835. }
  21836. /**
  21837. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  21838. *
  21839. * @private
  21840. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  21841. */
  21842. var clearTimeout = ctxClearTimeout || function(id) {
  21843. return root.clearTimeout(id);
  21844. };
  21845. /**
  21846. * Creates a clone of `buffer`.
  21847. *
  21848. * @private
  21849. * @param {Buffer} buffer The buffer to clone.
  21850. * @param {boolean} [isDeep] Specify a deep clone.
  21851. * @returns {Buffer} Returns the cloned buffer.
  21852. */
  21853. function cloneBuffer(buffer, isDeep) {
  21854. if (isDeep) {
  21855. return buffer.slice();
  21856. }
  21857. var length = buffer.length,
  21858. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  21859. buffer.copy(result);
  21860. return result;
  21861. }
  21862. /**
  21863. * Creates a clone of `arrayBuffer`.
  21864. *
  21865. * @private
  21866. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  21867. * @returns {ArrayBuffer} Returns the cloned array buffer.
  21868. */
  21869. function cloneArrayBuffer(arrayBuffer) {
  21870. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  21871. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  21872. return result;
  21873. }
  21874. /**
  21875. * Creates a clone of `dataView`.
  21876. *
  21877. * @private
  21878. * @param {Object} dataView The data view to clone.
  21879. * @param {boolean} [isDeep] Specify a deep clone.
  21880. * @returns {Object} Returns the cloned data view.
  21881. */
  21882. function cloneDataView(dataView, isDeep) {
  21883. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  21884. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  21885. }
  21886. /**
  21887. * Creates a clone of `regexp`.
  21888. *
  21889. * @private
  21890. * @param {Object} regexp The regexp to clone.
  21891. * @returns {Object} Returns the cloned regexp.
  21892. */
  21893. function cloneRegExp(regexp) {
  21894. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  21895. result.lastIndex = regexp.lastIndex;
  21896. return result;
  21897. }
  21898. /**
  21899. * Creates a clone of the `symbol` object.
  21900. *
  21901. * @private
  21902. * @param {Object} symbol The symbol object to clone.
  21903. * @returns {Object} Returns the cloned symbol object.
  21904. */
  21905. function cloneSymbol(symbol) {
  21906. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  21907. }
  21908. /**
  21909. * Creates a clone of `typedArray`.
  21910. *
  21911. * @private
  21912. * @param {Object} typedArray The typed array to clone.
  21913. * @param {boolean} [isDeep] Specify a deep clone.
  21914. * @returns {Object} Returns the cloned typed array.
  21915. */
  21916. function cloneTypedArray(typedArray, isDeep) {
  21917. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  21918. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  21919. }
  21920. /**
  21921. * Compares values to sort them in ascending order.
  21922. *
  21923. * @private
  21924. * @param {*} value The value to compare.
  21925. * @param {*} other The other value to compare.
  21926. * @returns {number} Returns the sort order indicator for `value`.
  21927. */
  21928. function compareAscending(value, other) {
  21929. if (value !== other) {
  21930. var valIsDefined = value !== undefined,
  21931. valIsNull = value === null,
  21932. valIsReflexive = value === value,
  21933. valIsSymbol = isSymbol(value);
  21934. var othIsDefined = other !== undefined,
  21935. othIsNull = other === null,
  21936. othIsReflexive = other === other,
  21937. othIsSymbol = isSymbol(other);
  21938. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  21939. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  21940. (valIsNull && othIsDefined && othIsReflexive) ||
  21941. (!valIsDefined && othIsReflexive) ||
  21942. !valIsReflexive) {
  21943. return 1;
  21944. }
  21945. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21946. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21947. (othIsNull && valIsDefined && valIsReflexive) ||
  21948. (!othIsDefined && valIsReflexive) ||
  21949. !othIsReflexive) {
  21950. return -1;
  21951. }
  21952. }
  21953. return 0;
  21954. }
  21955. /**
  21956. * Used by `_.orderBy` to compare multiple properties of a value to another
  21957. * and stable sort them.
  21958. *
  21959. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21960. * specify an order of "desc" for descending or "asc" for ascending sort order
  21961. * of corresponding values.
  21962. *
  21963. * @private
  21964. * @param {Object} object The object to compare.
  21965. * @param {Object} other The other object to compare.
  21966. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21967. * @returns {number} Returns the sort order indicator for `object`.
  21968. */
  21969. function compareMultiple(object, other, orders) {
  21970. var index = -1,
  21971. objCriteria = object.criteria,
  21972. othCriteria = other.criteria,
  21973. length = objCriteria.length,
  21974. ordersLength = orders.length;
  21975. while (++index < length) {
  21976. var result = compareAscending(objCriteria[index], othCriteria[index]);
  21977. if (result) {
  21978. if (index >= ordersLength) {
  21979. return result;
  21980. }
  21981. var order = orders[index];
  21982. return result * (order == 'desc' ? -1 : 1);
  21983. }
  21984. }
  21985. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  21986. // that causes it, under certain circumstances, to provide the same value for
  21987. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  21988. // for more details.
  21989. //
  21990. // This also ensures a stable sort in V8 and other engines.
  21991. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  21992. return object.index - other.index;
  21993. }
  21994. /**
  21995. * Creates an array that is the composition of partially applied arguments,
  21996. * placeholders, and provided arguments into a single array of arguments.
  21997. *
  21998. * @private
  21999. * @param {Array} args The provided arguments.
  22000. * @param {Array} partials The arguments to prepend to those provided.
  22001. * @param {Array} holders The `partials` placeholder indexes.
  22002. * @params {boolean} [isCurried] Specify composing for a curried function.
  22003. * @returns {Array} Returns the new array of composed arguments.
  22004. */
  22005. function composeArgs(args, partials, holders, isCurried) {
  22006. var argsIndex = -1,
  22007. argsLength = args.length,
  22008. holdersLength = holders.length,
  22009. leftIndex = -1,
  22010. leftLength = partials.length,
  22011. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22012. result = Array(leftLength + rangeLength),
  22013. isUncurried = !isCurried;
  22014. while (++leftIndex < leftLength) {
  22015. result[leftIndex] = partials[leftIndex];
  22016. }
  22017. while (++argsIndex < holdersLength) {
  22018. if (isUncurried || argsIndex < argsLength) {
  22019. result[holders[argsIndex]] = args[argsIndex];
  22020. }
  22021. }
  22022. while (rangeLength--) {
  22023. result[leftIndex++] = args[argsIndex++];
  22024. }
  22025. return result;
  22026. }
  22027. /**
  22028. * This function is like `composeArgs` except that the arguments composition
  22029. * is tailored for `_.partialRight`.
  22030. *
  22031. * @private
  22032. * @param {Array} args The provided arguments.
  22033. * @param {Array} partials The arguments to append to those provided.
  22034. * @param {Array} holders The `partials` placeholder indexes.
  22035. * @params {boolean} [isCurried] Specify composing for a curried function.
  22036. * @returns {Array} Returns the new array of composed arguments.
  22037. */
  22038. function composeArgsRight(args, partials, holders, isCurried) {
  22039. var argsIndex = -1,
  22040. argsLength = args.length,
  22041. holdersIndex = -1,
  22042. holdersLength = holders.length,
  22043. rightIndex = -1,
  22044. rightLength = partials.length,
  22045. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22046. result = Array(rangeLength + rightLength),
  22047. isUncurried = !isCurried;
  22048. while (++argsIndex < rangeLength) {
  22049. result[argsIndex] = args[argsIndex];
  22050. }
  22051. var offset = argsIndex;
  22052. while (++rightIndex < rightLength) {
  22053. result[offset + rightIndex] = partials[rightIndex];
  22054. }
  22055. while (++holdersIndex < holdersLength) {
  22056. if (isUncurried || argsIndex < argsLength) {
  22057. result[offset + holders[holdersIndex]] = args[argsIndex++];
  22058. }
  22059. }
  22060. return result;
  22061. }
  22062. /**
  22063. * Copies the values of `source` to `array`.
  22064. *
  22065. * @private
  22066. * @param {Array} source The array to copy values from.
  22067. * @param {Array} [array=[]] The array to copy values to.
  22068. * @returns {Array} Returns `array`.
  22069. */
  22070. function copyArray(source, array) {
  22071. var index = -1,
  22072. length = source.length;
  22073. array || (array = Array(length));
  22074. while (++index < length) {
  22075. array[index] = source[index];
  22076. }
  22077. return array;
  22078. }
  22079. /**
  22080. * Copies properties of `source` to `object`.
  22081. *
  22082. * @private
  22083. * @param {Object} source The object to copy properties from.
  22084. * @param {Array} props The property identifiers to copy.
  22085. * @param {Object} [object={}] The object to copy properties to.
  22086. * @param {Function} [customizer] The function to customize copied values.
  22087. * @returns {Object} Returns `object`.
  22088. */
  22089. function copyObject(source, props, object, customizer) {
  22090. var isNew = !object;
  22091. object || (object = {});
  22092. var index = -1,
  22093. length = props.length;
  22094. while (++index < length) {
  22095. var key = props[index];
  22096. var newValue = customizer
  22097. ? customizer(object[key], source[key], key, object, source)
  22098. : undefined;
  22099. if (newValue === undefined) {
  22100. newValue = source[key];
  22101. }
  22102. if (isNew) {
  22103. baseAssignValue(object, key, newValue);
  22104. } else {
  22105. assignValue(object, key, newValue);
  22106. }
  22107. }
  22108. return object;
  22109. }
  22110. /**
  22111. * Copies own symbols of `source` to `object`.
  22112. *
  22113. * @private
  22114. * @param {Object} source The object to copy symbols from.
  22115. * @param {Object} [object={}] The object to copy symbols to.
  22116. * @returns {Object} Returns `object`.
  22117. */
  22118. function copySymbols(source, object) {
  22119. return copyObject(source, getSymbols(source), object);
  22120. }
  22121. /**
  22122. * Copies own and inherited symbols of `source` to `object`.
  22123. *
  22124. * @private
  22125. * @param {Object} source The object to copy symbols from.
  22126. * @param {Object} [object={}] The object to copy symbols to.
  22127. * @returns {Object} Returns `object`.
  22128. */
  22129. function copySymbolsIn(source, object) {
  22130. return copyObject(source, getSymbolsIn(source), object);
  22131. }
  22132. /**
  22133. * Creates a function like `_.groupBy`.
  22134. *
  22135. * @private
  22136. * @param {Function} setter The function to set accumulator values.
  22137. * @param {Function} [initializer] The accumulator object initializer.
  22138. * @returns {Function} Returns the new aggregator function.
  22139. */
  22140. function createAggregator(setter, initializer) {
  22141. return function(collection, iteratee) {
  22142. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  22143. accumulator = initializer ? initializer() : {};
  22144. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  22145. };
  22146. }
  22147. /**
  22148. * Creates a function like `_.assign`.
  22149. *
  22150. * @private
  22151. * @param {Function} assigner The function to assign values.
  22152. * @returns {Function} Returns the new assigner function.
  22153. */
  22154. function createAssigner(assigner) {
  22155. return baseRest(function(object, sources) {
  22156. var index = -1,
  22157. length = sources.length,
  22158. customizer = length > 1 ? sources[length - 1] : undefined,
  22159. guard = length > 2 ? sources[2] : undefined;
  22160. customizer = (assigner.length > 3 && typeof customizer == 'function')
  22161. ? (length--, customizer)
  22162. : undefined;
  22163. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  22164. customizer = length < 3 ? undefined : customizer;
  22165. length = 1;
  22166. }
  22167. object = Object(object);
  22168. while (++index < length) {
  22169. var source = sources[index];
  22170. if (source) {
  22171. assigner(object, source, index, customizer);
  22172. }
  22173. }
  22174. return object;
  22175. });
  22176. }
  22177. /**
  22178. * Creates a `baseEach` or `baseEachRight` function.
  22179. *
  22180. * @private
  22181. * @param {Function} eachFunc The function to iterate over a collection.
  22182. * @param {boolean} [fromRight] Specify iterating from right to left.
  22183. * @returns {Function} Returns the new base function.
  22184. */
  22185. function createBaseEach(eachFunc, fromRight) {
  22186. return function(collection, iteratee) {
  22187. if (collection == null) {
  22188. return collection;
  22189. }
  22190. if (!isArrayLike(collection)) {
  22191. return eachFunc(collection, iteratee);
  22192. }
  22193. var length = collection.length,
  22194. index = fromRight ? length : -1,
  22195. iterable = Object(collection);
  22196. while ((fromRight ? index-- : ++index < length)) {
  22197. if (iteratee(iterable[index], index, iterable) === false) {
  22198. break;
  22199. }
  22200. }
  22201. return collection;
  22202. };
  22203. }
  22204. /**
  22205. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  22206. *
  22207. * @private
  22208. * @param {boolean} [fromRight] Specify iterating from right to left.
  22209. * @returns {Function} Returns the new base function.
  22210. */
  22211. function createBaseFor(fromRight) {
  22212. return function(object, iteratee, keysFunc) {
  22213. var index = -1,
  22214. iterable = Object(object),
  22215. props = keysFunc(object),
  22216. length = props.length;
  22217. while (length--) {
  22218. var key = props[fromRight ? length : ++index];
  22219. if (iteratee(iterable[key], key, iterable) === false) {
  22220. break;
  22221. }
  22222. }
  22223. return object;
  22224. };
  22225. }
  22226. /**
  22227. * Creates a function that wraps `func` to invoke it with the optional `this`
  22228. * binding of `thisArg`.
  22229. *
  22230. * @private
  22231. * @param {Function} func The function to wrap.
  22232. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22233. * @param {*} [thisArg] The `this` binding of `func`.
  22234. * @returns {Function} Returns the new wrapped function.
  22235. */
  22236. function createBind(func, bitmask, thisArg) {
  22237. var isBind = bitmask & WRAP_BIND_FLAG,
  22238. Ctor = createCtor(func);
  22239. function wrapper() {
  22240. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22241. return fn.apply(isBind ? thisArg : this, arguments);
  22242. }
  22243. return wrapper;
  22244. }
  22245. /**
  22246. * Creates a function like `_.lowerFirst`.
  22247. *
  22248. * @private
  22249. * @param {string} methodName The name of the `String` case method to use.
  22250. * @returns {Function} Returns the new case function.
  22251. */
  22252. function createCaseFirst(methodName) {
  22253. return function(string) {
  22254. string = toString(string);
  22255. var strSymbols = hasUnicode(string)
  22256. ? stringToArray(string)
  22257. : undefined;
  22258. var chr = strSymbols
  22259. ? strSymbols[0]
  22260. : string.charAt(0);
  22261. var trailing = strSymbols
  22262. ? castSlice(strSymbols, 1).join('')
  22263. : string.slice(1);
  22264. return chr[methodName]() + trailing;
  22265. };
  22266. }
  22267. /**
  22268. * Creates a function like `_.camelCase`.
  22269. *
  22270. * @private
  22271. * @param {Function} callback The function to combine each word.
  22272. * @returns {Function} Returns the new compounder function.
  22273. */
  22274. function createCompounder(callback) {
  22275. return function(string) {
  22276. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  22277. };
  22278. }
  22279. /**
  22280. * Creates a function that produces an instance of `Ctor` regardless of
  22281. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  22282. *
  22283. * @private
  22284. * @param {Function} Ctor The constructor to wrap.
  22285. * @returns {Function} Returns the new wrapped function.
  22286. */
  22287. function createCtor(Ctor) {
  22288. return function() {
  22289. // Use a `switch` statement to work with class constructors. See
  22290. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  22291. // for more details.
  22292. var args = arguments;
  22293. switch (args.length) {
  22294. case 0: return new Ctor;
  22295. case 1: return new Ctor(args[0]);
  22296. case 2: return new Ctor(args[0], args[1]);
  22297. case 3: return new Ctor(args[0], args[1], args[2]);
  22298. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  22299. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  22300. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  22301. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  22302. }
  22303. var thisBinding = baseCreate(Ctor.prototype),
  22304. result = Ctor.apply(thisBinding, args);
  22305. // Mimic the constructor's `return` behavior.
  22306. // See https://es5.github.io/#x13.2.2 for more details.
  22307. return isObject(result) ? result : thisBinding;
  22308. };
  22309. }
  22310. /**
  22311. * Creates a function that wraps `func` to enable currying.
  22312. *
  22313. * @private
  22314. * @param {Function} func The function to wrap.
  22315. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22316. * @param {number} arity The arity of `func`.
  22317. * @returns {Function} Returns the new wrapped function.
  22318. */
  22319. function createCurry(func, bitmask, arity) {
  22320. var Ctor = createCtor(func);
  22321. function wrapper() {
  22322. var length = arguments.length,
  22323. args = Array(length),
  22324. index = length,
  22325. placeholder = getHolder(wrapper);
  22326. while (index--) {
  22327. args[index] = arguments[index];
  22328. }
  22329. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  22330. ? []
  22331. : replaceHolders(args, placeholder);
  22332. length -= holders.length;
  22333. if (length < arity) {
  22334. return createRecurry(
  22335. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  22336. args, holders, undefined, undefined, arity - length);
  22337. }
  22338. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22339. return apply(fn, this, args);
  22340. }
  22341. return wrapper;
  22342. }
  22343. /**
  22344. * Creates a `_.find` or `_.findLast` function.
  22345. *
  22346. * @private
  22347. * @param {Function} findIndexFunc The function to find the collection index.
  22348. * @returns {Function} Returns the new find function.
  22349. */
  22350. function createFind(findIndexFunc) {
  22351. return function(collection, predicate, fromIndex) {
  22352. var iterable = Object(collection);
  22353. if (!isArrayLike(collection)) {
  22354. var iteratee = getIteratee(predicate, 3);
  22355. collection = keys(collection);
  22356. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  22357. }
  22358. var index = findIndexFunc(collection, predicate, fromIndex);
  22359. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  22360. };
  22361. }
  22362. /**
  22363. * Creates a `_.flow` or `_.flowRight` function.
  22364. *
  22365. * @private
  22366. * @param {boolean} [fromRight] Specify iterating from right to left.
  22367. * @returns {Function} Returns the new flow function.
  22368. */
  22369. function createFlow(fromRight) {
  22370. return flatRest(function(funcs) {
  22371. var length = funcs.length,
  22372. index = length,
  22373. prereq = LodashWrapper.prototype.thru;
  22374. if (fromRight) {
  22375. funcs.reverse();
  22376. }
  22377. while (index--) {
  22378. var func = funcs[index];
  22379. if (typeof func != 'function') {
  22380. throw new TypeError(FUNC_ERROR_TEXT);
  22381. }
  22382. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  22383. var wrapper = new LodashWrapper([], true);
  22384. }
  22385. }
  22386. index = wrapper ? index : length;
  22387. while (++index < length) {
  22388. func = funcs[index];
  22389. var funcName = getFuncName(func),
  22390. data = funcName == 'wrapper' ? getData(func) : undefined;
  22391. if (data && isLaziable(data[0]) &&
  22392. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  22393. !data[4].length && data[9] == 1
  22394. ) {
  22395. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  22396. } else {
  22397. wrapper = (func.length == 1 && isLaziable(func))
  22398. ? wrapper[funcName]()
  22399. : wrapper.thru(func);
  22400. }
  22401. }
  22402. return function() {
  22403. var args = arguments,
  22404. value = args[0];
  22405. if (wrapper && args.length == 1 && isArray(value)) {
  22406. return wrapper.plant(value).value();
  22407. }
  22408. var index = 0,
  22409. result = length ? funcs[index].apply(this, args) : value;
  22410. while (++index < length) {
  22411. result = funcs[index].call(this, result);
  22412. }
  22413. return result;
  22414. };
  22415. });
  22416. }
  22417. /**
  22418. * Creates a function that wraps `func` to invoke it with optional `this`
  22419. * binding of `thisArg`, partial application, and currying.
  22420. *
  22421. * @private
  22422. * @param {Function|string} func The function or method name to wrap.
  22423. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22424. * @param {*} [thisArg] The `this` binding of `func`.
  22425. * @param {Array} [partials] The arguments to prepend to those provided to
  22426. * the new function.
  22427. * @param {Array} [holders] The `partials` placeholder indexes.
  22428. * @param {Array} [partialsRight] The arguments to append to those provided
  22429. * to the new function.
  22430. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  22431. * @param {Array} [argPos] The argument positions of the new function.
  22432. * @param {number} [ary] The arity cap of `func`.
  22433. * @param {number} [arity] The arity of `func`.
  22434. * @returns {Function} Returns the new wrapped function.
  22435. */
  22436. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  22437. var isAry = bitmask & WRAP_ARY_FLAG,
  22438. isBind = bitmask & WRAP_BIND_FLAG,
  22439. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  22440. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  22441. isFlip = bitmask & WRAP_FLIP_FLAG,
  22442. Ctor = isBindKey ? undefined : createCtor(func);
  22443. function wrapper() {
  22444. var length = arguments.length,
  22445. args = Array(length),
  22446. index = length;
  22447. while (index--) {
  22448. args[index] = arguments[index];
  22449. }
  22450. if (isCurried) {
  22451. var placeholder = getHolder(wrapper),
  22452. holdersCount = countHolders(args, placeholder);
  22453. }
  22454. if (partials) {
  22455. args = composeArgs(args, partials, holders, isCurried);
  22456. }
  22457. if (partialsRight) {
  22458. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  22459. }
  22460. length -= holdersCount;
  22461. if (isCurried && length < arity) {
  22462. var newHolders = replaceHolders(args, placeholder);
  22463. return createRecurry(
  22464. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  22465. args, newHolders, argPos, ary, arity - length
  22466. );
  22467. }
  22468. var thisBinding = isBind ? thisArg : this,
  22469. fn = isBindKey ? thisBinding[func] : func;
  22470. length = args.length;
  22471. if (argPos) {
  22472. args = reorder(args, argPos);
  22473. } else if (isFlip && length > 1) {
  22474. args.reverse();
  22475. }
  22476. if (isAry && ary < length) {
  22477. args.length = ary;
  22478. }
  22479. if (this && this !== root && this instanceof wrapper) {
  22480. fn = Ctor || createCtor(fn);
  22481. }
  22482. return fn.apply(thisBinding, args);
  22483. }
  22484. return wrapper;
  22485. }
  22486. /**
  22487. * Creates a function like `_.invertBy`.
  22488. *
  22489. * @private
  22490. * @param {Function} setter The function to set accumulator values.
  22491. * @param {Function} toIteratee The function to resolve iteratees.
  22492. * @returns {Function} Returns the new inverter function.
  22493. */
  22494. function createInverter(setter, toIteratee) {
  22495. return function(object, iteratee) {
  22496. return baseInverter(object, setter, toIteratee(iteratee), {});
  22497. };
  22498. }
  22499. /**
  22500. * Creates a function that performs a mathematical operation on two values.
  22501. *
  22502. * @private
  22503. * @param {Function} operator The function to perform the operation.
  22504. * @param {number} [defaultValue] The value used for `undefined` arguments.
  22505. * @returns {Function} Returns the new mathematical operation function.
  22506. */
  22507. function createMathOperation(operator, defaultValue) {
  22508. return function(value, other) {
  22509. var result;
  22510. if (value === undefined && other === undefined) {
  22511. return defaultValue;
  22512. }
  22513. if (value !== undefined) {
  22514. result = value;
  22515. }
  22516. if (other !== undefined) {
  22517. if (result === undefined) {
  22518. return other;
  22519. }
  22520. if (typeof value == 'string' || typeof other == 'string') {
  22521. value = baseToString(value);
  22522. other = baseToString(other);
  22523. } else {
  22524. value = baseToNumber(value);
  22525. other = baseToNumber(other);
  22526. }
  22527. result = operator(value, other);
  22528. }
  22529. return result;
  22530. };
  22531. }
  22532. /**
  22533. * Creates a function like `_.over`.
  22534. *
  22535. * @private
  22536. * @param {Function} arrayFunc The function to iterate over iteratees.
  22537. * @returns {Function} Returns the new over function.
  22538. */
  22539. function createOver(arrayFunc) {
  22540. return flatRest(function(iteratees) {
  22541. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  22542. return baseRest(function(args) {
  22543. var thisArg = this;
  22544. return arrayFunc(iteratees, function(iteratee) {
  22545. return apply(iteratee, thisArg, args);
  22546. });
  22547. });
  22548. });
  22549. }
  22550. /**
  22551. * Creates the padding for `string` based on `length`. The `chars` string
  22552. * is truncated if the number of characters exceeds `length`.
  22553. *
  22554. * @private
  22555. * @param {number} length The padding length.
  22556. * @param {string} [chars=' '] The string used as padding.
  22557. * @returns {string} Returns the padding for `string`.
  22558. */
  22559. function createPadding(length, chars) {
  22560. chars = chars === undefined ? ' ' : baseToString(chars);
  22561. var charsLength = chars.length;
  22562. if (charsLength < 2) {
  22563. return charsLength ? baseRepeat(chars, length) : chars;
  22564. }
  22565. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  22566. return hasUnicode(chars)
  22567. ? castSlice(stringToArray(result), 0, length).join('')
  22568. : result.slice(0, length);
  22569. }
  22570. /**
  22571. * Creates a function that wraps `func` to invoke it with the `this` binding
  22572. * of `thisArg` and `partials` prepended to the arguments it receives.
  22573. *
  22574. * @private
  22575. * @param {Function} func The function to wrap.
  22576. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22577. * @param {*} thisArg The `this` binding of `func`.
  22578. * @param {Array} partials The arguments to prepend to those provided to
  22579. * the new function.
  22580. * @returns {Function} Returns the new wrapped function.
  22581. */
  22582. function createPartial(func, bitmask, thisArg, partials) {
  22583. var isBind = bitmask & WRAP_BIND_FLAG,
  22584. Ctor = createCtor(func);
  22585. function wrapper() {
  22586. var argsIndex = -1,
  22587. argsLength = arguments.length,
  22588. leftIndex = -1,
  22589. leftLength = partials.length,
  22590. args = Array(leftLength + argsLength),
  22591. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22592. while (++leftIndex < leftLength) {
  22593. args[leftIndex] = partials[leftIndex];
  22594. }
  22595. while (argsLength--) {
  22596. args[leftIndex++] = arguments[++argsIndex];
  22597. }
  22598. return apply(fn, isBind ? thisArg : this, args);
  22599. }
  22600. return wrapper;
  22601. }
  22602. /**
  22603. * Creates a `_.range` or `_.rangeRight` function.
  22604. *
  22605. * @private
  22606. * @param {boolean} [fromRight] Specify iterating from right to left.
  22607. * @returns {Function} Returns the new range function.
  22608. */
  22609. function createRange(fromRight) {
  22610. return function(start, end, step) {
  22611. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  22612. end = step = undefined;
  22613. }
  22614. // Ensure the sign of `-0` is preserved.
  22615. start = toFinite(start);
  22616. if (end === undefined) {
  22617. end = start;
  22618. start = 0;
  22619. } else {
  22620. end = toFinite(end);
  22621. }
  22622. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  22623. return baseRange(start, end, step, fromRight);
  22624. };
  22625. }
  22626. /**
  22627. * Creates a function that performs a relational operation on two values.
  22628. *
  22629. * @private
  22630. * @param {Function} operator The function to perform the operation.
  22631. * @returns {Function} Returns the new relational operation function.
  22632. */
  22633. function createRelationalOperation(operator) {
  22634. return function(value, other) {
  22635. if (!(typeof value == 'string' && typeof other == 'string')) {
  22636. value = toNumber(value);
  22637. other = toNumber(other);
  22638. }
  22639. return operator(value, other);
  22640. };
  22641. }
  22642. /**
  22643. * Creates a function that wraps `func` to continue currying.
  22644. *
  22645. * @private
  22646. * @param {Function} func The function to wrap.
  22647. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22648. * @param {Function} wrapFunc The function to create the `func` wrapper.
  22649. * @param {*} placeholder The placeholder value.
  22650. * @param {*} [thisArg] The `this` binding of `func`.
  22651. * @param {Array} [partials] The arguments to prepend to those provided to
  22652. * the new function.
  22653. * @param {Array} [holders] The `partials` placeholder indexes.
  22654. * @param {Array} [argPos] The argument positions of the new function.
  22655. * @param {number} [ary] The arity cap of `func`.
  22656. * @param {number} [arity] The arity of `func`.
  22657. * @returns {Function} Returns the new wrapped function.
  22658. */
  22659. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  22660. var isCurry = bitmask & WRAP_CURRY_FLAG,
  22661. newHolders = isCurry ? holders : undefined,
  22662. newHoldersRight = isCurry ? undefined : holders,
  22663. newPartials = isCurry ? partials : undefined,
  22664. newPartialsRight = isCurry ? undefined : partials;
  22665. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  22666. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  22667. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  22668. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  22669. }
  22670. var newData = [
  22671. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  22672. newHoldersRight, argPos, ary, arity
  22673. ];
  22674. var result = wrapFunc.apply(undefined, newData);
  22675. if (isLaziable(func)) {
  22676. setData(result, newData);
  22677. }
  22678. result.placeholder = placeholder;
  22679. return setWrapToString(result, func, bitmask);
  22680. }
  22681. /**
  22682. * Creates a function like `_.round`.
  22683. *
  22684. * @private
  22685. * @param {string} methodName The name of the `Math` method to use when rounding.
  22686. * @returns {Function} Returns the new round function.
  22687. */
  22688. function createRound(methodName) {
  22689. var func = Math[methodName];
  22690. return function(number, precision) {
  22691. number = toNumber(number);
  22692. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  22693. if (precision && nativeIsFinite(number)) {
  22694. // Shift with exponential notation to avoid floating-point issues.
  22695. // See [MDN](https://mdn.io/round#Examples) for more details.
  22696. var pair = (toString(number) + 'e').split('e'),
  22697. value = func(pair[0] + 'e' + (+pair[1] + precision));
  22698. pair = (toString(value) + 'e').split('e');
  22699. return +(pair[0] + 'e' + (+pair[1] - precision));
  22700. }
  22701. return func(number);
  22702. };
  22703. }
  22704. /**
  22705. * Creates a set object of `values`.
  22706. *
  22707. * @private
  22708. * @param {Array} values The values to add to the set.
  22709. * @returns {Object} Returns the new set.
  22710. */
  22711. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  22712. return new Set(values);
  22713. };
  22714. /**
  22715. * Creates a `_.toPairs` or `_.toPairsIn` function.
  22716. *
  22717. * @private
  22718. * @param {Function} keysFunc The function to get the keys of a given object.
  22719. * @returns {Function} Returns the new pairs function.
  22720. */
  22721. function createToPairs(keysFunc) {
  22722. return function(object) {
  22723. var tag = getTag(object);
  22724. if (tag == mapTag) {
  22725. return mapToArray(object);
  22726. }
  22727. if (tag == setTag) {
  22728. return setToPairs(object);
  22729. }
  22730. return baseToPairs(object, keysFunc(object));
  22731. };
  22732. }
  22733. /**
  22734. * Creates a function that either curries or invokes `func` with optional
  22735. * `this` binding and partially applied arguments.
  22736. *
  22737. * @private
  22738. * @param {Function|string} func The function or method name to wrap.
  22739. * @param {number} bitmask The bitmask flags.
  22740. * 1 - `_.bind`
  22741. * 2 - `_.bindKey`
  22742. * 4 - `_.curry` or `_.curryRight` of a bound function
  22743. * 8 - `_.curry`
  22744. * 16 - `_.curryRight`
  22745. * 32 - `_.partial`
  22746. * 64 - `_.partialRight`
  22747. * 128 - `_.rearg`
  22748. * 256 - `_.ary`
  22749. * 512 - `_.flip`
  22750. * @param {*} [thisArg] The `this` binding of `func`.
  22751. * @param {Array} [partials] The arguments to be partially applied.
  22752. * @param {Array} [holders] The `partials` placeholder indexes.
  22753. * @param {Array} [argPos] The argument positions of the new function.
  22754. * @param {number} [ary] The arity cap of `func`.
  22755. * @param {number} [arity] The arity of `func`.
  22756. * @returns {Function} Returns the new wrapped function.
  22757. */
  22758. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  22759. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  22760. if (!isBindKey && typeof func != 'function') {
  22761. throw new TypeError(FUNC_ERROR_TEXT);
  22762. }
  22763. var length = partials ? partials.length : 0;
  22764. if (!length) {
  22765. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  22766. partials = holders = undefined;
  22767. }
  22768. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  22769. arity = arity === undefined ? arity : toInteger(arity);
  22770. length -= holders ? holders.length : 0;
  22771. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  22772. var partialsRight = partials,
  22773. holdersRight = holders;
  22774. partials = holders = undefined;
  22775. }
  22776. var data = isBindKey ? undefined : getData(func);
  22777. var newData = [
  22778. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  22779. argPos, ary, arity
  22780. ];
  22781. if (data) {
  22782. mergeData(newData, data);
  22783. }
  22784. func = newData[0];
  22785. bitmask = newData[1];
  22786. thisArg = newData[2];
  22787. partials = newData[3];
  22788. holders = newData[4];
  22789. arity = newData[9] = newData[9] === undefined
  22790. ? (isBindKey ? 0 : func.length)
  22791. : nativeMax(newData[9] - length, 0);
  22792. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  22793. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  22794. }
  22795. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  22796. var result = createBind(func, bitmask, thisArg);
  22797. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  22798. result = createCurry(func, bitmask, arity);
  22799. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  22800. result = createPartial(func, bitmask, thisArg, partials);
  22801. } else {
  22802. result = createHybrid.apply(undefined, newData);
  22803. }
  22804. var setter = data ? baseSetData : setData;
  22805. return setWrapToString(setter(result, newData), func, bitmask);
  22806. }
  22807. /**
  22808. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  22809. * of source objects to the destination object for all destination properties
  22810. * that resolve to `undefined`.
  22811. *
  22812. * @private
  22813. * @param {*} objValue The destination value.
  22814. * @param {*} srcValue The source value.
  22815. * @param {string} key The key of the property to assign.
  22816. * @param {Object} object The parent object of `objValue`.
  22817. * @returns {*} Returns the value to assign.
  22818. */
  22819. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  22820. if (objValue === undefined ||
  22821. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  22822. return srcValue;
  22823. }
  22824. return objValue;
  22825. }
  22826. /**
  22827. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  22828. * objects into destination objects that are passed thru.
  22829. *
  22830. * @private
  22831. * @param {*} objValue The destination value.
  22832. * @param {*} srcValue The source value.
  22833. * @param {string} key The key of the property to merge.
  22834. * @param {Object} object The parent object of `objValue`.
  22835. * @param {Object} source The parent object of `srcValue`.
  22836. * @param {Object} [stack] Tracks traversed source values and their merged
  22837. * counterparts.
  22838. * @returns {*} Returns the value to assign.
  22839. */
  22840. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  22841. if (isObject(objValue) && isObject(srcValue)) {
  22842. // Recursively merge objects and arrays (susceptible to call stack limits).
  22843. stack.set(srcValue, objValue);
  22844. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  22845. stack['delete'](srcValue);
  22846. }
  22847. return objValue;
  22848. }
  22849. /**
  22850. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  22851. * objects.
  22852. *
  22853. * @private
  22854. * @param {*} value The value to inspect.
  22855. * @param {string} key The key of the property to inspect.
  22856. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  22857. */
  22858. function customOmitClone(value) {
  22859. return isPlainObject(value) ? undefined : value;
  22860. }
  22861. /**
  22862. * A specialized version of `baseIsEqualDeep` for arrays with support for
  22863. * partial deep comparisons.
  22864. *
  22865. * @private
  22866. * @param {Array} array The array to compare.
  22867. * @param {Array} other The other array to compare.
  22868. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22869. * @param {Function} customizer The function to customize comparisons.
  22870. * @param {Function} equalFunc The function to determine equivalents of values.
  22871. * @param {Object} stack Tracks traversed `array` and `other` objects.
  22872. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  22873. */
  22874. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  22875. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22876. arrLength = array.length,
  22877. othLength = other.length;
  22878. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  22879. return false;
  22880. }
  22881. // Assume cyclic values are equal.
  22882. var stacked = stack.get(array);
  22883. if (stacked && stack.get(other)) {
  22884. return stacked == other;
  22885. }
  22886. var index = -1,
  22887. result = true,
  22888. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  22889. stack.set(array, other);
  22890. stack.set(other, array);
  22891. // Ignore non-index properties.
  22892. while (++index < arrLength) {
  22893. var arrValue = array[index],
  22894. othValue = other[index];
  22895. if (customizer) {
  22896. var compared = isPartial
  22897. ? customizer(othValue, arrValue, index, other, array, stack)
  22898. : customizer(arrValue, othValue, index, array, other, stack);
  22899. }
  22900. if (compared !== undefined) {
  22901. if (compared) {
  22902. continue;
  22903. }
  22904. result = false;
  22905. break;
  22906. }
  22907. // Recursively compare arrays (susceptible to call stack limits).
  22908. if (seen) {
  22909. if (!arraySome(other, function(othValue, othIndex) {
  22910. if (!cacheHas(seen, othIndex) &&
  22911. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22912. return seen.push(othIndex);
  22913. }
  22914. })) {
  22915. result = false;
  22916. break;
  22917. }
  22918. } else if (!(
  22919. arrValue === othValue ||
  22920. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  22921. )) {
  22922. result = false;
  22923. break;
  22924. }
  22925. }
  22926. stack['delete'](array);
  22927. stack['delete'](other);
  22928. return result;
  22929. }
  22930. /**
  22931. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22932. * the same `toStringTag`.
  22933. *
  22934. * **Note:** This function only supports comparing values with tags of
  22935. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22936. *
  22937. * @private
  22938. * @param {Object} object The object to compare.
  22939. * @param {Object} other The other object to compare.
  22940. * @param {string} tag The `toStringTag` of the objects to compare.
  22941. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22942. * @param {Function} customizer The function to customize comparisons.
  22943. * @param {Function} equalFunc The function to determine equivalents of values.
  22944. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22945. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22946. */
  22947. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22948. switch (tag) {
  22949. case dataViewTag:
  22950. if ((object.byteLength != other.byteLength) ||
  22951. (object.byteOffset != other.byteOffset)) {
  22952. return false;
  22953. }
  22954. object = object.buffer;
  22955. other = other.buffer;
  22956. case arrayBufferTag:
  22957. if ((object.byteLength != other.byteLength) ||
  22958. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22959. return false;
  22960. }
  22961. return true;
  22962. case boolTag:
  22963. case dateTag:
  22964. case numberTag:
  22965. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22966. // Invalid dates are coerced to `NaN`.
  22967. return eq(+object, +other);
  22968. case errorTag:
  22969. return object.name == other.name && object.message == other.message;
  22970. case regexpTag:
  22971. case stringTag:
  22972. // Coerce regexes to strings and treat strings, primitives and objects,
  22973. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22974. // for more details.
  22975. return object == (other + '');
  22976. case mapTag:
  22977. var convert = mapToArray;
  22978. case setTag:
  22979. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  22980. convert || (convert = setToArray);
  22981. if (object.size != other.size && !isPartial) {
  22982. return false;
  22983. }
  22984. // Assume cyclic values are equal.
  22985. var stacked = stack.get(object);
  22986. if (stacked) {
  22987. return stacked == other;
  22988. }
  22989. bitmask |= COMPARE_UNORDERED_FLAG;
  22990. // Recursively compare objects (susceptible to call stack limits).
  22991. stack.set(object, other);
  22992. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  22993. stack['delete'](object);
  22994. return result;
  22995. case symbolTag:
  22996. if (symbolValueOf) {
  22997. return symbolValueOf.call(object) == symbolValueOf.call(other);
  22998. }
  22999. }
  23000. return false;
  23001. }
  23002. /**
  23003. * A specialized version of `baseIsEqualDeep` for objects with support for
  23004. * partial deep comparisons.
  23005. *
  23006. * @private
  23007. * @param {Object} object The object to compare.
  23008. * @param {Object} other The other object to compare.
  23009. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23010. * @param {Function} customizer The function to customize comparisons.
  23011. * @param {Function} equalFunc The function to determine equivalents of values.
  23012. * @param {Object} stack Tracks traversed `object` and `other` objects.
  23013. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23014. */
  23015. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  23016. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  23017. objProps = getAllKeys(object),
  23018. objLength = objProps.length,
  23019. othProps = getAllKeys(other),
  23020. othLength = othProps.length;
  23021. if (objLength != othLength && !isPartial) {
  23022. return false;
  23023. }
  23024. var index = objLength;
  23025. while (index--) {
  23026. var key = objProps[index];
  23027. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  23028. return false;
  23029. }
  23030. }
  23031. // Assume cyclic values are equal.
  23032. var stacked = stack.get(object);
  23033. if (stacked && stack.get(other)) {
  23034. return stacked == other;
  23035. }
  23036. var result = true;
  23037. stack.set(object, other);
  23038. stack.set(other, object);
  23039. var skipCtor = isPartial;
  23040. while (++index < objLength) {
  23041. key = objProps[index];
  23042. var objValue = object[key],
  23043. othValue = other[key];
  23044. if (customizer) {
  23045. var compared = isPartial
  23046. ? customizer(othValue, objValue, key, other, object, stack)
  23047. : customizer(objValue, othValue, key, object, other, stack);
  23048. }
  23049. // Recursively compare objects (susceptible to call stack limits).
  23050. if (!(compared === undefined
  23051. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  23052. : compared
  23053. )) {
  23054. result = false;
  23055. break;
  23056. }
  23057. skipCtor || (skipCtor = key == 'constructor');
  23058. }
  23059. if (result && !skipCtor) {
  23060. var objCtor = object.constructor,
  23061. othCtor = other.constructor;
  23062. // Non `Object` object instances with different constructors are not equal.
  23063. if (objCtor != othCtor &&
  23064. ('constructor' in object && 'constructor' in other) &&
  23065. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  23066. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  23067. result = false;
  23068. }
  23069. }
  23070. stack['delete'](object);
  23071. stack['delete'](other);
  23072. return result;
  23073. }
  23074. /**
  23075. * A specialized version of `baseRest` which flattens the rest array.
  23076. *
  23077. * @private
  23078. * @param {Function} func The function to apply a rest parameter to.
  23079. * @returns {Function} Returns the new function.
  23080. */
  23081. function flatRest(func) {
  23082. return setToString(overRest(func, undefined, flatten), func + '');
  23083. }
  23084. /**
  23085. * Creates an array of own enumerable property names and symbols of `object`.
  23086. *
  23087. * @private
  23088. * @param {Object} object The object to query.
  23089. * @returns {Array} Returns the array of property names and symbols.
  23090. */
  23091. function getAllKeys(object) {
  23092. return baseGetAllKeys(object, keys, getSymbols);
  23093. }
  23094. /**
  23095. * Creates an array of own and inherited enumerable property names and
  23096. * symbols of `object`.
  23097. *
  23098. * @private
  23099. * @param {Object} object The object to query.
  23100. * @returns {Array} Returns the array of property names and symbols.
  23101. */
  23102. function getAllKeysIn(object) {
  23103. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  23104. }
  23105. /**
  23106. * Gets metadata for `func`.
  23107. *
  23108. * @private
  23109. * @param {Function} func The function to query.
  23110. * @returns {*} Returns the metadata for `func`.
  23111. */
  23112. var getData = !metaMap ? noop : function(func) {
  23113. return metaMap.get(func);
  23114. };
  23115. /**
  23116. * Gets the name of `func`.
  23117. *
  23118. * @private
  23119. * @param {Function} func The function to query.
  23120. * @returns {string} Returns the function name.
  23121. */
  23122. function getFuncName(func) {
  23123. var result = (func.name + ''),
  23124. array = realNames[result],
  23125. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  23126. while (length--) {
  23127. var data = array[length],
  23128. otherFunc = data.func;
  23129. if (otherFunc == null || otherFunc == func) {
  23130. return data.name;
  23131. }
  23132. }
  23133. return result;
  23134. }
  23135. /**
  23136. * Gets the argument placeholder value for `func`.
  23137. *
  23138. * @private
  23139. * @param {Function} func The function to inspect.
  23140. * @returns {*} Returns the placeholder value.
  23141. */
  23142. function getHolder(func) {
  23143. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  23144. return object.placeholder;
  23145. }
  23146. /**
  23147. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  23148. * this function returns the custom method, otherwise it returns `baseIteratee`.
  23149. * If arguments are provided, the chosen function is invoked with them and
  23150. * its result is returned.
  23151. *
  23152. * @private
  23153. * @param {*} [value] The value to convert to an iteratee.
  23154. * @param {number} [arity] The arity of the created iteratee.
  23155. * @returns {Function} Returns the chosen function or its result.
  23156. */
  23157. function getIteratee() {
  23158. var result = lodash.iteratee || iteratee;
  23159. result = result === iteratee ? baseIteratee : result;
  23160. return arguments.length ? result(arguments[0], arguments[1]) : result;
  23161. }
  23162. /**
  23163. * Gets the data for `map`.
  23164. *
  23165. * @private
  23166. * @param {Object} map The map to query.
  23167. * @param {string} key The reference key.
  23168. * @returns {*} Returns the map data.
  23169. */
  23170. function getMapData(map, key) {
  23171. var data = map.__data__;
  23172. return isKeyable(key)
  23173. ? data[typeof key == 'string' ? 'string' : 'hash']
  23174. : data.map;
  23175. }
  23176. /**
  23177. * Gets the property names, values, and compare flags of `object`.
  23178. *
  23179. * @private
  23180. * @param {Object} object The object to query.
  23181. * @returns {Array} Returns the match data of `object`.
  23182. */
  23183. function getMatchData(object) {
  23184. var result = keys(object),
  23185. length = result.length;
  23186. while (length--) {
  23187. var key = result[length],
  23188. value = object[key];
  23189. result[length] = [key, value, isStrictComparable(value)];
  23190. }
  23191. return result;
  23192. }
  23193. /**
  23194. * Gets the native function at `key` of `object`.
  23195. *
  23196. * @private
  23197. * @param {Object} object The object to query.
  23198. * @param {string} key The key of the method to get.
  23199. * @returns {*} Returns the function if it's native, else `undefined`.
  23200. */
  23201. function getNative(object, key) {
  23202. var value = getValue(object, key);
  23203. return baseIsNative(value) ? value : undefined;
  23204. }
  23205. /**
  23206. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  23207. *
  23208. * @private
  23209. * @param {*} value The value to query.
  23210. * @returns {string} Returns the raw `toStringTag`.
  23211. */
  23212. function getRawTag(value) {
  23213. var isOwn = hasOwnProperty.call(value, symToStringTag),
  23214. tag = value[symToStringTag];
  23215. try {
  23216. value[symToStringTag] = undefined;
  23217. var unmasked = true;
  23218. } catch (e) {}
  23219. var result = nativeObjectToString.call(value);
  23220. if (unmasked) {
  23221. if (isOwn) {
  23222. value[symToStringTag] = tag;
  23223. } else {
  23224. delete value[symToStringTag];
  23225. }
  23226. }
  23227. return result;
  23228. }
  23229. /**
  23230. * Creates an array of the own enumerable symbols of `object`.
  23231. *
  23232. * @private
  23233. * @param {Object} object The object to query.
  23234. * @returns {Array} Returns the array of symbols.
  23235. */
  23236. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  23237. if (object == null) {
  23238. return [];
  23239. }
  23240. object = Object(object);
  23241. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  23242. return propertyIsEnumerable.call(object, symbol);
  23243. });
  23244. };
  23245. /**
  23246. * Creates an array of the own and inherited enumerable symbols of `object`.
  23247. *
  23248. * @private
  23249. * @param {Object} object The object to query.
  23250. * @returns {Array} Returns the array of symbols.
  23251. */
  23252. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  23253. var result = [];
  23254. while (object) {
  23255. arrayPush(result, getSymbols(object));
  23256. object = getPrototype(object);
  23257. }
  23258. return result;
  23259. };
  23260. /**
  23261. * Gets the `toStringTag` of `value`.
  23262. *
  23263. * @private
  23264. * @param {*} value The value to query.
  23265. * @returns {string} Returns the `toStringTag`.
  23266. */
  23267. var getTag = baseGetTag;
  23268. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  23269. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  23270. (Map && getTag(new Map) != mapTag) ||
  23271. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  23272. (Set && getTag(new Set) != setTag) ||
  23273. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  23274. getTag = function(value) {
  23275. var result = baseGetTag(value),
  23276. Ctor = result == objectTag ? value.constructor : undefined,
  23277. ctorString = Ctor ? toSource(Ctor) : '';
  23278. if (ctorString) {
  23279. switch (ctorString) {
  23280. case dataViewCtorString: return dataViewTag;
  23281. case mapCtorString: return mapTag;
  23282. case promiseCtorString: return promiseTag;
  23283. case setCtorString: return setTag;
  23284. case weakMapCtorString: return weakMapTag;
  23285. }
  23286. }
  23287. return result;
  23288. };
  23289. }
  23290. /**
  23291. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  23292. *
  23293. * @private
  23294. * @param {number} start The start of the view.
  23295. * @param {number} end The end of the view.
  23296. * @param {Array} transforms The transformations to apply to the view.
  23297. * @returns {Object} Returns an object containing the `start` and `end`
  23298. * positions of the view.
  23299. */
  23300. function getView(start, end, transforms) {
  23301. var index = -1,
  23302. length = transforms.length;
  23303. while (++index < length) {
  23304. var data = transforms[index],
  23305. size = data.size;
  23306. switch (data.type) {
  23307. case 'drop': start += size; break;
  23308. case 'dropRight': end -= size; break;
  23309. case 'take': end = nativeMin(end, start + size); break;
  23310. case 'takeRight': start = nativeMax(start, end - size); break;
  23311. }
  23312. }
  23313. return { 'start': start, 'end': end };
  23314. }
  23315. /**
  23316. * Extracts wrapper details from the `source` body comment.
  23317. *
  23318. * @private
  23319. * @param {string} source The source to inspect.
  23320. * @returns {Array} Returns the wrapper details.
  23321. */
  23322. function getWrapDetails(source) {
  23323. var match = source.match(reWrapDetails);
  23324. return match ? match[1].split(reSplitDetails) : [];
  23325. }
  23326. /**
  23327. * Checks if `path` exists on `object`.
  23328. *
  23329. * @private
  23330. * @param {Object} object The object to query.
  23331. * @param {Array|string} path The path to check.
  23332. * @param {Function} hasFunc The function to check properties.
  23333. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  23334. */
  23335. function hasPath(object, path, hasFunc) {
  23336. path = castPath(path, object);
  23337. var index = -1,
  23338. length = path.length,
  23339. result = false;
  23340. while (++index < length) {
  23341. var key = toKey(path[index]);
  23342. if (!(result = object != null && hasFunc(object, key))) {
  23343. break;
  23344. }
  23345. object = object[key];
  23346. }
  23347. if (result || ++index != length) {
  23348. return result;
  23349. }
  23350. length = object == null ? 0 : object.length;
  23351. return !!length && isLength(length) && isIndex(key, length) &&
  23352. (isArray(object) || isArguments(object));
  23353. }
  23354. /**
  23355. * Initializes an array clone.
  23356. *
  23357. * @private
  23358. * @param {Array} array The array to clone.
  23359. * @returns {Array} Returns the initialized clone.
  23360. */
  23361. function initCloneArray(array) {
  23362. var length = array.length,
  23363. result = new array.constructor(length);
  23364. // Add properties assigned by `RegExp#exec`.
  23365. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  23366. result.index = array.index;
  23367. result.input = array.input;
  23368. }
  23369. return result;
  23370. }
  23371. /**
  23372. * Initializes an object clone.
  23373. *
  23374. * @private
  23375. * @param {Object} object The object to clone.
  23376. * @returns {Object} Returns the initialized clone.
  23377. */
  23378. function initCloneObject(object) {
  23379. return (typeof object.constructor == 'function' && !isPrototype(object))
  23380. ? baseCreate(getPrototype(object))
  23381. : {};
  23382. }
  23383. /**
  23384. * Initializes an object clone based on its `toStringTag`.
  23385. *
  23386. * **Note:** This function only supports cloning values with tags of
  23387. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  23388. *
  23389. * @private
  23390. * @param {Object} object The object to clone.
  23391. * @param {string} tag The `toStringTag` of the object to clone.
  23392. * @param {boolean} [isDeep] Specify a deep clone.
  23393. * @returns {Object} Returns the initialized clone.
  23394. */
  23395. function initCloneByTag(object, tag, isDeep) {
  23396. var Ctor = object.constructor;
  23397. switch (tag) {
  23398. case arrayBufferTag:
  23399. return cloneArrayBuffer(object);
  23400. case boolTag:
  23401. case dateTag:
  23402. return new Ctor(+object);
  23403. case dataViewTag:
  23404. return cloneDataView(object, isDeep);
  23405. case float32Tag: case float64Tag:
  23406. case int8Tag: case int16Tag: case int32Tag:
  23407. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  23408. return cloneTypedArray(object, isDeep);
  23409. case mapTag:
  23410. return new Ctor;
  23411. case numberTag:
  23412. case stringTag:
  23413. return new Ctor(object);
  23414. case regexpTag:
  23415. return cloneRegExp(object);
  23416. case setTag:
  23417. return new Ctor;
  23418. case symbolTag:
  23419. return cloneSymbol(object);
  23420. }
  23421. }
  23422. /**
  23423. * Inserts wrapper `details` in a comment at the top of the `source` body.
  23424. *
  23425. * @private
  23426. * @param {string} source The source to modify.
  23427. * @returns {Array} details The details to insert.
  23428. * @returns {string} Returns the modified source.
  23429. */
  23430. function insertWrapDetails(source, details) {
  23431. var length = details.length;
  23432. if (!length) {
  23433. return source;
  23434. }
  23435. var lastIndex = length - 1;
  23436. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  23437. details = details.join(length > 2 ? ', ' : ' ');
  23438. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  23439. }
  23440. /**
  23441. * Checks if `value` is a flattenable `arguments` object or array.
  23442. *
  23443. * @private
  23444. * @param {*} value The value to check.
  23445. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  23446. */
  23447. function isFlattenable(value) {
  23448. return isArray(value) || isArguments(value) ||
  23449. !!(spreadableSymbol && value && value[spreadableSymbol]);
  23450. }
  23451. /**
  23452. * Checks if `value` is a valid array-like index.
  23453. *
  23454. * @private
  23455. * @param {*} value The value to check.
  23456. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  23457. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  23458. */
  23459. function isIndex(value, length) {
  23460. var type = typeof value;
  23461. length = length == null ? MAX_SAFE_INTEGER : length;
  23462. return !!length &&
  23463. (type == 'number' ||
  23464. (type != 'symbol' && reIsUint.test(value))) &&
  23465. (value > -1 && value % 1 == 0 && value < length);
  23466. }
  23467. /**
  23468. * Checks if the given arguments are from an iteratee call.
  23469. *
  23470. * @private
  23471. * @param {*} value The potential iteratee value argument.
  23472. * @param {*} index The potential iteratee index or key argument.
  23473. * @param {*} object The potential iteratee object argument.
  23474. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  23475. * else `false`.
  23476. */
  23477. function isIterateeCall(value, index, object) {
  23478. if (!isObject(object)) {
  23479. return false;
  23480. }
  23481. var type = typeof index;
  23482. if (type == 'number'
  23483. ? (isArrayLike(object) && isIndex(index, object.length))
  23484. : (type == 'string' && index in object)
  23485. ) {
  23486. return eq(object[index], value);
  23487. }
  23488. return false;
  23489. }
  23490. /**
  23491. * Checks if `value` is a property name and not a property path.
  23492. *
  23493. * @private
  23494. * @param {*} value The value to check.
  23495. * @param {Object} [object] The object to query keys on.
  23496. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  23497. */
  23498. function isKey(value, object) {
  23499. if (isArray(value)) {
  23500. return false;
  23501. }
  23502. var type = typeof value;
  23503. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  23504. value == null || isSymbol(value)) {
  23505. return true;
  23506. }
  23507. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  23508. (object != null && value in Object(object));
  23509. }
  23510. /**
  23511. * Checks if `value` is suitable for use as unique object key.
  23512. *
  23513. * @private
  23514. * @param {*} value The value to check.
  23515. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  23516. */
  23517. function isKeyable(value) {
  23518. var type = typeof value;
  23519. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  23520. ? (value !== '__proto__')
  23521. : (value === null);
  23522. }
  23523. /**
  23524. * Checks if `func` has a lazy counterpart.
  23525. *
  23526. * @private
  23527. * @param {Function} func The function to check.
  23528. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  23529. * else `false`.
  23530. */
  23531. function isLaziable(func) {
  23532. var funcName = getFuncName(func),
  23533. other = lodash[funcName];
  23534. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  23535. return false;
  23536. }
  23537. if (func === other) {
  23538. return true;
  23539. }
  23540. var data = getData(other);
  23541. return !!data && func === data[0];
  23542. }
  23543. /**
  23544. * Checks if `func` has its source masked.
  23545. *
  23546. * @private
  23547. * @param {Function} func The function to check.
  23548. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  23549. */
  23550. function isMasked(func) {
  23551. return !!maskSrcKey && (maskSrcKey in func);
  23552. }
  23553. /**
  23554. * Checks if `func` is capable of being masked.
  23555. *
  23556. * @private
  23557. * @param {*} value The value to check.
  23558. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  23559. */
  23560. var isMaskable = coreJsData ? isFunction : stubFalse;
  23561. /**
  23562. * Checks if `value` is likely a prototype object.
  23563. *
  23564. * @private
  23565. * @param {*} value The value to check.
  23566. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  23567. */
  23568. function isPrototype(value) {
  23569. var Ctor = value && value.constructor,
  23570. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  23571. return value === proto;
  23572. }
  23573. /**
  23574. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  23575. *
  23576. * @private
  23577. * @param {*} value The value to check.
  23578. * @returns {boolean} Returns `true` if `value` if suitable for strict
  23579. * equality comparisons, else `false`.
  23580. */
  23581. function isStrictComparable(value) {
  23582. return value === value && !isObject(value);
  23583. }
  23584. /**
  23585. * A specialized version of `matchesProperty` for source values suitable
  23586. * for strict equality comparisons, i.e. `===`.
  23587. *
  23588. * @private
  23589. * @param {string} key The key of the property to get.
  23590. * @param {*} srcValue The value to match.
  23591. * @returns {Function} Returns the new spec function.
  23592. */
  23593. function matchesStrictComparable(key, srcValue) {
  23594. return function(object) {
  23595. if (object == null) {
  23596. return false;
  23597. }
  23598. return object[key] === srcValue &&
  23599. (srcValue !== undefined || (key in Object(object)));
  23600. };
  23601. }
  23602. /**
  23603. * A specialized version of `_.memoize` which clears the memoized function's
  23604. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  23605. *
  23606. * @private
  23607. * @param {Function} func The function to have its output memoized.
  23608. * @returns {Function} Returns the new memoized function.
  23609. */
  23610. function memoizeCapped(func) {
  23611. var result = memoize(func, function(key) {
  23612. if (cache.size === MAX_MEMOIZE_SIZE) {
  23613. cache.clear();
  23614. }
  23615. return key;
  23616. });
  23617. var cache = result.cache;
  23618. return result;
  23619. }
  23620. /**
  23621. * Merges the function metadata of `source` into `data`.
  23622. *
  23623. * Merging metadata reduces the number of wrappers used to invoke a function.
  23624. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  23625. * may be applied regardless of execution order. Methods like `_.ary` and
  23626. * `_.rearg` modify function arguments, making the order in which they are
  23627. * executed important, preventing the merging of metadata. However, we make
  23628. * an exception for a safe combined case where curried functions have `_.ary`
  23629. * and or `_.rearg` applied.
  23630. *
  23631. * @private
  23632. * @param {Array} data The destination metadata.
  23633. * @param {Array} source The source metadata.
  23634. * @returns {Array} Returns `data`.
  23635. */
  23636. function mergeData(data, source) {
  23637. var bitmask = data[1],
  23638. srcBitmask = source[1],
  23639. newBitmask = bitmask | srcBitmask,
  23640. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  23641. var isCombo =
  23642. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  23643. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  23644. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  23645. // Exit early if metadata can't be merged.
  23646. if (!(isCommon || isCombo)) {
  23647. return data;
  23648. }
  23649. // Use source `thisArg` if available.
  23650. if (srcBitmask & WRAP_BIND_FLAG) {
  23651. data[2] = source[2];
  23652. // Set when currying a bound function.
  23653. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  23654. }
  23655. // Compose partial arguments.
  23656. var value = source[3];
  23657. if (value) {
  23658. var partials = data[3];
  23659. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  23660. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  23661. }
  23662. // Compose partial right arguments.
  23663. value = source[5];
  23664. if (value) {
  23665. partials = data[5];
  23666. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  23667. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  23668. }
  23669. // Use source `argPos` if available.
  23670. value = source[7];
  23671. if (value) {
  23672. data[7] = value;
  23673. }
  23674. // Use source `ary` if it's smaller.
  23675. if (srcBitmask & WRAP_ARY_FLAG) {
  23676. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  23677. }
  23678. // Use source `arity` if one is not provided.
  23679. if (data[9] == null) {
  23680. data[9] = source[9];
  23681. }
  23682. // Use source `func` and merge bitmasks.
  23683. data[0] = source[0];
  23684. data[1] = newBitmask;
  23685. return data;
  23686. }
  23687. /**
  23688. * This function is like
  23689. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  23690. * except that it includes inherited enumerable properties.
  23691. *
  23692. * @private
  23693. * @param {Object} object The object to query.
  23694. * @returns {Array} Returns the array of property names.
  23695. */
  23696. function nativeKeysIn(object) {
  23697. var result = [];
  23698. if (object != null) {
  23699. for (var key in Object(object)) {
  23700. result.push(key);
  23701. }
  23702. }
  23703. return result;
  23704. }
  23705. /**
  23706. * Converts `value` to a string using `Object.prototype.toString`.
  23707. *
  23708. * @private
  23709. * @param {*} value The value to convert.
  23710. * @returns {string} Returns the converted string.
  23711. */
  23712. function objectToString(value) {
  23713. return nativeObjectToString.call(value);
  23714. }
  23715. /**
  23716. * A specialized version of `baseRest` which transforms the rest array.
  23717. *
  23718. * @private
  23719. * @param {Function} func The function to apply a rest parameter to.
  23720. * @param {number} [start=func.length-1] The start position of the rest parameter.
  23721. * @param {Function} transform The rest array transform.
  23722. * @returns {Function} Returns the new function.
  23723. */
  23724. function overRest(func, start, transform) {
  23725. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  23726. return function() {
  23727. var args = arguments,
  23728. index = -1,
  23729. length = nativeMax(args.length - start, 0),
  23730. array = Array(length);
  23731. while (++index < length) {
  23732. array[index] = args[start + index];
  23733. }
  23734. index = -1;
  23735. var otherArgs = Array(start + 1);
  23736. while (++index < start) {
  23737. otherArgs[index] = args[index];
  23738. }
  23739. otherArgs[start] = transform(array);
  23740. return apply(func, this, otherArgs);
  23741. };
  23742. }
  23743. /**
  23744. * Gets the parent value at `path` of `object`.
  23745. *
  23746. * @private
  23747. * @param {Object} object The object to query.
  23748. * @param {Array} path The path to get the parent value of.
  23749. * @returns {*} Returns the parent value.
  23750. */
  23751. function parent(object, path) {
  23752. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  23753. }
  23754. /**
  23755. * Reorder `array` according to the specified indexes where the element at
  23756. * the first index is assigned as the first element, the element at
  23757. * the second index is assigned as the second element, and so on.
  23758. *
  23759. * @private
  23760. * @param {Array} array The array to reorder.
  23761. * @param {Array} indexes The arranged array indexes.
  23762. * @returns {Array} Returns `array`.
  23763. */
  23764. function reorder(array, indexes) {
  23765. var arrLength = array.length,
  23766. length = nativeMin(indexes.length, arrLength),
  23767. oldArray = copyArray(array);
  23768. while (length--) {
  23769. var index = indexes[length];
  23770. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  23771. }
  23772. return array;
  23773. }
  23774. /**
  23775. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  23776. *
  23777. * @private
  23778. * @param {Object} object The object to query.
  23779. * @param {string} key The key of the property to get.
  23780. * @returns {*} Returns the property value.
  23781. */
  23782. function safeGet(object, key) {
  23783. if (key === 'constructor' && typeof object[key] === 'function') {
  23784. return;
  23785. }
  23786. if (key == '__proto__') {
  23787. return;
  23788. }
  23789. return object[key];
  23790. }
  23791. /**
  23792. * Sets metadata for `func`.
  23793. *
  23794. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  23795. * period of time, it will trip its breaker and transition to an identity
  23796. * function to avoid garbage collection pauses in V8. See
  23797. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  23798. * for more details.
  23799. *
  23800. * @private
  23801. * @param {Function} func The function to associate metadata with.
  23802. * @param {*} data The metadata.
  23803. * @returns {Function} Returns `func`.
  23804. */
  23805. var setData = shortOut(baseSetData);
  23806. /**
  23807. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  23808. *
  23809. * @private
  23810. * @param {Function} func The function to delay.
  23811. * @param {number} wait The number of milliseconds to delay invocation.
  23812. * @returns {number|Object} Returns the timer id or timeout object.
  23813. */
  23814. var setTimeout = ctxSetTimeout || function(func, wait) {
  23815. return root.setTimeout(func, wait);
  23816. };
  23817. /**
  23818. * Sets the `toString` method of `func` to return `string`.
  23819. *
  23820. * @private
  23821. * @param {Function} func The function to modify.
  23822. * @param {Function} string The `toString` result.
  23823. * @returns {Function} Returns `func`.
  23824. */
  23825. var setToString = shortOut(baseSetToString);
  23826. /**
  23827. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  23828. * with wrapper details in a comment at the top of the source body.
  23829. *
  23830. * @private
  23831. * @param {Function} wrapper The function to modify.
  23832. * @param {Function} reference The reference function.
  23833. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23834. * @returns {Function} Returns `wrapper`.
  23835. */
  23836. function setWrapToString(wrapper, reference, bitmask) {
  23837. var source = (reference + '');
  23838. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  23839. }
  23840. /**
  23841. * Creates a function that'll short out and invoke `identity` instead
  23842. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  23843. * milliseconds.
  23844. *
  23845. * @private
  23846. * @param {Function} func The function to restrict.
  23847. * @returns {Function} Returns the new shortable function.
  23848. */
  23849. function shortOut(func) {
  23850. var count = 0,
  23851. lastCalled = 0;
  23852. return function() {
  23853. var stamp = nativeNow(),
  23854. remaining = HOT_SPAN - (stamp - lastCalled);
  23855. lastCalled = stamp;
  23856. if (remaining > 0) {
  23857. if (++count >= HOT_COUNT) {
  23858. return arguments[0];
  23859. }
  23860. } else {
  23861. count = 0;
  23862. }
  23863. return func.apply(undefined, arguments);
  23864. };
  23865. }
  23866. /**
  23867. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  23868. *
  23869. * @private
  23870. * @param {Array} array The array to shuffle.
  23871. * @param {number} [size=array.length] The size of `array`.
  23872. * @returns {Array} Returns `array`.
  23873. */
  23874. function shuffleSelf(array, size) {
  23875. var index = -1,
  23876. length = array.length,
  23877. lastIndex = length - 1;
  23878. size = size === undefined ? length : size;
  23879. while (++index < size) {
  23880. var rand = baseRandom(index, lastIndex),
  23881. value = array[rand];
  23882. array[rand] = array[index];
  23883. array[index] = value;
  23884. }
  23885. array.length = size;
  23886. return array;
  23887. }
  23888. /**
  23889. * Converts `string` to a property path array.
  23890. *
  23891. * @private
  23892. * @param {string} string The string to convert.
  23893. * @returns {Array} Returns the property path array.
  23894. */
  23895. var stringToPath = memoizeCapped(function(string) {
  23896. var result = [];
  23897. if (string.charCodeAt(0) === 46 /* . */) {
  23898. result.push('');
  23899. }
  23900. string.replace(rePropName, function(match, number, quote, subString) {
  23901. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  23902. });
  23903. return result;
  23904. });
  23905. /**
  23906. * Converts `value` to a string key if it's not a string or symbol.
  23907. *
  23908. * @private
  23909. * @param {*} value The value to inspect.
  23910. * @returns {string|symbol} Returns the key.
  23911. */
  23912. function toKey(value) {
  23913. if (typeof value == 'string' || isSymbol(value)) {
  23914. return value;
  23915. }
  23916. var result = (value + '');
  23917. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  23918. }
  23919. /**
  23920. * Converts `func` to its source code.
  23921. *
  23922. * @private
  23923. * @param {Function} func The function to convert.
  23924. * @returns {string} Returns the source code.
  23925. */
  23926. function toSource(func) {
  23927. if (func != null) {
  23928. try {
  23929. return funcToString.call(func);
  23930. } catch (e) {}
  23931. try {
  23932. return (func + '');
  23933. } catch (e) {}
  23934. }
  23935. return '';
  23936. }
  23937. /**
  23938. * Updates wrapper `details` based on `bitmask` flags.
  23939. *
  23940. * @private
  23941. * @returns {Array} details The details to modify.
  23942. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23943. * @returns {Array} Returns `details`.
  23944. */
  23945. function updateWrapDetails(details, bitmask) {
  23946. arrayEach(wrapFlags, function(pair) {
  23947. var value = '_.' + pair[0];
  23948. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  23949. details.push(value);
  23950. }
  23951. });
  23952. return details.sort();
  23953. }
  23954. /**
  23955. * Creates a clone of `wrapper`.
  23956. *
  23957. * @private
  23958. * @param {Object} wrapper The wrapper to clone.
  23959. * @returns {Object} Returns the cloned wrapper.
  23960. */
  23961. function wrapperClone(wrapper) {
  23962. if (wrapper instanceof LazyWrapper) {
  23963. return wrapper.clone();
  23964. }
  23965. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  23966. result.__actions__ = copyArray(wrapper.__actions__);
  23967. result.__index__ = wrapper.__index__;
  23968. result.__values__ = wrapper.__values__;
  23969. return result;
  23970. }
  23971. /*------------------------------------------------------------------------*/
  23972. /**
  23973. * Creates an array of elements split into groups the length of `size`.
  23974. * If `array` can't be split evenly, the final chunk will be the remaining
  23975. * elements.
  23976. *
  23977. * @static
  23978. * @memberOf _
  23979. * @since 3.0.0
  23980. * @category Array
  23981. * @param {Array} array The array to process.
  23982. * @param {number} [size=1] The length of each chunk
  23983. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23984. * @returns {Array} Returns the new array of chunks.
  23985. * @example
  23986. *
  23987. * _.chunk(['a', 'b', 'c', 'd'], 2);
  23988. * // => [['a', 'b'], ['c', 'd']]
  23989. *
  23990. * _.chunk(['a', 'b', 'c', 'd'], 3);
  23991. * // => [['a', 'b', 'c'], ['d']]
  23992. */
  23993. function chunk(array, size, guard) {
  23994. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  23995. size = 1;
  23996. } else {
  23997. size = nativeMax(toInteger(size), 0);
  23998. }
  23999. var length = array == null ? 0 : array.length;
  24000. if (!length || size < 1) {
  24001. return [];
  24002. }
  24003. var index = 0,
  24004. resIndex = 0,
  24005. result = Array(nativeCeil(length / size));
  24006. while (index < length) {
  24007. result[resIndex++] = baseSlice(array, index, (index += size));
  24008. }
  24009. return result;
  24010. }
  24011. /**
  24012. * Creates an array with all falsey values removed. The values `false`, `null`,
  24013. * `0`, `""`, `undefined`, and `NaN` are falsey.
  24014. *
  24015. * @static
  24016. * @memberOf _
  24017. * @since 0.1.0
  24018. * @category Array
  24019. * @param {Array} array The array to compact.
  24020. * @returns {Array} Returns the new array of filtered values.
  24021. * @example
  24022. *
  24023. * _.compact([0, 1, false, 2, '', 3]);
  24024. * // => [1, 2, 3]
  24025. */
  24026. function compact(array) {
  24027. var index = -1,
  24028. length = array == null ? 0 : array.length,
  24029. resIndex = 0,
  24030. result = [];
  24031. while (++index < length) {
  24032. var value = array[index];
  24033. if (value) {
  24034. result[resIndex++] = value;
  24035. }
  24036. }
  24037. return result;
  24038. }
  24039. /**
  24040. * Creates a new array concatenating `array` with any additional arrays
  24041. * and/or values.
  24042. *
  24043. * @static
  24044. * @memberOf _
  24045. * @since 4.0.0
  24046. * @category Array
  24047. * @param {Array} array The array to concatenate.
  24048. * @param {...*} [values] The values to concatenate.
  24049. * @returns {Array} Returns the new concatenated array.
  24050. * @example
  24051. *
  24052. * var array = [1];
  24053. * var other = _.concat(array, 2, [3], [[4]]);
  24054. *
  24055. * console.log(other);
  24056. * // => [1, 2, 3, [4]]
  24057. *
  24058. * console.log(array);
  24059. * // => [1]
  24060. */
  24061. function concat() {
  24062. var length = arguments.length;
  24063. if (!length) {
  24064. return [];
  24065. }
  24066. var args = Array(length - 1),
  24067. array = arguments[0],
  24068. index = length;
  24069. while (index--) {
  24070. args[index - 1] = arguments[index];
  24071. }
  24072. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  24073. }
  24074. /**
  24075. * Creates an array of `array` values not included in the other given arrays
  24076. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24077. * for equality comparisons. The order and references of result values are
  24078. * determined by the first array.
  24079. *
  24080. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  24081. *
  24082. * @static
  24083. * @memberOf _
  24084. * @since 0.1.0
  24085. * @category Array
  24086. * @param {Array} array The array to inspect.
  24087. * @param {...Array} [values] The values to exclude.
  24088. * @returns {Array} Returns the new array of filtered values.
  24089. * @see _.without, _.xor
  24090. * @example
  24091. *
  24092. * _.difference([2, 1], [2, 3]);
  24093. * // => [1]
  24094. */
  24095. var difference = baseRest(function(array, values) {
  24096. return isArrayLikeObject(array)
  24097. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  24098. : [];
  24099. });
  24100. /**
  24101. * This method is like `_.difference` except that it accepts `iteratee` which
  24102. * is invoked for each element of `array` and `values` to generate the criterion
  24103. * by which they're compared. The order and references of result values are
  24104. * determined by the first array. The iteratee is invoked with one argument:
  24105. * (value).
  24106. *
  24107. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  24108. *
  24109. * @static
  24110. * @memberOf _
  24111. * @since 4.0.0
  24112. * @category Array
  24113. * @param {Array} array The array to inspect.
  24114. * @param {...Array} [values] The values to exclude.
  24115. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24116. * @returns {Array} Returns the new array of filtered values.
  24117. * @example
  24118. *
  24119. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24120. * // => [1.2]
  24121. *
  24122. * // The `_.property` iteratee shorthand.
  24123. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  24124. * // => [{ 'x': 2 }]
  24125. */
  24126. var differenceBy = baseRest(function(array, values) {
  24127. var iteratee = last(values);
  24128. if (isArrayLikeObject(iteratee)) {
  24129. iteratee = undefined;
  24130. }
  24131. return isArrayLikeObject(array)
  24132. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  24133. : [];
  24134. });
  24135. /**
  24136. * This method is like `_.difference` except that it accepts `comparator`
  24137. * which is invoked to compare elements of `array` to `values`. The order and
  24138. * references of result values are determined by the first array. The comparator
  24139. * is invoked with two arguments: (arrVal, othVal).
  24140. *
  24141. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  24142. *
  24143. * @static
  24144. * @memberOf _
  24145. * @since 4.0.0
  24146. * @category Array
  24147. * @param {Array} array The array to inspect.
  24148. * @param {...Array} [values] The values to exclude.
  24149. * @param {Function} [comparator] The comparator invoked per element.
  24150. * @returns {Array} Returns the new array of filtered values.
  24151. * @example
  24152. *
  24153. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24154. *
  24155. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  24156. * // => [{ 'x': 2, 'y': 1 }]
  24157. */
  24158. var differenceWith = baseRest(function(array, values) {
  24159. var comparator = last(values);
  24160. if (isArrayLikeObject(comparator)) {
  24161. comparator = undefined;
  24162. }
  24163. return isArrayLikeObject(array)
  24164. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  24165. : [];
  24166. });
  24167. /**
  24168. * Creates a slice of `array` with `n` elements dropped from the beginning.
  24169. *
  24170. * @static
  24171. * @memberOf _
  24172. * @since 0.5.0
  24173. * @category Array
  24174. * @param {Array} array The array to query.
  24175. * @param {number} [n=1] The number of elements to drop.
  24176. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24177. * @returns {Array} Returns the slice of `array`.
  24178. * @example
  24179. *
  24180. * _.drop([1, 2, 3]);
  24181. * // => [2, 3]
  24182. *
  24183. * _.drop([1, 2, 3], 2);
  24184. * // => [3]
  24185. *
  24186. * _.drop([1, 2, 3], 5);
  24187. * // => []
  24188. *
  24189. * _.drop([1, 2, 3], 0);
  24190. * // => [1, 2, 3]
  24191. */
  24192. function drop(array, n, guard) {
  24193. var length = array == null ? 0 : array.length;
  24194. if (!length) {
  24195. return [];
  24196. }
  24197. n = (guard || n === undefined) ? 1 : toInteger(n);
  24198. return baseSlice(array, n < 0 ? 0 : n, length);
  24199. }
  24200. /**
  24201. * Creates a slice of `array` with `n` elements dropped from the end.
  24202. *
  24203. * @static
  24204. * @memberOf _
  24205. * @since 3.0.0
  24206. * @category Array
  24207. * @param {Array} array The array to query.
  24208. * @param {number} [n=1] The number of elements to drop.
  24209. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24210. * @returns {Array} Returns the slice of `array`.
  24211. * @example
  24212. *
  24213. * _.dropRight([1, 2, 3]);
  24214. * // => [1, 2]
  24215. *
  24216. * _.dropRight([1, 2, 3], 2);
  24217. * // => [1]
  24218. *
  24219. * _.dropRight([1, 2, 3], 5);
  24220. * // => []
  24221. *
  24222. * _.dropRight([1, 2, 3], 0);
  24223. * // => [1, 2, 3]
  24224. */
  24225. function dropRight(array, n, guard) {
  24226. var length = array == null ? 0 : array.length;
  24227. if (!length) {
  24228. return [];
  24229. }
  24230. n = (guard || n === undefined) ? 1 : toInteger(n);
  24231. n = length - n;
  24232. return baseSlice(array, 0, n < 0 ? 0 : n);
  24233. }
  24234. /**
  24235. * Creates a slice of `array` excluding elements dropped from the end.
  24236. * Elements are dropped until `predicate` returns falsey. The predicate is
  24237. * invoked with three arguments: (value, index, array).
  24238. *
  24239. * @static
  24240. * @memberOf _
  24241. * @since 3.0.0
  24242. * @category Array
  24243. * @param {Array} array The array to query.
  24244. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24245. * @returns {Array} Returns the slice of `array`.
  24246. * @example
  24247. *
  24248. * var users = [
  24249. * { 'user': 'barney', 'active': true },
  24250. * { 'user': 'fred', 'active': false },
  24251. * { 'user': 'pebbles', 'active': false }
  24252. * ];
  24253. *
  24254. * _.dropRightWhile(users, function(o) { return !o.active; });
  24255. * // => objects for ['barney']
  24256. *
  24257. * // The `_.matches` iteratee shorthand.
  24258. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  24259. * // => objects for ['barney', 'fred']
  24260. *
  24261. * // The `_.matchesProperty` iteratee shorthand.
  24262. * _.dropRightWhile(users, ['active', false]);
  24263. * // => objects for ['barney']
  24264. *
  24265. * // The `_.property` iteratee shorthand.
  24266. * _.dropRightWhile(users, 'active');
  24267. * // => objects for ['barney', 'fred', 'pebbles']
  24268. */
  24269. function dropRightWhile(array, predicate) {
  24270. return (array && array.length)
  24271. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  24272. : [];
  24273. }
  24274. /**
  24275. * Creates a slice of `array` excluding elements dropped from the beginning.
  24276. * Elements are dropped until `predicate` returns falsey. The predicate is
  24277. * invoked with three arguments: (value, index, array).
  24278. *
  24279. * @static
  24280. * @memberOf _
  24281. * @since 3.0.0
  24282. * @category Array
  24283. * @param {Array} array The array to query.
  24284. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24285. * @returns {Array} Returns the slice of `array`.
  24286. * @example
  24287. *
  24288. * var users = [
  24289. * { 'user': 'barney', 'active': false },
  24290. * { 'user': 'fred', 'active': false },
  24291. * { 'user': 'pebbles', 'active': true }
  24292. * ];
  24293. *
  24294. * _.dropWhile(users, function(o) { return !o.active; });
  24295. * // => objects for ['pebbles']
  24296. *
  24297. * // The `_.matches` iteratee shorthand.
  24298. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  24299. * // => objects for ['fred', 'pebbles']
  24300. *
  24301. * // The `_.matchesProperty` iteratee shorthand.
  24302. * _.dropWhile(users, ['active', false]);
  24303. * // => objects for ['pebbles']
  24304. *
  24305. * // The `_.property` iteratee shorthand.
  24306. * _.dropWhile(users, 'active');
  24307. * // => objects for ['barney', 'fred', 'pebbles']
  24308. */
  24309. function dropWhile(array, predicate) {
  24310. return (array && array.length)
  24311. ? baseWhile(array, getIteratee(predicate, 3), true)
  24312. : [];
  24313. }
  24314. /**
  24315. * Fills elements of `array` with `value` from `start` up to, but not
  24316. * including, `end`.
  24317. *
  24318. * **Note:** This method mutates `array`.
  24319. *
  24320. * @static
  24321. * @memberOf _
  24322. * @since 3.2.0
  24323. * @category Array
  24324. * @param {Array} array The array to fill.
  24325. * @param {*} value The value to fill `array` with.
  24326. * @param {number} [start=0] The start position.
  24327. * @param {number} [end=array.length] The end position.
  24328. * @returns {Array} Returns `array`.
  24329. * @example
  24330. *
  24331. * var array = [1, 2, 3];
  24332. *
  24333. * _.fill(array, 'a');
  24334. * console.log(array);
  24335. * // => ['a', 'a', 'a']
  24336. *
  24337. * _.fill(Array(3), 2);
  24338. * // => [2, 2, 2]
  24339. *
  24340. * _.fill([4, 6, 8, 10], '*', 1, 3);
  24341. * // => [4, '*', '*', 10]
  24342. */
  24343. function fill(array, value, start, end) {
  24344. var length = array == null ? 0 : array.length;
  24345. if (!length) {
  24346. return [];
  24347. }
  24348. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  24349. start = 0;
  24350. end = length;
  24351. }
  24352. return baseFill(array, value, start, end);
  24353. }
  24354. /**
  24355. * This method is like `_.find` except that it returns the index of the first
  24356. * element `predicate` returns truthy for instead of the element itself.
  24357. *
  24358. * @static
  24359. * @memberOf _
  24360. * @since 1.1.0
  24361. * @category Array
  24362. * @param {Array} array The array to inspect.
  24363. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24364. * @param {number} [fromIndex=0] The index to search from.
  24365. * @returns {number} Returns the index of the found element, else `-1`.
  24366. * @example
  24367. *
  24368. * var users = [
  24369. * { 'user': 'barney', 'active': false },
  24370. * { 'user': 'fred', 'active': false },
  24371. * { 'user': 'pebbles', 'active': true }
  24372. * ];
  24373. *
  24374. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  24375. * // => 0
  24376. *
  24377. * // The `_.matches` iteratee shorthand.
  24378. * _.findIndex(users, { 'user': 'fred', 'active': false });
  24379. * // => 1
  24380. *
  24381. * // The `_.matchesProperty` iteratee shorthand.
  24382. * _.findIndex(users, ['active', false]);
  24383. * // => 0
  24384. *
  24385. * // The `_.property` iteratee shorthand.
  24386. * _.findIndex(users, 'active');
  24387. * // => 2
  24388. */
  24389. function findIndex(array, predicate, fromIndex) {
  24390. var length = array == null ? 0 : array.length;
  24391. if (!length) {
  24392. return -1;
  24393. }
  24394. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24395. if (index < 0) {
  24396. index = nativeMax(length + index, 0);
  24397. }
  24398. return baseFindIndex(array, getIteratee(predicate, 3), index);
  24399. }
  24400. /**
  24401. * This method is like `_.findIndex` except that it iterates over elements
  24402. * of `collection` from right to left.
  24403. *
  24404. * @static
  24405. * @memberOf _
  24406. * @since 2.0.0
  24407. * @category Array
  24408. * @param {Array} array The array to inspect.
  24409. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24410. * @param {number} [fromIndex=array.length-1] The index to search from.
  24411. * @returns {number} Returns the index of the found element, else `-1`.
  24412. * @example
  24413. *
  24414. * var users = [
  24415. * { 'user': 'barney', 'active': true },
  24416. * { 'user': 'fred', 'active': false },
  24417. * { 'user': 'pebbles', 'active': false }
  24418. * ];
  24419. *
  24420. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  24421. * // => 2
  24422. *
  24423. * // The `_.matches` iteratee shorthand.
  24424. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  24425. * // => 0
  24426. *
  24427. * // The `_.matchesProperty` iteratee shorthand.
  24428. * _.findLastIndex(users, ['active', false]);
  24429. * // => 2
  24430. *
  24431. * // The `_.property` iteratee shorthand.
  24432. * _.findLastIndex(users, 'active');
  24433. * // => 0
  24434. */
  24435. function findLastIndex(array, predicate, fromIndex) {
  24436. var length = array == null ? 0 : array.length;
  24437. if (!length) {
  24438. return -1;
  24439. }
  24440. var index = length - 1;
  24441. if (fromIndex !== undefined) {
  24442. index = toInteger(fromIndex);
  24443. index = fromIndex < 0
  24444. ? nativeMax(length + index, 0)
  24445. : nativeMin(index, length - 1);
  24446. }
  24447. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  24448. }
  24449. /**
  24450. * Flattens `array` a single level deep.
  24451. *
  24452. * @static
  24453. * @memberOf _
  24454. * @since 0.1.0
  24455. * @category Array
  24456. * @param {Array} array The array to flatten.
  24457. * @returns {Array} Returns the new flattened array.
  24458. * @example
  24459. *
  24460. * _.flatten([1, [2, [3, [4]], 5]]);
  24461. * // => [1, 2, [3, [4]], 5]
  24462. */
  24463. function flatten(array) {
  24464. var length = array == null ? 0 : array.length;
  24465. return length ? baseFlatten(array, 1) : [];
  24466. }
  24467. /**
  24468. * Recursively flattens `array`.
  24469. *
  24470. * @static
  24471. * @memberOf _
  24472. * @since 3.0.0
  24473. * @category Array
  24474. * @param {Array} array The array to flatten.
  24475. * @returns {Array} Returns the new flattened array.
  24476. * @example
  24477. *
  24478. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  24479. * // => [1, 2, 3, 4, 5]
  24480. */
  24481. function flattenDeep(array) {
  24482. var length = array == null ? 0 : array.length;
  24483. return length ? baseFlatten(array, INFINITY) : [];
  24484. }
  24485. /**
  24486. * Recursively flatten `array` up to `depth` times.
  24487. *
  24488. * @static
  24489. * @memberOf _
  24490. * @since 4.4.0
  24491. * @category Array
  24492. * @param {Array} array The array to flatten.
  24493. * @param {number} [depth=1] The maximum recursion depth.
  24494. * @returns {Array} Returns the new flattened array.
  24495. * @example
  24496. *
  24497. * var array = [1, [2, [3, [4]], 5]];
  24498. *
  24499. * _.flattenDepth(array, 1);
  24500. * // => [1, 2, [3, [4]], 5]
  24501. *
  24502. * _.flattenDepth(array, 2);
  24503. * // => [1, 2, 3, [4], 5]
  24504. */
  24505. function flattenDepth(array, depth) {
  24506. var length = array == null ? 0 : array.length;
  24507. if (!length) {
  24508. return [];
  24509. }
  24510. depth = depth === undefined ? 1 : toInteger(depth);
  24511. return baseFlatten(array, depth);
  24512. }
  24513. /**
  24514. * The inverse of `_.toPairs`; this method returns an object composed
  24515. * from key-value `pairs`.
  24516. *
  24517. * @static
  24518. * @memberOf _
  24519. * @since 4.0.0
  24520. * @category Array
  24521. * @param {Array} pairs The key-value pairs.
  24522. * @returns {Object} Returns the new object.
  24523. * @example
  24524. *
  24525. * _.fromPairs([['a', 1], ['b', 2]]);
  24526. * // => { 'a': 1, 'b': 2 }
  24527. */
  24528. function fromPairs(pairs) {
  24529. var index = -1,
  24530. length = pairs == null ? 0 : pairs.length,
  24531. result = {};
  24532. while (++index < length) {
  24533. var pair = pairs[index];
  24534. result[pair[0]] = pair[1];
  24535. }
  24536. return result;
  24537. }
  24538. /**
  24539. * Gets the first element of `array`.
  24540. *
  24541. * @static
  24542. * @memberOf _
  24543. * @since 0.1.0
  24544. * @alias first
  24545. * @category Array
  24546. * @param {Array} array The array to query.
  24547. * @returns {*} Returns the first element of `array`.
  24548. * @example
  24549. *
  24550. * _.head([1, 2, 3]);
  24551. * // => 1
  24552. *
  24553. * _.head([]);
  24554. * // => undefined
  24555. */
  24556. function head(array) {
  24557. return (array && array.length) ? array[0] : undefined;
  24558. }
  24559. /**
  24560. * Gets the index at which the first occurrence of `value` is found in `array`
  24561. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24562. * for equality comparisons. If `fromIndex` is negative, it's used as the
  24563. * offset from the end of `array`.
  24564. *
  24565. * @static
  24566. * @memberOf _
  24567. * @since 0.1.0
  24568. * @category Array
  24569. * @param {Array} array The array to inspect.
  24570. * @param {*} value The value to search for.
  24571. * @param {number} [fromIndex=0] The index to search from.
  24572. * @returns {number} Returns the index of the matched value, else `-1`.
  24573. * @example
  24574. *
  24575. * _.indexOf([1, 2, 1, 2], 2);
  24576. * // => 1
  24577. *
  24578. * // Search from the `fromIndex`.
  24579. * _.indexOf([1, 2, 1, 2], 2, 2);
  24580. * // => 3
  24581. */
  24582. function indexOf(array, value, fromIndex) {
  24583. var length = array == null ? 0 : array.length;
  24584. if (!length) {
  24585. return -1;
  24586. }
  24587. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24588. if (index < 0) {
  24589. index = nativeMax(length + index, 0);
  24590. }
  24591. return baseIndexOf(array, value, index);
  24592. }
  24593. /**
  24594. * Gets all but the last element of `array`.
  24595. *
  24596. * @static
  24597. * @memberOf _
  24598. * @since 0.1.0
  24599. * @category Array
  24600. * @param {Array} array The array to query.
  24601. * @returns {Array} Returns the slice of `array`.
  24602. * @example
  24603. *
  24604. * _.initial([1, 2, 3]);
  24605. * // => [1, 2]
  24606. */
  24607. function initial(array) {
  24608. var length = array == null ? 0 : array.length;
  24609. return length ? baseSlice(array, 0, -1) : [];
  24610. }
  24611. /**
  24612. * Creates an array of unique values that are included in all given arrays
  24613. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24614. * for equality comparisons. The order and references of result values are
  24615. * determined by the first array.
  24616. *
  24617. * @static
  24618. * @memberOf _
  24619. * @since 0.1.0
  24620. * @category Array
  24621. * @param {...Array} [arrays] The arrays to inspect.
  24622. * @returns {Array} Returns the new array of intersecting values.
  24623. * @example
  24624. *
  24625. * _.intersection([2, 1], [2, 3]);
  24626. * // => [2]
  24627. */
  24628. var intersection = baseRest(function(arrays) {
  24629. var mapped = arrayMap(arrays, castArrayLikeObject);
  24630. return (mapped.length && mapped[0] === arrays[0])
  24631. ? baseIntersection(mapped)
  24632. : [];
  24633. });
  24634. /**
  24635. * This method is like `_.intersection` except that it accepts `iteratee`
  24636. * which is invoked for each element of each `arrays` to generate the criterion
  24637. * by which they're compared. The order and references of result values are
  24638. * determined by the first array. The iteratee is invoked with one argument:
  24639. * (value).
  24640. *
  24641. * @static
  24642. * @memberOf _
  24643. * @since 4.0.0
  24644. * @category Array
  24645. * @param {...Array} [arrays] The arrays to inspect.
  24646. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24647. * @returns {Array} Returns the new array of intersecting values.
  24648. * @example
  24649. *
  24650. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24651. * // => [2.1]
  24652. *
  24653. * // The `_.property` iteratee shorthand.
  24654. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24655. * // => [{ 'x': 1 }]
  24656. */
  24657. var intersectionBy = baseRest(function(arrays) {
  24658. var iteratee = last(arrays),
  24659. mapped = arrayMap(arrays, castArrayLikeObject);
  24660. if (iteratee === last(mapped)) {
  24661. iteratee = undefined;
  24662. } else {
  24663. mapped.pop();
  24664. }
  24665. return (mapped.length && mapped[0] === arrays[0])
  24666. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  24667. : [];
  24668. });
  24669. /**
  24670. * This method is like `_.intersection` except that it accepts `comparator`
  24671. * which is invoked to compare elements of `arrays`. The order and references
  24672. * of result values are determined by the first array. The comparator is
  24673. * invoked with two arguments: (arrVal, othVal).
  24674. *
  24675. * @static
  24676. * @memberOf _
  24677. * @since 4.0.0
  24678. * @category Array
  24679. * @param {...Array} [arrays] The arrays to inspect.
  24680. * @param {Function} [comparator] The comparator invoked per element.
  24681. * @returns {Array} Returns the new array of intersecting values.
  24682. * @example
  24683. *
  24684. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24685. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24686. *
  24687. * _.intersectionWith(objects, others, _.isEqual);
  24688. * // => [{ 'x': 1, 'y': 2 }]
  24689. */
  24690. var intersectionWith = baseRest(function(arrays) {
  24691. var comparator = last(arrays),
  24692. mapped = arrayMap(arrays, castArrayLikeObject);
  24693. comparator = typeof comparator == 'function' ? comparator : undefined;
  24694. if (comparator) {
  24695. mapped.pop();
  24696. }
  24697. return (mapped.length && mapped[0] === arrays[0])
  24698. ? baseIntersection(mapped, undefined, comparator)
  24699. : [];
  24700. });
  24701. /**
  24702. * Converts all elements in `array` into a string separated by `separator`.
  24703. *
  24704. * @static
  24705. * @memberOf _
  24706. * @since 4.0.0
  24707. * @category Array
  24708. * @param {Array} array The array to convert.
  24709. * @param {string} [separator=','] The element separator.
  24710. * @returns {string} Returns the joined string.
  24711. * @example
  24712. *
  24713. * _.join(['a', 'b', 'c'], '~');
  24714. * // => 'a~b~c'
  24715. */
  24716. function join(array, separator) {
  24717. return array == null ? '' : nativeJoin.call(array, separator);
  24718. }
  24719. /**
  24720. * Gets the last element of `array`.
  24721. *
  24722. * @static
  24723. * @memberOf _
  24724. * @since 0.1.0
  24725. * @category Array
  24726. * @param {Array} array The array to query.
  24727. * @returns {*} Returns the last element of `array`.
  24728. * @example
  24729. *
  24730. * _.last([1, 2, 3]);
  24731. * // => 3
  24732. */
  24733. function last(array) {
  24734. var length = array == null ? 0 : array.length;
  24735. return length ? array[length - 1] : undefined;
  24736. }
  24737. /**
  24738. * This method is like `_.indexOf` except that it iterates over elements of
  24739. * `array` from right to left.
  24740. *
  24741. * @static
  24742. * @memberOf _
  24743. * @since 0.1.0
  24744. * @category Array
  24745. * @param {Array} array The array to inspect.
  24746. * @param {*} value The value to search for.
  24747. * @param {number} [fromIndex=array.length-1] The index to search from.
  24748. * @returns {number} Returns the index of the matched value, else `-1`.
  24749. * @example
  24750. *
  24751. * _.lastIndexOf([1, 2, 1, 2], 2);
  24752. * // => 3
  24753. *
  24754. * // Search from the `fromIndex`.
  24755. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  24756. * // => 1
  24757. */
  24758. function lastIndexOf(array, value, fromIndex) {
  24759. var length = array == null ? 0 : array.length;
  24760. if (!length) {
  24761. return -1;
  24762. }
  24763. var index = length;
  24764. if (fromIndex !== undefined) {
  24765. index = toInteger(fromIndex);
  24766. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  24767. }
  24768. return value === value
  24769. ? strictLastIndexOf(array, value, index)
  24770. : baseFindIndex(array, baseIsNaN, index, true);
  24771. }
  24772. /**
  24773. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  24774. * element from the end is returned.
  24775. *
  24776. * @static
  24777. * @memberOf _
  24778. * @since 4.11.0
  24779. * @category Array
  24780. * @param {Array} array The array to query.
  24781. * @param {number} [n=0] The index of the element to return.
  24782. * @returns {*} Returns the nth element of `array`.
  24783. * @example
  24784. *
  24785. * var array = ['a', 'b', 'c', 'd'];
  24786. *
  24787. * _.nth(array, 1);
  24788. * // => 'b'
  24789. *
  24790. * _.nth(array, -2);
  24791. * // => 'c';
  24792. */
  24793. function nth(array, n) {
  24794. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  24795. }
  24796. /**
  24797. * Removes all given values from `array` using
  24798. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24799. * for equality comparisons.
  24800. *
  24801. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  24802. * to remove elements from an array by predicate.
  24803. *
  24804. * @static
  24805. * @memberOf _
  24806. * @since 2.0.0
  24807. * @category Array
  24808. * @param {Array} array The array to modify.
  24809. * @param {...*} [values] The values to remove.
  24810. * @returns {Array} Returns `array`.
  24811. * @example
  24812. *
  24813. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24814. *
  24815. * _.pull(array, 'a', 'c');
  24816. * console.log(array);
  24817. * // => ['b', 'b']
  24818. */
  24819. var pull = baseRest(pullAll);
  24820. /**
  24821. * This method is like `_.pull` except that it accepts an array of values to remove.
  24822. *
  24823. * **Note:** Unlike `_.difference`, this method mutates `array`.
  24824. *
  24825. * @static
  24826. * @memberOf _
  24827. * @since 4.0.0
  24828. * @category Array
  24829. * @param {Array} array The array to modify.
  24830. * @param {Array} values The values to remove.
  24831. * @returns {Array} Returns `array`.
  24832. * @example
  24833. *
  24834. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24835. *
  24836. * _.pullAll(array, ['a', 'c']);
  24837. * console.log(array);
  24838. * // => ['b', 'b']
  24839. */
  24840. function pullAll(array, values) {
  24841. return (array && array.length && values && values.length)
  24842. ? basePullAll(array, values)
  24843. : array;
  24844. }
  24845. /**
  24846. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  24847. * invoked for each element of `array` and `values` to generate the criterion
  24848. * by which they're compared. The iteratee is invoked with one argument: (value).
  24849. *
  24850. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  24851. *
  24852. * @static
  24853. * @memberOf _
  24854. * @since 4.0.0
  24855. * @category Array
  24856. * @param {Array} array The array to modify.
  24857. * @param {Array} values The values to remove.
  24858. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24859. * @returns {Array} Returns `array`.
  24860. * @example
  24861. *
  24862. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  24863. *
  24864. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  24865. * console.log(array);
  24866. * // => [{ 'x': 2 }]
  24867. */
  24868. function pullAllBy(array, values, iteratee) {
  24869. return (array && array.length && values && values.length)
  24870. ? basePullAll(array, values, getIteratee(iteratee, 2))
  24871. : array;
  24872. }
  24873. /**
  24874. * This method is like `_.pullAll` except that it accepts `comparator` which
  24875. * is invoked to compare elements of `array` to `values`. The comparator is
  24876. * invoked with two arguments: (arrVal, othVal).
  24877. *
  24878. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  24879. *
  24880. * @static
  24881. * @memberOf _
  24882. * @since 4.6.0
  24883. * @category Array
  24884. * @param {Array} array The array to modify.
  24885. * @param {Array} values The values to remove.
  24886. * @param {Function} [comparator] The comparator invoked per element.
  24887. * @returns {Array} Returns `array`.
  24888. * @example
  24889. *
  24890. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  24891. *
  24892. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  24893. * console.log(array);
  24894. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  24895. */
  24896. function pullAllWith(array, values, comparator) {
  24897. return (array && array.length && values && values.length)
  24898. ? basePullAll(array, values, undefined, comparator)
  24899. : array;
  24900. }
  24901. /**
  24902. * Removes elements from `array` corresponding to `indexes` and returns an
  24903. * array of removed elements.
  24904. *
  24905. * **Note:** Unlike `_.at`, this method mutates `array`.
  24906. *
  24907. * @static
  24908. * @memberOf _
  24909. * @since 3.0.0
  24910. * @category Array
  24911. * @param {Array} array The array to modify.
  24912. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  24913. * @returns {Array} Returns the new array of removed elements.
  24914. * @example
  24915. *
  24916. * var array = ['a', 'b', 'c', 'd'];
  24917. * var pulled = _.pullAt(array, [1, 3]);
  24918. *
  24919. * console.log(array);
  24920. * // => ['a', 'c']
  24921. *
  24922. * console.log(pulled);
  24923. * // => ['b', 'd']
  24924. */
  24925. var pullAt = flatRest(function(array, indexes) {
  24926. var length = array == null ? 0 : array.length,
  24927. result = baseAt(array, indexes);
  24928. basePullAt(array, arrayMap(indexes, function(index) {
  24929. return isIndex(index, length) ? +index : index;
  24930. }).sort(compareAscending));
  24931. return result;
  24932. });
  24933. /**
  24934. * Removes all elements from `array` that `predicate` returns truthy for
  24935. * and returns an array of the removed elements. The predicate is invoked
  24936. * with three arguments: (value, index, array).
  24937. *
  24938. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  24939. * to pull elements from an array by value.
  24940. *
  24941. * @static
  24942. * @memberOf _
  24943. * @since 2.0.0
  24944. * @category Array
  24945. * @param {Array} array The array to modify.
  24946. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24947. * @returns {Array} Returns the new array of removed elements.
  24948. * @example
  24949. *
  24950. * var array = [1, 2, 3, 4];
  24951. * var evens = _.remove(array, function(n) {
  24952. * return n % 2 == 0;
  24953. * });
  24954. *
  24955. * console.log(array);
  24956. * // => [1, 3]
  24957. *
  24958. * console.log(evens);
  24959. * // => [2, 4]
  24960. */
  24961. function remove(array, predicate) {
  24962. var result = [];
  24963. if (!(array && array.length)) {
  24964. return result;
  24965. }
  24966. var index = -1,
  24967. indexes = [],
  24968. length = array.length;
  24969. predicate = getIteratee(predicate, 3);
  24970. while (++index < length) {
  24971. var value = array[index];
  24972. if (predicate(value, index, array)) {
  24973. result.push(value);
  24974. indexes.push(index);
  24975. }
  24976. }
  24977. basePullAt(array, indexes);
  24978. return result;
  24979. }
  24980. /**
  24981. * Reverses `array` so that the first element becomes the last, the second
  24982. * element becomes the second to last, and so on.
  24983. *
  24984. * **Note:** This method mutates `array` and is based on
  24985. * [`Array#reverse`](https://mdn.io/Array/reverse).
  24986. *
  24987. * @static
  24988. * @memberOf _
  24989. * @since 4.0.0
  24990. * @category Array
  24991. * @param {Array} array The array to modify.
  24992. * @returns {Array} Returns `array`.
  24993. * @example
  24994. *
  24995. * var array = [1, 2, 3];
  24996. *
  24997. * _.reverse(array);
  24998. * // => [3, 2, 1]
  24999. *
  25000. * console.log(array);
  25001. * // => [3, 2, 1]
  25002. */
  25003. function reverse(array) {
  25004. return array == null ? array : nativeReverse.call(array);
  25005. }
  25006. /**
  25007. * Creates a slice of `array` from `start` up to, but not including, `end`.
  25008. *
  25009. * **Note:** This method is used instead of
  25010. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  25011. * returned.
  25012. *
  25013. * @static
  25014. * @memberOf _
  25015. * @since 3.0.0
  25016. * @category Array
  25017. * @param {Array} array The array to slice.
  25018. * @param {number} [start=0] The start position.
  25019. * @param {number} [end=array.length] The end position.
  25020. * @returns {Array} Returns the slice of `array`.
  25021. */
  25022. function slice(array, start, end) {
  25023. var length = array == null ? 0 : array.length;
  25024. if (!length) {
  25025. return [];
  25026. }
  25027. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  25028. start = 0;
  25029. end = length;
  25030. }
  25031. else {
  25032. start = start == null ? 0 : toInteger(start);
  25033. end = end === undefined ? length : toInteger(end);
  25034. }
  25035. return baseSlice(array, start, end);
  25036. }
  25037. /**
  25038. * Uses a binary search to determine the lowest index at which `value`
  25039. * should be inserted into `array` in order to maintain its sort order.
  25040. *
  25041. * @static
  25042. * @memberOf _
  25043. * @since 0.1.0
  25044. * @category Array
  25045. * @param {Array} array The sorted array to inspect.
  25046. * @param {*} value The value to evaluate.
  25047. * @returns {number} Returns the index at which `value` should be inserted
  25048. * into `array`.
  25049. * @example
  25050. *
  25051. * _.sortedIndex([30, 50], 40);
  25052. * // => 1
  25053. */
  25054. function sortedIndex(array, value) {
  25055. return baseSortedIndex(array, value);
  25056. }
  25057. /**
  25058. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  25059. * which is invoked for `value` and each element of `array` to compute their
  25060. * sort ranking. The iteratee is invoked with one argument: (value).
  25061. *
  25062. * @static
  25063. * @memberOf _
  25064. * @since 4.0.0
  25065. * @category Array
  25066. * @param {Array} array The sorted array to inspect.
  25067. * @param {*} value The value to evaluate.
  25068. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25069. * @returns {number} Returns the index at which `value` should be inserted
  25070. * into `array`.
  25071. * @example
  25072. *
  25073. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25074. *
  25075. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25076. * // => 0
  25077. *
  25078. * // The `_.property` iteratee shorthand.
  25079. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  25080. * // => 0
  25081. */
  25082. function sortedIndexBy(array, value, iteratee) {
  25083. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  25084. }
  25085. /**
  25086. * This method is like `_.indexOf` except that it performs a binary
  25087. * search on a sorted `array`.
  25088. *
  25089. * @static
  25090. * @memberOf _
  25091. * @since 4.0.0
  25092. * @category Array
  25093. * @param {Array} array The array to inspect.
  25094. * @param {*} value The value to search for.
  25095. * @returns {number} Returns the index of the matched value, else `-1`.
  25096. * @example
  25097. *
  25098. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  25099. * // => 1
  25100. */
  25101. function sortedIndexOf(array, value) {
  25102. var length = array == null ? 0 : array.length;
  25103. if (length) {
  25104. var index = baseSortedIndex(array, value);
  25105. if (index < length && eq(array[index], value)) {
  25106. return index;
  25107. }
  25108. }
  25109. return -1;
  25110. }
  25111. /**
  25112. * This method is like `_.sortedIndex` except that it returns the highest
  25113. * index at which `value` should be inserted into `array` in order to
  25114. * maintain its sort order.
  25115. *
  25116. * @static
  25117. * @memberOf _
  25118. * @since 3.0.0
  25119. * @category Array
  25120. * @param {Array} array The sorted array to inspect.
  25121. * @param {*} value The value to evaluate.
  25122. * @returns {number} Returns the index at which `value` should be inserted
  25123. * into `array`.
  25124. * @example
  25125. *
  25126. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  25127. * // => 4
  25128. */
  25129. function sortedLastIndex(array, value) {
  25130. return baseSortedIndex(array, value, true);
  25131. }
  25132. /**
  25133. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  25134. * which is invoked for `value` and each element of `array` to compute their
  25135. * sort ranking. The iteratee is invoked with one argument: (value).
  25136. *
  25137. * @static
  25138. * @memberOf _
  25139. * @since 4.0.0
  25140. * @category Array
  25141. * @param {Array} array The sorted array to inspect.
  25142. * @param {*} value The value to evaluate.
  25143. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25144. * @returns {number} Returns the index at which `value` should be inserted
  25145. * into `array`.
  25146. * @example
  25147. *
  25148. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25149. *
  25150. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25151. * // => 1
  25152. *
  25153. * // The `_.property` iteratee shorthand.
  25154. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  25155. * // => 1
  25156. */
  25157. function sortedLastIndexBy(array, value, iteratee) {
  25158. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  25159. }
  25160. /**
  25161. * This method is like `_.lastIndexOf` except that it performs a binary
  25162. * search on a sorted `array`.
  25163. *
  25164. * @static
  25165. * @memberOf _
  25166. * @since 4.0.0
  25167. * @category Array
  25168. * @param {Array} array The array to inspect.
  25169. * @param {*} value The value to search for.
  25170. * @returns {number} Returns the index of the matched value, else `-1`.
  25171. * @example
  25172. *
  25173. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  25174. * // => 3
  25175. */
  25176. function sortedLastIndexOf(array, value) {
  25177. var length = array == null ? 0 : array.length;
  25178. if (length) {
  25179. var index = baseSortedIndex(array, value, true) - 1;
  25180. if (eq(array[index], value)) {
  25181. return index;
  25182. }
  25183. }
  25184. return -1;
  25185. }
  25186. /**
  25187. * This method is like `_.uniq` except that it's designed and optimized
  25188. * for sorted arrays.
  25189. *
  25190. * @static
  25191. * @memberOf _
  25192. * @since 4.0.0
  25193. * @category Array
  25194. * @param {Array} array The array to inspect.
  25195. * @returns {Array} Returns the new duplicate free array.
  25196. * @example
  25197. *
  25198. * _.sortedUniq([1, 1, 2]);
  25199. * // => [1, 2]
  25200. */
  25201. function sortedUniq(array) {
  25202. return (array && array.length)
  25203. ? baseSortedUniq(array)
  25204. : [];
  25205. }
  25206. /**
  25207. * This method is like `_.uniqBy` except that it's designed and optimized
  25208. * for sorted arrays.
  25209. *
  25210. * @static
  25211. * @memberOf _
  25212. * @since 4.0.0
  25213. * @category Array
  25214. * @param {Array} array The array to inspect.
  25215. * @param {Function} [iteratee] The iteratee invoked per element.
  25216. * @returns {Array} Returns the new duplicate free array.
  25217. * @example
  25218. *
  25219. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  25220. * // => [1.1, 2.3]
  25221. */
  25222. function sortedUniqBy(array, iteratee) {
  25223. return (array && array.length)
  25224. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  25225. : [];
  25226. }
  25227. /**
  25228. * Gets all but the first element of `array`.
  25229. *
  25230. * @static
  25231. * @memberOf _
  25232. * @since 4.0.0
  25233. * @category Array
  25234. * @param {Array} array The array to query.
  25235. * @returns {Array} Returns the slice of `array`.
  25236. * @example
  25237. *
  25238. * _.tail([1, 2, 3]);
  25239. * // => [2, 3]
  25240. */
  25241. function tail(array) {
  25242. var length = array == null ? 0 : array.length;
  25243. return length ? baseSlice(array, 1, length) : [];
  25244. }
  25245. /**
  25246. * Creates a slice of `array` with `n` elements taken from the beginning.
  25247. *
  25248. * @static
  25249. * @memberOf _
  25250. * @since 0.1.0
  25251. * @category Array
  25252. * @param {Array} array The array to query.
  25253. * @param {number} [n=1] The number of elements to take.
  25254. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25255. * @returns {Array} Returns the slice of `array`.
  25256. * @example
  25257. *
  25258. * _.take([1, 2, 3]);
  25259. * // => [1]
  25260. *
  25261. * _.take([1, 2, 3], 2);
  25262. * // => [1, 2]
  25263. *
  25264. * _.take([1, 2, 3], 5);
  25265. * // => [1, 2, 3]
  25266. *
  25267. * _.take([1, 2, 3], 0);
  25268. * // => []
  25269. */
  25270. function take(array, n, guard) {
  25271. if (!(array && array.length)) {
  25272. return [];
  25273. }
  25274. n = (guard || n === undefined) ? 1 : toInteger(n);
  25275. return baseSlice(array, 0, n < 0 ? 0 : n);
  25276. }
  25277. /**
  25278. * Creates a slice of `array` with `n` elements taken from the end.
  25279. *
  25280. * @static
  25281. * @memberOf _
  25282. * @since 3.0.0
  25283. * @category Array
  25284. * @param {Array} array The array to query.
  25285. * @param {number} [n=1] The number of elements to take.
  25286. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25287. * @returns {Array} Returns the slice of `array`.
  25288. * @example
  25289. *
  25290. * _.takeRight([1, 2, 3]);
  25291. * // => [3]
  25292. *
  25293. * _.takeRight([1, 2, 3], 2);
  25294. * // => [2, 3]
  25295. *
  25296. * _.takeRight([1, 2, 3], 5);
  25297. * // => [1, 2, 3]
  25298. *
  25299. * _.takeRight([1, 2, 3], 0);
  25300. * // => []
  25301. */
  25302. function takeRight(array, n, guard) {
  25303. var length = array == null ? 0 : array.length;
  25304. if (!length) {
  25305. return [];
  25306. }
  25307. n = (guard || n === undefined) ? 1 : toInteger(n);
  25308. n = length - n;
  25309. return baseSlice(array, n < 0 ? 0 : n, length);
  25310. }
  25311. /**
  25312. * Creates a slice of `array` with elements taken from the end. Elements are
  25313. * taken until `predicate` returns falsey. The predicate is invoked with
  25314. * three arguments: (value, index, array).
  25315. *
  25316. * @static
  25317. * @memberOf _
  25318. * @since 3.0.0
  25319. * @category Array
  25320. * @param {Array} array The array to query.
  25321. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25322. * @returns {Array} Returns the slice of `array`.
  25323. * @example
  25324. *
  25325. * var users = [
  25326. * { 'user': 'barney', 'active': true },
  25327. * { 'user': 'fred', 'active': false },
  25328. * { 'user': 'pebbles', 'active': false }
  25329. * ];
  25330. *
  25331. * _.takeRightWhile(users, function(o) { return !o.active; });
  25332. * // => objects for ['fred', 'pebbles']
  25333. *
  25334. * // The `_.matches` iteratee shorthand.
  25335. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  25336. * // => objects for ['pebbles']
  25337. *
  25338. * // The `_.matchesProperty` iteratee shorthand.
  25339. * _.takeRightWhile(users, ['active', false]);
  25340. * // => objects for ['fred', 'pebbles']
  25341. *
  25342. * // The `_.property` iteratee shorthand.
  25343. * _.takeRightWhile(users, 'active');
  25344. * // => []
  25345. */
  25346. function takeRightWhile(array, predicate) {
  25347. return (array && array.length)
  25348. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  25349. : [];
  25350. }
  25351. /**
  25352. * Creates a slice of `array` with elements taken from the beginning. Elements
  25353. * are taken until `predicate` returns falsey. The predicate is invoked with
  25354. * three arguments: (value, index, array).
  25355. *
  25356. * @static
  25357. * @memberOf _
  25358. * @since 3.0.0
  25359. * @category Array
  25360. * @param {Array} array The array to query.
  25361. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25362. * @returns {Array} Returns the slice of `array`.
  25363. * @example
  25364. *
  25365. * var users = [
  25366. * { 'user': 'barney', 'active': false },
  25367. * { 'user': 'fred', 'active': false },
  25368. * { 'user': 'pebbles', 'active': true }
  25369. * ];
  25370. *
  25371. * _.takeWhile(users, function(o) { return !o.active; });
  25372. * // => objects for ['barney', 'fred']
  25373. *
  25374. * // The `_.matches` iteratee shorthand.
  25375. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  25376. * // => objects for ['barney']
  25377. *
  25378. * // The `_.matchesProperty` iteratee shorthand.
  25379. * _.takeWhile(users, ['active', false]);
  25380. * // => objects for ['barney', 'fred']
  25381. *
  25382. * // The `_.property` iteratee shorthand.
  25383. * _.takeWhile(users, 'active');
  25384. * // => []
  25385. */
  25386. function takeWhile(array, predicate) {
  25387. return (array && array.length)
  25388. ? baseWhile(array, getIteratee(predicate, 3))
  25389. : [];
  25390. }
  25391. /**
  25392. * Creates an array of unique values, in order, from all given arrays using
  25393. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25394. * for equality comparisons.
  25395. *
  25396. * @static
  25397. * @memberOf _
  25398. * @since 0.1.0
  25399. * @category Array
  25400. * @param {...Array} [arrays] The arrays to inspect.
  25401. * @returns {Array} Returns the new array of combined values.
  25402. * @example
  25403. *
  25404. * _.union([2], [1, 2]);
  25405. * // => [2, 1]
  25406. */
  25407. var union = baseRest(function(arrays) {
  25408. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  25409. });
  25410. /**
  25411. * This method is like `_.union` except that it accepts `iteratee` which is
  25412. * invoked for each element of each `arrays` to generate the criterion by
  25413. * which uniqueness is computed. Result values are chosen from the first
  25414. * array in which the value occurs. The iteratee is invoked with one argument:
  25415. * (value).
  25416. *
  25417. * @static
  25418. * @memberOf _
  25419. * @since 4.0.0
  25420. * @category Array
  25421. * @param {...Array} [arrays] The arrays to inspect.
  25422. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25423. * @returns {Array} Returns the new array of combined values.
  25424. * @example
  25425. *
  25426. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  25427. * // => [2.1, 1.2]
  25428. *
  25429. * // The `_.property` iteratee shorthand.
  25430. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25431. * // => [{ 'x': 1 }, { 'x': 2 }]
  25432. */
  25433. var unionBy = baseRest(function(arrays) {
  25434. var iteratee = last(arrays);
  25435. if (isArrayLikeObject(iteratee)) {
  25436. iteratee = undefined;
  25437. }
  25438. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  25439. });
  25440. /**
  25441. * This method is like `_.union` except that it accepts `comparator` which
  25442. * is invoked to compare elements of `arrays`. Result values are chosen from
  25443. * the first array in which the value occurs. The comparator is invoked
  25444. * with two arguments: (arrVal, othVal).
  25445. *
  25446. * @static
  25447. * @memberOf _
  25448. * @since 4.0.0
  25449. * @category Array
  25450. * @param {...Array} [arrays] The arrays to inspect.
  25451. * @param {Function} [comparator] The comparator invoked per element.
  25452. * @returns {Array} Returns the new array of combined values.
  25453. * @example
  25454. *
  25455. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25456. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25457. *
  25458. * _.unionWith(objects, others, _.isEqual);
  25459. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25460. */
  25461. var unionWith = baseRest(function(arrays) {
  25462. var comparator = last(arrays);
  25463. comparator = typeof comparator == 'function' ? comparator : undefined;
  25464. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  25465. });
  25466. /**
  25467. * Creates a duplicate-free version of an array, using
  25468. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25469. * for equality comparisons, in which only the first occurrence of each element
  25470. * is kept. The order of result values is determined by the order they occur
  25471. * in the array.
  25472. *
  25473. * @static
  25474. * @memberOf _
  25475. * @since 0.1.0
  25476. * @category Array
  25477. * @param {Array} array The array to inspect.
  25478. * @returns {Array} Returns the new duplicate free array.
  25479. * @example
  25480. *
  25481. * _.uniq([2, 1, 2]);
  25482. * // => [2, 1]
  25483. */
  25484. function uniq(array) {
  25485. return (array && array.length) ? baseUniq(array) : [];
  25486. }
  25487. /**
  25488. * This method is like `_.uniq` except that it accepts `iteratee` which is
  25489. * invoked for each element in `array` to generate the criterion by which
  25490. * uniqueness is computed. The order of result values is determined by the
  25491. * order they occur in the array. The iteratee is invoked with one argument:
  25492. * (value).
  25493. *
  25494. * @static
  25495. * @memberOf _
  25496. * @since 4.0.0
  25497. * @category Array
  25498. * @param {Array} array The array to inspect.
  25499. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25500. * @returns {Array} Returns the new duplicate free array.
  25501. * @example
  25502. *
  25503. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  25504. * // => [2.1, 1.2]
  25505. *
  25506. * // The `_.property` iteratee shorthand.
  25507. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  25508. * // => [{ 'x': 1 }, { 'x': 2 }]
  25509. */
  25510. function uniqBy(array, iteratee) {
  25511. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  25512. }
  25513. /**
  25514. * This method is like `_.uniq` except that it accepts `comparator` which
  25515. * is invoked to compare elements of `array`. The order of result values is
  25516. * determined by the order they occur in the array.The comparator is invoked
  25517. * with two arguments: (arrVal, othVal).
  25518. *
  25519. * @static
  25520. * @memberOf _
  25521. * @since 4.0.0
  25522. * @category Array
  25523. * @param {Array} array The array to inspect.
  25524. * @param {Function} [comparator] The comparator invoked per element.
  25525. * @returns {Array} Returns the new duplicate free array.
  25526. * @example
  25527. *
  25528. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25529. *
  25530. * _.uniqWith(objects, _.isEqual);
  25531. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  25532. */
  25533. function uniqWith(array, comparator) {
  25534. comparator = typeof comparator == 'function' ? comparator : undefined;
  25535. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  25536. }
  25537. /**
  25538. * This method is like `_.zip` except that it accepts an array of grouped
  25539. * elements and creates an array regrouping the elements to their pre-zip
  25540. * configuration.
  25541. *
  25542. * @static
  25543. * @memberOf _
  25544. * @since 1.2.0
  25545. * @category Array
  25546. * @param {Array} array The array of grouped elements to process.
  25547. * @returns {Array} Returns the new array of regrouped elements.
  25548. * @example
  25549. *
  25550. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  25551. * // => [['a', 1, true], ['b', 2, false]]
  25552. *
  25553. * _.unzip(zipped);
  25554. * // => [['a', 'b'], [1, 2], [true, false]]
  25555. */
  25556. function unzip(array) {
  25557. if (!(array && array.length)) {
  25558. return [];
  25559. }
  25560. var length = 0;
  25561. array = arrayFilter(array, function(group) {
  25562. if (isArrayLikeObject(group)) {
  25563. length = nativeMax(group.length, length);
  25564. return true;
  25565. }
  25566. });
  25567. return baseTimes(length, function(index) {
  25568. return arrayMap(array, baseProperty(index));
  25569. });
  25570. }
  25571. /**
  25572. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  25573. * how regrouped values should be combined. The iteratee is invoked with the
  25574. * elements of each group: (...group).
  25575. *
  25576. * @static
  25577. * @memberOf _
  25578. * @since 3.8.0
  25579. * @category Array
  25580. * @param {Array} array The array of grouped elements to process.
  25581. * @param {Function} [iteratee=_.identity] The function to combine
  25582. * regrouped values.
  25583. * @returns {Array} Returns the new array of regrouped elements.
  25584. * @example
  25585. *
  25586. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  25587. * // => [[1, 10, 100], [2, 20, 200]]
  25588. *
  25589. * _.unzipWith(zipped, _.add);
  25590. * // => [3, 30, 300]
  25591. */
  25592. function unzipWith(array, iteratee) {
  25593. if (!(array && array.length)) {
  25594. return [];
  25595. }
  25596. var result = unzip(array);
  25597. if (iteratee == null) {
  25598. return result;
  25599. }
  25600. return arrayMap(result, function(group) {
  25601. return apply(iteratee, undefined, group);
  25602. });
  25603. }
  25604. /**
  25605. * Creates an array excluding all given values using
  25606. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25607. * for equality comparisons.
  25608. *
  25609. * **Note:** Unlike `_.pull`, this method returns a new array.
  25610. *
  25611. * @static
  25612. * @memberOf _
  25613. * @since 0.1.0
  25614. * @category Array
  25615. * @param {Array} array The array to inspect.
  25616. * @param {...*} [values] The values to exclude.
  25617. * @returns {Array} Returns the new array of filtered values.
  25618. * @see _.difference, _.xor
  25619. * @example
  25620. *
  25621. * _.without([2, 1, 2, 3], 1, 2);
  25622. * // => [3]
  25623. */
  25624. var without = baseRest(function(array, values) {
  25625. return isArrayLikeObject(array)
  25626. ? baseDifference(array, values)
  25627. : [];
  25628. });
  25629. /**
  25630. * Creates an array of unique values that is the
  25631. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  25632. * of the given arrays. The order of result values is determined by the order
  25633. * they occur in the arrays.
  25634. *
  25635. * @static
  25636. * @memberOf _
  25637. * @since 2.4.0
  25638. * @category Array
  25639. * @param {...Array} [arrays] The arrays to inspect.
  25640. * @returns {Array} Returns the new array of filtered values.
  25641. * @see _.difference, _.without
  25642. * @example
  25643. *
  25644. * _.xor([2, 1], [2, 3]);
  25645. * // => [1, 3]
  25646. */
  25647. var xor = baseRest(function(arrays) {
  25648. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  25649. });
  25650. /**
  25651. * This method is like `_.xor` except that it accepts `iteratee` which is
  25652. * invoked for each element of each `arrays` to generate the criterion by
  25653. * which by which they're compared. The order of result values is determined
  25654. * by the order they occur in the arrays. The iteratee is invoked with one
  25655. * argument: (value).
  25656. *
  25657. * @static
  25658. * @memberOf _
  25659. * @since 4.0.0
  25660. * @category Array
  25661. * @param {...Array} [arrays] The arrays to inspect.
  25662. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25663. * @returns {Array} Returns the new array of filtered values.
  25664. * @example
  25665. *
  25666. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  25667. * // => [1.2, 3.4]
  25668. *
  25669. * // The `_.property` iteratee shorthand.
  25670. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25671. * // => [{ 'x': 2 }]
  25672. */
  25673. var xorBy = baseRest(function(arrays) {
  25674. var iteratee = last(arrays);
  25675. if (isArrayLikeObject(iteratee)) {
  25676. iteratee = undefined;
  25677. }
  25678. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  25679. });
  25680. /**
  25681. * This method is like `_.xor` except that it accepts `comparator` which is
  25682. * invoked to compare elements of `arrays`. The order of result values is
  25683. * determined by the order they occur in the arrays. The comparator is invoked
  25684. * with two arguments: (arrVal, othVal).
  25685. *
  25686. * @static
  25687. * @memberOf _
  25688. * @since 4.0.0
  25689. * @category Array
  25690. * @param {...Array} [arrays] The arrays to inspect.
  25691. * @param {Function} [comparator] The comparator invoked per element.
  25692. * @returns {Array} Returns the new array of filtered values.
  25693. * @example
  25694. *
  25695. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25696. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25697. *
  25698. * _.xorWith(objects, others, _.isEqual);
  25699. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25700. */
  25701. var xorWith = baseRest(function(arrays) {
  25702. var comparator = last(arrays);
  25703. comparator = typeof comparator == 'function' ? comparator : undefined;
  25704. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  25705. });
  25706. /**
  25707. * Creates an array of grouped elements, the first of which contains the
  25708. * first elements of the given arrays, the second of which contains the
  25709. * second elements of the given arrays, and so on.
  25710. *
  25711. * @static
  25712. * @memberOf _
  25713. * @since 0.1.0
  25714. * @category Array
  25715. * @param {...Array} [arrays] The arrays to process.
  25716. * @returns {Array} Returns the new array of grouped elements.
  25717. * @example
  25718. *
  25719. * _.zip(['a', 'b'], [1, 2], [true, false]);
  25720. * // => [['a', 1, true], ['b', 2, false]]
  25721. */
  25722. var zip = baseRest(unzip);
  25723. /**
  25724. * This method is like `_.fromPairs` except that it accepts two arrays,
  25725. * one of property identifiers and one of corresponding values.
  25726. *
  25727. * @static
  25728. * @memberOf _
  25729. * @since 0.4.0
  25730. * @category Array
  25731. * @param {Array} [props=[]] The property identifiers.
  25732. * @param {Array} [values=[]] The property values.
  25733. * @returns {Object} Returns the new object.
  25734. * @example
  25735. *
  25736. * _.zipObject(['a', 'b'], [1, 2]);
  25737. * // => { 'a': 1, 'b': 2 }
  25738. */
  25739. function zipObject(props, values) {
  25740. return baseZipObject(props || [], values || [], assignValue);
  25741. }
  25742. /**
  25743. * This method is like `_.zipObject` except that it supports property paths.
  25744. *
  25745. * @static
  25746. * @memberOf _
  25747. * @since 4.1.0
  25748. * @category Array
  25749. * @param {Array} [props=[]] The property identifiers.
  25750. * @param {Array} [values=[]] The property values.
  25751. * @returns {Object} Returns the new object.
  25752. * @example
  25753. *
  25754. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  25755. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  25756. */
  25757. function zipObjectDeep(props, values) {
  25758. return baseZipObject(props || [], values || [], baseSet);
  25759. }
  25760. /**
  25761. * This method is like `_.zip` except that it accepts `iteratee` to specify
  25762. * how grouped values should be combined. The iteratee is invoked with the
  25763. * elements of each group: (...group).
  25764. *
  25765. * @static
  25766. * @memberOf _
  25767. * @since 3.8.0
  25768. * @category Array
  25769. * @param {...Array} [arrays] The arrays to process.
  25770. * @param {Function} [iteratee=_.identity] The function to combine
  25771. * grouped values.
  25772. * @returns {Array} Returns the new array of grouped elements.
  25773. * @example
  25774. *
  25775. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  25776. * return a + b + c;
  25777. * });
  25778. * // => [111, 222]
  25779. */
  25780. var zipWith = baseRest(function(arrays) {
  25781. var length = arrays.length,
  25782. iteratee = length > 1 ? arrays[length - 1] : undefined;
  25783. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  25784. return unzipWith(arrays, iteratee);
  25785. });
  25786. /*------------------------------------------------------------------------*/
  25787. /**
  25788. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  25789. * chain sequences enabled. The result of such sequences must be unwrapped
  25790. * with `_#value`.
  25791. *
  25792. * @static
  25793. * @memberOf _
  25794. * @since 1.3.0
  25795. * @category Seq
  25796. * @param {*} value The value to wrap.
  25797. * @returns {Object} Returns the new `lodash` wrapper instance.
  25798. * @example
  25799. *
  25800. * var users = [
  25801. * { 'user': 'barney', 'age': 36 },
  25802. * { 'user': 'fred', 'age': 40 },
  25803. * { 'user': 'pebbles', 'age': 1 }
  25804. * ];
  25805. *
  25806. * var youngest = _
  25807. * .chain(users)
  25808. * .sortBy('age')
  25809. * .map(function(o) {
  25810. * return o.user + ' is ' + o.age;
  25811. * })
  25812. * .head()
  25813. * .value();
  25814. * // => 'pebbles is 1'
  25815. */
  25816. function chain(value) {
  25817. var result = lodash(value);
  25818. result.__chain__ = true;
  25819. return result;
  25820. }
  25821. /**
  25822. * This method invokes `interceptor` and returns `value`. The interceptor
  25823. * is invoked with one argument; (value). The purpose of this method is to
  25824. * "tap into" a method chain sequence in order to modify intermediate results.
  25825. *
  25826. * @static
  25827. * @memberOf _
  25828. * @since 0.1.0
  25829. * @category Seq
  25830. * @param {*} value The value to provide to `interceptor`.
  25831. * @param {Function} interceptor The function to invoke.
  25832. * @returns {*} Returns `value`.
  25833. * @example
  25834. *
  25835. * _([1, 2, 3])
  25836. * .tap(function(array) {
  25837. * // Mutate input array.
  25838. * array.pop();
  25839. * })
  25840. * .reverse()
  25841. * .value();
  25842. * // => [2, 1]
  25843. */
  25844. function tap(value, interceptor) {
  25845. interceptor(value);
  25846. return value;
  25847. }
  25848. /**
  25849. * This method is like `_.tap` except that it returns the result of `interceptor`.
  25850. * The purpose of this method is to "pass thru" values replacing intermediate
  25851. * results in a method chain sequence.
  25852. *
  25853. * @static
  25854. * @memberOf _
  25855. * @since 3.0.0
  25856. * @category Seq
  25857. * @param {*} value The value to provide to `interceptor`.
  25858. * @param {Function} interceptor The function to invoke.
  25859. * @returns {*} Returns the result of `interceptor`.
  25860. * @example
  25861. *
  25862. * _(' abc ')
  25863. * .chain()
  25864. * .trim()
  25865. * .thru(function(value) {
  25866. * return [value];
  25867. * })
  25868. * .value();
  25869. * // => ['abc']
  25870. */
  25871. function thru(value, interceptor) {
  25872. return interceptor(value);
  25873. }
  25874. /**
  25875. * This method is the wrapper version of `_.at`.
  25876. *
  25877. * @name at
  25878. * @memberOf _
  25879. * @since 1.0.0
  25880. * @category Seq
  25881. * @param {...(string|string[])} [paths] The property paths to pick.
  25882. * @returns {Object} Returns the new `lodash` wrapper instance.
  25883. * @example
  25884. *
  25885. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  25886. *
  25887. * _(object).at(['a[0].b.c', 'a[1]']).value();
  25888. * // => [3, 4]
  25889. */
  25890. var wrapperAt = flatRest(function(paths) {
  25891. var length = paths.length,
  25892. start = length ? paths[0] : 0,
  25893. value = this.__wrapped__,
  25894. interceptor = function(object) { return baseAt(object, paths); };
  25895. if (length > 1 || this.__actions__.length ||
  25896. !(value instanceof LazyWrapper) || !isIndex(start)) {
  25897. return this.thru(interceptor);
  25898. }
  25899. value = value.slice(start, +start + (length ? 1 : 0));
  25900. value.__actions__.push({
  25901. 'func': thru,
  25902. 'args': [interceptor],
  25903. 'thisArg': undefined
  25904. });
  25905. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  25906. if (length && !array.length) {
  25907. array.push(undefined);
  25908. }
  25909. return array;
  25910. });
  25911. });
  25912. /**
  25913. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  25914. *
  25915. * @name chain
  25916. * @memberOf _
  25917. * @since 0.1.0
  25918. * @category Seq
  25919. * @returns {Object} Returns the new `lodash` wrapper instance.
  25920. * @example
  25921. *
  25922. * var users = [
  25923. * { 'user': 'barney', 'age': 36 },
  25924. * { 'user': 'fred', 'age': 40 }
  25925. * ];
  25926. *
  25927. * // A sequence without explicit chaining.
  25928. * _(users).head();
  25929. * // => { 'user': 'barney', 'age': 36 }
  25930. *
  25931. * // A sequence with explicit chaining.
  25932. * _(users)
  25933. * .chain()
  25934. * .head()
  25935. * .pick('user')
  25936. * .value();
  25937. * // => { 'user': 'barney' }
  25938. */
  25939. function wrapperChain() {
  25940. return chain(this);
  25941. }
  25942. /**
  25943. * Executes the chain sequence and returns the wrapped result.
  25944. *
  25945. * @name commit
  25946. * @memberOf _
  25947. * @since 3.2.0
  25948. * @category Seq
  25949. * @returns {Object} Returns the new `lodash` wrapper instance.
  25950. * @example
  25951. *
  25952. * var array = [1, 2];
  25953. * var wrapped = _(array).push(3);
  25954. *
  25955. * console.log(array);
  25956. * // => [1, 2]
  25957. *
  25958. * wrapped = wrapped.commit();
  25959. * console.log(array);
  25960. * // => [1, 2, 3]
  25961. *
  25962. * wrapped.last();
  25963. * // => 3
  25964. *
  25965. * console.log(array);
  25966. * // => [1, 2, 3]
  25967. */
  25968. function wrapperCommit() {
  25969. return new LodashWrapper(this.value(), this.__chain__);
  25970. }
  25971. /**
  25972. * Gets the next value on a wrapped object following the
  25973. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  25974. *
  25975. * @name next
  25976. * @memberOf _
  25977. * @since 4.0.0
  25978. * @category Seq
  25979. * @returns {Object} Returns the next iterator value.
  25980. * @example
  25981. *
  25982. * var wrapped = _([1, 2]);
  25983. *
  25984. * wrapped.next();
  25985. * // => { 'done': false, 'value': 1 }
  25986. *
  25987. * wrapped.next();
  25988. * // => { 'done': false, 'value': 2 }
  25989. *
  25990. * wrapped.next();
  25991. * // => { 'done': true, 'value': undefined }
  25992. */
  25993. function wrapperNext() {
  25994. if (this.__values__ === undefined) {
  25995. this.__values__ = toArray(this.value());
  25996. }
  25997. var done = this.__index__ >= this.__values__.length,
  25998. value = done ? undefined : this.__values__[this.__index__++];
  25999. return { 'done': done, 'value': value };
  26000. }
  26001. /**
  26002. * Enables the wrapper to be iterable.
  26003. *
  26004. * @name Symbol.iterator
  26005. * @memberOf _
  26006. * @since 4.0.0
  26007. * @category Seq
  26008. * @returns {Object} Returns the wrapper object.
  26009. * @example
  26010. *
  26011. * var wrapped = _([1, 2]);
  26012. *
  26013. * wrapped[Symbol.iterator]() === wrapped;
  26014. * // => true
  26015. *
  26016. * Array.from(wrapped);
  26017. * // => [1, 2]
  26018. */
  26019. function wrapperToIterator() {
  26020. return this;
  26021. }
  26022. /**
  26023. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  26024. *
  26025. * @name plant
  26026. * @memberOf _
  26027. * @since 3.2.0
  26028. * @category Seq
  26029. * @param {*} value The value to plant.
  26030. * @returns {Object} Returns the new `lodash` wrapper instance.
  26031. * @example
  26032. *
  26033. * function square(n) {
  26034. * return n * n;
  26035. * }
  26036. *
  26037. * var wrapped = _([1, 2]).map(square);
  26038. * var other = wrapped.plant([3, 4]);
  26039. *
  26040. * other.value();
  26041. * // => [9, 16]
  26042. *
  26043. * wrapped.value();
  26044. * // => [1, 4]
  26045. */
  26046. function wrapperPlant(value) {
  26047. var result,
  26048. parent = this;
  26049. while (parent instanceof baseLodash) {
  26050. var clone = wrapperClone(parent);
  26051. clone.__index__ = 0;
  26052. clone.__values__ = undefined;
  26053. if (result) {
  26054. previous.__wrapped__ = clone;
  26055. } else {
  26056. result = clone;
  26057. }
  26058. var previous = clone;
  26059. parent = parent.__wrapped__;
  26060. }
  26061. previous.__wrapped__ = value;
  26062. return result;
  26063. }
  26064. /**
  26065. * This method is the wrapper version of `_.reverse`.
  26066. *
  26067. * **Note:** This method mutates the wrapped array.
  26068. *
  26069. * @name reverse
  26070. * @memberOf _
  26071. * @since 0.1.0
  26072. * @category Seq
  26073. * @returns {Object} Returns the new `lodash` wrapper instance.
  26074. * @example
  26075. *
  26076. * var array = [1, 2, 3];
  26077. *
  26078. * _(array).reverse().value()
  26079. * // => [3, 2, 1]
  26080. *
  26081. * console.log(array);
  26082. * // => [3, 2, 1]
  26083. */
  26084. function wrapperReverse() {
  26085. var value = this.__wrapped__;
  26086. if (value instanceof LazyWrapper) {
  26087. var wrapped = value;
  26088. if (this.__actions__.length) {
  26089. wrapped = new LazyWrapper(this);
  26090. }
  26091. wrapped = wrapped.reverse();
  26092. wrapped.__actions__.push({
  26093. 'func': thru,
  26094. 'args': [reverse],
  26095. 'thisArg': undefined
  26096. });
  26097. return new LodashWrapper(wrapped, this.__chain__);
  26098. }
  26099. return this.thru(reverse);
  26100. }
  26101. /**
  26102. * Executes the chain sequence to resolve the unwrapped value.
  26103. *
  26104. * @name value
  26105. * @memberOf _
  26106. * @since 0.1.0
  26107. * @alias toJSON, valueOf
  26108. * @category Seq
  26109. * @returns {*} Returns the resolved unwrapped value.
  26110. * @example
  26111. *
  26112. * _([1, 2, 3]).value();
  26113. * // => [1, 2, 3]
  26114. */
  26115. function wrapperValue() {
  26116. return baseWrapperValue(this.__wrapped__, this.__actions__);
  26117. }
  26118. /*------------------------------------------------------------------------*/
  26119. /**
  26120. * Creates an object composed of keys generated from the results of running
  26121. * each element of `collection` thru `iteratee`. The corresponding value of
  26122. * each key is the number of times the key was returned by `iteratee`. The
  26123. * iteratee is invoked with one argument: (value).
  26124. *
  26125. * @static
  26126. * @memberOf _
  26127. * @since 0.5.0
  26128. * @category Collection
  26129. * @param {Array|Object} collection The collection to iterate over.
  26130. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26131. * @returns {Object} Returns the composed aggregate object.
  26132. * @example
  26133. *
  26134. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  26135. * // => { '4': 1, '6': 2 }
  26136. *
  26137. * // The `_.property` iteratee shorthand.
  26138. * _.countBy(['one', 'two', 'three'], 'length');
  26139. * // => { '3': 2, '5': 1 }
  26140. */
  26141. var countBy = createAggregator(function(result, value, key) {
  26142. if (hasOwnProperty.call(result, key)) {
  26143. ++result[key];
  26144. } else {
  26145. baseAssignValue(result, key, 1);
  26146. }
  26147. });
  26148. /**
  26149. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  26150. * Iteration is stopped once `predicate` returns falsey. The predicate is
  26151. * invoked with three arguments: (value, index|key, collection).
  26152. *
  26153. * **Note:** This method returns `true` for
  26154. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  26155. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  26156. * elements of empty collections.
  26157. *
  26158. * @static
  26159. * @memberOf _
  26160. * @since 0.1.0
  26161. * @category Collection
  26162. * @param {Array|Object} collection The collection to iterate over.
  26163. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26164. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26165. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  26166. * else `false`.
  26167. * @example
  26168. *
  26169. * _.every([true, 1, null, 'yes'], Boolean);
  26170. * // => false
  26171. *
  26172. * var users = [
  26173. * { 'user': 'barney', 'age': 36, 'active': false },
  26174. * { 'user': 'fred', 'age': 40, 'active': false }
  26175. * ];
  26176. *
  26177. * // The `_.matches` iteratee shorthand.
  26178. * _.every(users, { 'user': 'barney', 'active': false });
  26179. * // => false
  26180. *
  26181. * // The `_.matchesProperty` iteratee shorthand.
  26182. * _.every(users, ['active', false]);
  26183. * // => true
  26184. *
  26185. * // The `_.property` iteratee shorthand.
  26186. * _.every(users, 'active');
  26187. * // => false
  26188. */
  26189. function every(collection, predicate, guard) {
  26190. var func = isArray(collection) ? arrayEvery : baseEvery;
  26191. if (guard && isIterateeCall(collection, predicate, guard)) {
  26192. predicate = undefined;
  26193. }
  26194. return func(collection, getIteratee(predicate, 3));
  26195. }
  26196. /**
  26197. * Iterates over elements of `collection`, returning an array of all elements
  26198. * `predicate` returns truthy for. The predicate is invoked with three
  26199. * arguments: (value, index|key, collection).
  26200. *
  26201. * **Note:** Unlike `_.remove`, this method returns a new array.
  26202. *
  26203. * @static
  26204. * @memberOf _
  26205. * @since 0.1.0
  26206. * @category Collection
  26207. * @param {Array|Object} collection The collection to iterate over.
  26208. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26209. * @returns {Array} Returns the new filtered array.
  26210. * @see _.reject
  26211. * @example
  26212. *
  26213. * var users = [
  26214. * { 'user': 'barney', 'age': 36, 'active': true },
  26215. * { 'user': 'fred', 'age': 40, 'active': false }
  26216. * ];
  26217. *
  26218. * _.filter(users, function(o) { return !o.active; });
  26219. * // => objects for ['fred']
  26220. *
  26221. * // The `_.matches` iteratee shorthand.
  26222. * _.filter(users, { 'age': 36, 'active': true });
  26223. * // => objects for ['barney']
  26224. *
  26225. * // The `_.matchesProperty` iteratee shorthand.
  26226. * _.filter(users, ['active', false]);
  26227. * // => objects for ['fred']
  26228. *
  26229. * // The `_.property` iteratee shorthand.
  26230. * _.filter(users, 'active');
  26231. * // => objects for ['barney']
  26232. */
  26233. function filter(collection, predicate) {
  26234. var func = isArray(collection) ? arrayFilter : baseFilter;
  26235. return func(collection, getIteratee(predicate, 3));
  26236. }
  26237. /**
  26238. * Iterates over elements of `collection`, returning the first element
  26239. * `predicate` returns truthy for. The predicate is invoked with three
  26240. * arguments: (value, index|key, collection).
  26241. *
  26242. * @static
  26243. * @memberOf _
  26244. * @since 0.1.0
  26245. * @category Collection
  26246. * @param {Array|Object} collection The collection to inspect.
  26247. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26248. * @param {number} [fromIndex=0] The index to search from.
  26249. * @returns {*} Returns the matched element, else `undefined`.
  26250. * @example
  26251. *
  26252. * var users = [
  26253. * { 'user': 'barney', 'age': 36, 'active': true },
  26254. * { 'user': 'fred', 'age': 40, 'active': false },
  26255. * { 'user': 'pebbles', 'age': 1, 'active': true }
  26256. * ];
  26257. *
  26258. * _.find(users, function(o) { return o.age < 40; });
  26259. * // => object for 'barney'
  26260. *
  26261. * // The `_.matches` iteratee shorthand.
  26262. * _.find(users, { 'age': 1, 'active': true });
  26263. * // => object for 'pebbles'
  26264. *
  26265. * // The `_.matchesProperty` iteratee shorthand.
  26266. * _.find(users, ['active', false]);
  26267. * // => object for 'fred'
  26268. *
  26269. * // The `_.property` iteratee shorthand.
  26270. * _.find(users, 'active');
  26271. * // => object for 'barney'
  26272. */
  26273. var find = createFind(findIndex);
  26274. /**
  26275. * This method is like `_.find` except that it iterates over elements of
  26276. * `collection` from right to left.
  26277. *
  26278. * @static
  26279. * @memberOf _
  26280. * @since 2.0.0
  26281. * @category Collection
  26282. * @param {Array|Object} collection The collection to inspect.
  26283. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26284. * @param {number} [fromIndex=collection.length-1] The index to search from.
  26285. * @returns {*} Returns the matched element, else `undefined`.
  26286. * @example
  26287. *
  26288. * _.findLast([1, 2, 3, 4], function(n) {
  26289. * return n % 2 == 1;
  26290. * });
  26291. * // => 3
  26292. */
  26293. var findLast = createFind(findLastIndex);
  26294. /**
  26295. * Creates a flattened array of values by running each element in `collection`
  26296. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  26297. * with three arguments: (value, index|key, collection).
  26298. *
  26299. * @static
  26300. * @memberOf _
  26301. * @since 4.0.0
  26302. * @category Collection
  26303. * @param {Array|Object} collection The collection to iterate over.
  26304. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26305. * @returns {Array} Returns the new flattened array.
  26306. * @example
  26307. *
  26308. * function duplicate(n) {
  26309. * return [n, n];
  26310. * }
  26311. *
  26312. * _.flatMap([1, 2], duplicate);
  26313. * // => [1, 1, 2, 2]
  26314. */
  26315. function flatMap(collection, iteratee) {
  26316. return baseFlatten(map(collection, iteratee), 1);
  26317. }
  26318. /**
  26319. * This method is like `_.flatMap` except that it recursively flattens the
  26320. * mapped results.
  26321. *
  26322. * @static
  26323. * @memberOf _
  26324. * @since 4.7.0
  26325. * @category Collection
  26326. * @param {Array|Object} collection The collection to iterate over.
  26327. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26328. * @returns {Array} Returns the new flattened array.
  26329. * @example
  26330. *
  26331. * function duplicate(n) {
  26332. * return [[[n, n]]];
  26333. * }
  26334. *
  26335. * _.flatMapDeep([1, 2], duplicate);
  26336. * // => [1, 1, 2, 2]
  26337. */
  26338. function flatMapDeep(collection, iteratee) {
  26339. return baseFlatten(map(collection, iteratee), INFINITY);
  26340. }
  26341. /**
  26342. * This method is like `_.flatMap` except that it recursively flattens the
  26343. * mapped results up to `depth` times.
  26344. *
  26345. * @static
  26346. * @memberOf _
  26347. * @since 4.7.0
  26348. * @category Collection
  26349. * @param {Array|Object} collection The collection to iterate over.
  26350. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26351. * @param {number} [depth=1] The maximum recursion depth.
  26352. * @returns {Array} Returns the new flattened array.
  26353. * @example
  26354. *
  26355. * function duplicate(n) {
  26356. * return [[[n, n]]];
  26357. * }
  26358. *
  26359. * _.flatMapDepth([1, 2], duplicate, 2);
  26360. * // => [[1, 1], [2, 2]]
  26361. */
  26362. function flatMapDepth(collection, iteratee, depth) {
  26363. depth = depth === undefined ? 1 : toInteger(depth);
  26364. return baseFlatten(map(collection, iteratee), depth);
  26365. }
  26366. /**
  26367. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  26368. * The iteratee is invoked with three arguments: (value, index|key, collection).
  26369. * Iteratee functions may exit iteration early by explicitly returning `false`.
  26370. *
  26371. * **Note:** As with other "Collections" methods, objects with a "length"
  26372. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  26373. * or `_.forOwn` for object iteration.
  26374. *
  26375. * @static
  26376. * @memberOf _
  26377. * @since 0.1.0
  26378. * @alias each
  26379. * @category Collection
  26380. * @param {Array|Object} collection The collection to iterate over.
  26381. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26382. * @returns {Array|Object} Returns `collection`.
  26383. * @see _.forEachRight
  26384. * @example
  26385. *
  26386. * _.forEach([1, 2], function(value) {
  26387. * console.log(value);
  26388. * });
  26389. * // => Logs `1` then `2`.
  26390. *
  26391. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  26392. * console.log(key);
  26393. * });
  26394. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  26395. */
  26396. function forEach(collection, iteratee) {
  26397. var func = isArray(collection) ? arrayEach : baseEach;
  26398. return func(collection, getIteratee(iteratee, 3));
  26399. }
  26400. /**
  26401. * This method is like `_.forEach` except that it iterates over elements of
  26402. * `collection` from right to left.
  26403. *
  26404. * @static
  26405. * @memberOf _
  26406. * @since 2.0.0
  26407. * @alias eachRight
  26408. * @category Collection
  26409. * @param {Array|Object} collection The collection to iterate over.
  26410. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26411. * @returns {Array|Object} Returns `collection`.
  26412. * @see _.forEach
  26413. * @example
  26414. *
  26415. * _.forEachRight([1, 2], function(value) {
  26416. * console.log(value);
  26417. * });
  26418. * // => Logs `2` then `1`.
  26419. */
  26420. function forEachRight(collection, iteratee) {
  26421. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  26422. return func(collection, getIteratee(iteratee, 3));
  26423. }
  26424. /**
  26425. * Creates an object composed of keys generated from the results of running
  26426. * each element of `collection` thru `iteratee`. The order of grouped values
  26427. * is determined by the order they occur in `collection`. The corresponding
  26428. * value of each key is an array of elements responsible for generating the
  26429. * key. The iteratee is invoked with one argument: (value).
  26430. *
  26431. * @static
  26432. * @memberOf _
  26433. * @since 0.1.0
  26434. * @category Collection
  26435. * @param {Array|Object} collection The collection to iterate over.
  26436. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26437. * @returns {Object} Returns the composed aggregate object.
  26438. * @example
  26439. *
  26440. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  26441. * // => { '4': [4.2], '6': [6.1, 6.3] }
  26442. *
  26443. * // The `_.property` iteratee shorthand.
  26444. * _.groupBy(['one', 'two', 'three'], 'length');
  26445. * // => { '3': ['one', 'two'], '5': ['three'] }
  26446. */
  26447. var groupBy = createAggregator(function(result, value, key) {
  26448. if (hasOwnProperty.call(result, key)) {
  26449. result[key].push(value);
  26450. } else {
  26451. baseAssignValue(result, key, [value]);
  26452. }
  26453. });
  26454. /**
  26455. * Checks if `value` is in `collection`. If `collection` is a string, it's
  26456. * checked for a substring of `value`, otherwise
  26457. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  26458. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  26459. * the offset from the end of `collection`.
  26460. *
  26461. * @static
  26462. * @memberOf _
  26463. * @since 0.1.0
  26464. * @category Collection
  26465. * @param {Array|Object|string} collection The collection to inspect.
  26466. * @param {*} value The value to search for.
  26467. * @param {number} [fromIndex=0] The index to search from.
  26468. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26469. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  26470. * @example
  26471. *
  26472. * _.includes([1, 2, 3], 1);
  26473. * // => true
  26474. *
  26475. * _.includes([1, 2, 3], 1, 2);
  26476. * // => false
  26477. *
  26478. * _.includes({ 'a': 1, 'b': 2 }, 1);
  26479. * // => true
  26480. *
  26481. * _.includes('abcd', 'bc');
  26482. * // => true
  26483. */
  26484. function includes(collection, value, fromIndex, guard) {
  26485. collection = isArrayLike(collection) ? collection : values(collection);
  26486. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  26487. var length = collection.length;
  26488. if (fromIndex < 0) {
  26489. fromIndex = nativeMax(length + fromIndex, 0);
  26490. }
  26491. return isString(collection)
  26492. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  26493. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  26494. }
  26495. /**
  26496. * Invokes the method at `path` of each element in `collection`, returning
  26497. * an array of the results of each invoked method. Any additional arguments
  26498. * are provided to each invoked method. If `path` is a function, it's invoked
  26499. * for, and `this` bound to, each element in `collection`.
  26500. *
  26501. * @static
  26502. * @memberOf _
  26503. * @since 4.0.0
  26504. * @category Collection
  26505. * @param {Array|Object} collection The collection to iterate over.
  26506. * @param {Array|Function|string} path The path of the method to invoke or
  26507. * the function invoked per iteration.
  26508. * @param {...*} [args] The arguments to invoke each method with.
  26509. * @returns {Array} Returns the array of results.
  26510. * @example
  26511. *
  26512. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  26513. * // => [[1, 5, 7], [1, 2, 3]]
  26514. *
  26515. * _.invokeMap([123, 456], String.prototype.split, '');
  26516. * // => [['1', '2', '3'], ['4', '5', '6']]
  26517. */
  26518. var invokeMap = baseRest(function(collection, path, args) {
  26519. var index = -1,
  26520. isFunc = typeof path == 'function',
  26521. result = isArrayLike(collection) ? Array(collection.length) : [];
  26522. baseEach(collection, function(value) {
  26523. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  26524. });
  26525. return result;
  26526. });
  26527. /**
  26528. * Creates an object composed of keys generated from the results of running
  26529. * each element of `collection` thru `iteratee`. The corresponding value of
  26530. * each key is the last element responsible for generating the key. The
  26531. * iteratee is invoked with one argument: (value).
  26532. *
  26533. * @static
  26534. * @memberOf _
  26535. * @since 4.0.0
  26536. * @category Collection
  26537. * @param {Array|Object} collection The collection to iterate over.
  26538. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26539. * @returns {Object} Returns the composed aggregate object.
  26540. * @example
  26541. *
  26542. * var array = [
  26543. * { 'dir': 'left', 'code': 97 },
  26544. * { 'dir': 'right', 'code': 100 }
  26545. * ];
  26546. *
  26547. * _.keyBy(array, function(o) {
  26548. * return String.fromCharCode(o.code);
  26549. * });
  26550. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  26551. *
  26552. * _.keyBy(array, 'dir');
  26553. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  26554. */
  26555. var keyBy = createAggregator(function(result, value, key) {
  26556. baseAssignValue(result, key, value);
  26557. });
  26558. /**
  26559. * Creates an array of values by running each element in `collection` thru
  26560. * `iteratee`. The iteratee is invoked with three arguments:
  26561. * (value, index|key, collection).
  26562. *
  26563. * Many lodash methods are guarded to work as iteratees for methods like
  26564. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  26565. *
  26566. * The guarded methods are:
  26567. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  26568. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  26569. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  26570. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  26571. *
  26572. * @static
  26573. * @memberOf _
  26574. * @since 0.1.0
  26575. * @category Collection
  26576. * @param {Array|Object} collection The collection to iterate over.
  26577. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26578. * @returns {Array} Returns the new mapped array.
  26579. * @example
  26580. *
  26581. * function square(n) {
  26582. * return n * n;
  26583. * }
  26584. *
  26585. * _.map([4, 8], square);
  26586. * // => [16, 64]
  26587. *
  26588. * _.map({ 'a': 4, 'b': 8 }, square);
  26589. * // => [16, 64] (iteration order is not guaranteed)
  26590. *
  26591. * var users = [
  26592. * { 'user': 'barney' },
  26593. * { 'user': 'fred' }
  26594. * ];
  26595. *
  26596. * // The `_.property` iteratee shorthand.
  26597. * _.map(users, 'user');
  26598. * // => ['barney', 'fred']
  26599. */
  26600. function map(collection, iteratee) {
  26601. var func = isArray(collection) ? arrayMap : baseMap;
  26602. return func(collection, getIteratee(iteratee, 3));
  26603. }
  26604. /**
  26605. * This method is like `_.sortBy` except that it allows specifying the sort
  26606. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  26607. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  26608. * descending or "asc" for ascending sort order of corresponding values.
  26609. *
  26610. * @static
  26611. * @memberOf _
  26612. * @since 4.0.0
  26613. * @category Collection
  26614. * @param {Array|Object} collection The collection to iterate over.
  26615. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  26616. * The iteratees to sort by.
  26617. * @param {string[]} [orders] The sort orders of `iteratees`.
  26618. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26619. * @returns {Array} Returns the new sorted array.
  26620. * @example
  26621. *
  26622. * var users = [
  26623. * { 'user': 'fred', 'age': 48 },
  26624. * { 'user': 'barney', 'age': 34 },
  26625. * { 'user': 'fred', 'age': 40 },
  26626. * { 'user': 'barney', 'age': 36 }
  26627. * ];
  26628. *
  26629. * // Sort by `user` in ascending order and by `age` in descending order.
  26630. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  26631. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26632. */
  26633. function orderBy(collection, iteratees, orders, guard) {
  26634. if (collection == null) {
  26635. return [];
  26636. }
  26637. if (!isArray(iteratees)) {
  26638. iteratees = iteratees == null ? [] : [iteratees];
  26639. }
  26640. orders = guard ? undefined : orders;
  26641. if (!isArray(orders)) {
  26642. orders = orders == null ? [] : [orders];
  26643. }
  26644. return baseOrderBy(collection, iteratees, orders);
  26645. }
  26646. /**
  26647. * Creates an array of elements split into two groups, the first of which
  26648. * contains elements `predicate` returns truthy for, the second of which
  26649. * contains elements `predicate` returns falsey for. The predicate is
  26650. * invoked with one argument: (value).
  26651. *
  26652. * @static
  26653. * @memberOf _
  26654. * @since 3.0.0
  26655. * @category Collection
  26656. * @param {Array|Object} collection The collection to iterate over.
  26657. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26658. * @returns {Array} Returns the array of grouped elements.
  26659. * @example
  26660. *
  26661. * var users = [
  26662. * { 'user': 'barney', 'age': 36, 'active': false },
  26663. * { 'user': 'fred', 'age': 40, 'active': true },
  26664. * { 'user': 'pebbles', 'age': 1, 'active': false }
  26665. * ];
  26666. *
  26667. * _.partition(users, function(o) { return o.active; });
  26668. * // => objects for [['fred'], ['barney', 'pebbles']]
  26669. *
  26670. * // The `_.matches` iteratee shorthand.
  26671. * _.partition(users, { 'age': 1, 'active': false });
  26672. * // => objects for [['pebbles'], ['barney', 'fred']]
  26673. *
  26674. * // The `_.matchesProperty` iteratee shorthand.
  26675. * _.partition(users, ['active', false]);
  26676. * // => objects for [['barney', 'pebbles'], ['fred']]
  26677. *
  26678. * // The `_.property` iteratee shorthand.
  26679. * _.partition(users, 'active');
  26680. * // => objects for [['fred'], ['barney', 'pebbles']]
  26681. */
  26682. var partition = createAggregator(function(result, value, key) {
  26683. result[key ? 0 : 1].push(value);
  26684. }, function() { return [[], []]; });
  26685. /**
  26686. * Reduces `collection` to a value which is the accumulated result of running
  26687. * each element in `collection` thru `iteratee`, where each successive
  26688. * invocation is supplied the return value of the previous. If `accumulator`
  26689. * is not given, the first element of `collection` is used as the initial
  26690. * value. The iteratee is invoked with four arguments:
  26691. * (accumulator, value, index|key, collection).
  26692. *
  26693. * Many lodash methods are guarded to work as iteratees for methods like
  26694. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  26695. *
  26696. * The guarded methods are:
  26697. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  26698. * and `sortBy`
  26699. *
  26700. * @static
  26701. * @memberOf _
  26702. * @since 0.1.0
  26703. * @category Collection
  26704. * @param {Array|Object} collection The collection to iterate over.
  26705. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26706. * @param {*} [accumulator] The initial value.
  26707. * @returns {*} Returns the accumulated value.
  26708. * @see _.reduceRight
  26709. * @example
  26710. *
  26711. * _.reduce([1, 2], function(sum, n) {
  26712. * return sum + n;
  26713. * }, 0);
  26714. * // => 3
  26715. *
  26716. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  26717. * (result[value] || (result[value] = [])).push(key);
  26718. * return result;
  26719. * }, {});
  26720. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  26721. */
  26722. function reduce(collection, iteratee, accumulator) {
  26723. var func = isArray(collection) ? arrayReduce : baseReduce,
  26724. initAccum = arguments.length < 3;
  26725. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  26726. }
  26727. /**
  26728. * This method is like `_.reduce` except that it iterates over elements of
  26729. * `collection` from right to left.
  26730. *
  26731. * @static
  26732. * @memberOf _
  26733. * @since 0.1.0
  26734. * @category Collection
  26735. * @param {Array|Object} collection The collection to iterate over.
  26736. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26737. * @param {*} [accumulator] The initial value.
  26738. * @returns {*} Returns the accumulated value.
  26739. * @see _.reduce
  26740. * @example
  26741. *
  26742. * var array = [[0, 1], [2, 3], [4, 5]];
  26743. *
  26744. * _.reduceRight(array, function(flattened, other) {
  26745. * return flattened.concat(other);
  26746. * }, []);
  26747. * // => [4, 5, 2, 3, 0, 1]
  26748. */
  26749. function reduceRight(collection, iteratee, accumulator) {
  26750. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  26751. initAccum = arguments.length < 3;
  26752. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  26753. }
  26754. /**
  26755. * The opposite of `_.filter`; this method returns the elements of `collection`
  26756. * that `predicate` does **not** return truthy for.
  26757. *
  26758. * @static
  26759. * @memberOf _
  26760. * @since 0.1.0
  26761. * @category Collection
  26762. * @param {Array|Object} collection The collection to iterate over.
  26763. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26764. * @returns {Array} Returns the new filtered array.
  26765. * @see _.filter
  26766. * @example
  26767. *
  26768. * var users = [
  26769. * { 'user': 'barney', 'age': 36, 'active': false },
  26770. * { 'user': 'fred', 'age': 40, 'active': true }
  26771. * ];
  26772. *
  26773. * _.reject(users, function(o) { return !o.active; });
  26774. * // => objects for ['fred']
  26775. *
  26776. * // The `_.matches` iteratee shorthand.
  26777. * _.reject(users, { 'age': 40, 'active': true });
  26778. * // => objects for ['barney']
  26779. *
  26780. * // The `_.matchesProperty` iteratee shorthand.
  26781. * _.reject(users, ['active', false]);
  26782. * // => objects for ['fred']
  26783. *
  26784. * // The `_.property` iteratee shorthand.
  26785. * _.reject(users, 'active');
  26786. * // => objects for ['barney']
  26787. */
  26788. function reject(collection, predicate) {
  26789. var func = isArray(collection) ? arrayFilter : baseFilter;
  26790. return func(collection, negate(getIteratee(predicate, 3)));
  26791. }
  26792. /**
  26793. * Gets a random element from `collection`.
  26794. *
  26795. * @static
  26796. * @memberOf _
  26797. * @since 2.0.0
  26798. * @category Collection
  26799. * @param {Array|Object} collection The collection to sample.
  26800. * @returns {*} Returns the random element.
  26801. * @example
  26802. *
  26803. * _.sample([1, 2, 3, 4]);
  26804. * // => 2
  26805. */
  26806. function sample(collection) {
  26807. var func = isArray(collection) ? arraySample : baseSample;
  26808. return func(collection);
  26809. }
  26810. /**
  26811. * Gets `n` random elements at unique keys from `collection` up to the
  26812. * size of `collection`.
  26813. *
  26814. * @static
  26815. * @memberOf _
  26816. * @since 4.0.0
  26817. * @category Collection
  26818. * @param {Array|Object} collection The collection to sample.
  26819. * @param {number} [n=1] The number of elements to sample.
  26820. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26821. * @returns {Array} Returns the random elements.
  26822. * @example
  26823. *
  26824. * _.sampleSize([1, 2, 3], 2);
  26825. * // => [3, 1]
  26826. *
  26827. * _.sampleSize([1, 2, 3], 4);
  26828. * // => [2, 3, 1]
  26829. */
  26830. function sampleSize(collection, n, guard) {
  26831. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  26832. n = 1;
  26833. } else {
  26834. n = toInteger(n);
  26835. }
  26836. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  26837. return func(collection, n);
  26838. }
  26839. /**
  26840. * Creates an array of shuffled values, using a version of the
  26841. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  26842. *
  26843. * @static
  26844. * @memberOf _
  26845. * @since 0.1.0
  26846. * @category Collection
  26847. * @param {Array|Object} collection The collection to shuffle.
  26848. * @returns {Array} Returns the new shuffled array.
  26849. * @example
  26850. *
  26851. * _.shuffle([1, 2, 3, 4]);
  26852. * // => [4, 1, 3, 2]
  26853. */
  26854. function shuffle(collection) {
  26855. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  26856. return func(collection);
  26857. }
  26858. /**
  26859. * Gets the size of `collection` by returning its length for array-like
  26860. * values or the number of own enumerable string keyed properties for objects.
  26861. *
  26862. * @static
  26863. * @memberOf _
  26864. * @since 0.1.0
  26865. * @category Collection
  26866. * @param {Array|Object|string} collection The collection to inspect.
  26867. * @returns {number} Returns the collection size.
  26868. * @example
  26869. *
  26870. * _.size([1, 2, 3]);
  26871. * // => 3
  26872. *
  26873. * _.size({ 'a': 1, 'b': 2 });
  26874. * // => 2
  26875. *
  26876. * _.size('pebbles');
  26877. * // => 7
  26878. */
  26879. function size(collection) {
  26880. if (collection == null) {
  26881. return 0;
  26882. }
  26883. if (isArrayLike(collection)) {
  26884. return isString(collection) ? stringSize(collection) : collection.length;
  26885. }
  26886. var tag = getTag(collection);
  26887. if (tag == mapTag || tag == setTag) {
  26888. return collection.size;
  26889. }
  26890. return baseKeys(collection).length;
  26891. }
  26892. /**
  26893. * Checks if `predicate` returns truthy for **any** element of `collection`.
  26894. * Iteration is stopped once `predicate` returns truthy. The predicate is
  26895. * invoked with three arguments: (value, index|key, collection).
  26896. *
  26897. * @static
  26898. * @memberOf _
  26899. * @since 0.1.0
  26900. * @category Collection
  26901. * @param {Array|Object} collection The collection to iterate over.
  26902. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26903. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26904. * @returns {boolean} Returns `true` if any element passes the predicate check,
  26905. * else `false`.
  26906. * @example
  26907. *
  26908. * _.some([null, 0, 'yes', false], Boolean);
  26909. * // => true
  26910. *
  26911. * var users = [
  26912. * { 'user': 'barney', 'active': true },
  26913. * { 'user': 'fred', 'active': false }
  26914. * ];
  26915. *
  26916. * // The `_.matches` iteratee shorthand.
  26917. * _.some(users, { 'user': 'barney', 'active': false });
  26918. * // => false
  26919. *
  26920. * // The `_.matchesProperty` iteratee shorthand.
  26921. * _.some(users, ['active', false]);
  26922. * // => true
  26923. *
  26924. * // The `_.property` iteratee shorthand.
  26925. * _.some(users, 'active');
  26926. * // => true
  26927. */
  26928. function some(collection, predicate, guard) {
  26929. var func = isArray(collection) ? arraySome : baseSome;
  26930. if (guard && isIterateeCall(collection, predicate, guard)) {
  26931. predicate = undefined;
  26932. }
  26933. return func(collection, getIteratee(predicate, 3));
  26934. }
  26935. /**
  26936. * Creates an array of elements, sorted in ascending order by the results of
  26937. * running each element in a collection thru each iteratee. This method
  26938. * performs a stable sort, that is, it preserves the original sort order of
  26939. * equal elements. The iteratees are invoked with one argument: (value).
  26940. *
  26941. * @static
  26942. * @memberOf _
  26943. * @since 0.1.0
  26944. * @category Collection
  26945. * @param {Array|Object} collection The collection to iterate over.
  26946. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  26947. * The iteratees to sort by.
  26948. * @returns {Array} Returns the new sorted array.
  26949. * @example
  26950. *
  26951. * var users = [
  26952. * { 'user': 'fred', 'age': 48 },
  26953. * { 'user': 'barney', 'age': 36 },
  26954. * { 'user': 'fred', 'age': 40 },
  26955. * { 'user': 'barney', 'age': 34 }
  26956. * ];
  26957. *
  26958. * _.sortBy(users, [function(o) { return o.user; }]);
  26959. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26960. *
  26961. * _.sortBy(users, ['user', 'age']);
  26962. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  26963. */
  26964. var sortBy = baseRest(function(collection, iteratees) {
  26965. if (collection == null) {
  26966. return [];
  26967. }
  26968. var length = iteratees.length;
  26969. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  26970. iteratees = [];
  26971. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  26972. iteratees = [iteratees[0]];
  26973. }
  26974. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  26975. });
  26976. /*------------------------------------------------------------------------*/
  26977. /**
  26978. * Gets the timestamp of the number of milliseconds that have elapsed since
  26979. * the Unix epoch (1 January 1970 00:00:00 UTC).
  26980. *
  26981. * @static
  26982. * @memberOf _
  26983. * @since 2.4.0
  26984. * @category Date
  26985. * @returns {number} Returns the timestamp.
  26986. * @example
  26987. *
  26988. * _.defer(function(stamp) {
  26989. * console.log(_.now() - stamp);
  26990. * }, _.now());
  26991. * // => Logs the number of milliseconds it took for the deferred invocation.
  26992. */
  26993. var now = ctxNow || function() {
  26994. return root.Date.now();
  26995. };
  26996. /*------------------------------------------------------------------------*/
  26997. /**
  26998. * The opposite of `_.before`; this method creates a function that invokes
  26999. * `func` once it's called `n` or more times.
  27000. *
  27001. * @static
  27002. * @memberOf _
  27003. * @since 0.1.0
  27004. * @category Function
  27005. * @param {number} n The number of calls before `func` is invoked.
  27006. * @param {Function} func The function to restrict.
  27007. * @returns {Function} Returns the new restricted function.
  27008. * @example
  27009. *
  27010. * var saves = ['profile', 'settings'];
  27011. *
  27012. * var done = _.after(saves.length, function() {
  27013. * console.log('done saving!');
  27014. * });
  27015. *
  27016. * _.forEach(saves, function(type) {
  27017. * asyncSave({ 'type': type, 'complete': done });
  27018. * });
  27019. * // => Logs 'done saving!' after the two async saves have completed.
  27020. */
  27021. function after(n, func) {
  27022. if (typeof func != 'function') {
  27023. throw new TypeError(FUNC_ERROR_TEXT);
  27024. }
  27025. n = toInteger(n);
  27026. return function() {
  27027. if (--n < 1) {
  27028. return func.apply(this, arguments);
  27029. }
  27030. };
  27031. }
  27032. /**
  27033. * Creates a function that invokes `func`, with up to `n` arguments,
  27034. * ignoring any additional arguments.
  27035. *
  27036. * @static
  27037. * @memberOf _
  27038. * @since 3.0.0
  27039. * @category Function
  27040. * @param {Function} func The function to cap arguments for.
  27041. * @param {number} [n=func.length] The arity cap.
  27042. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27043. * @returns {Function} Returns the new capped function.
  27044. * @example
  27045. *
  27046. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  27047. * // => [6, 8, 10]
  27048. */
  27049. function ary(func, n, guard) {
  27050. n = guard ? undefined : n;
  27051. n = (func && n == null) ? func.length : n;
  27052. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  27053. }
  27054. /**
  27055. * Creates a function that invokes `func`, with the `this` binding and arguments
  27056. * of the created function, while it's called less than `n` times. Subsequent
  27057. * calls to the created function return the result of the last `func` invocation.
  27058. *
  27059. * @static
  27060. * @memberOf _
  27061. * @since 3.0.0
  27062. * @category Function
  27063. * @param {number} n The number of calls at which `func` is no longer invoked.
  27064. * @param {Function} func The function to restrict.
  27065. * @returns {Function} Returns the new restricted function.
  27066. * @example
  27067. *
  27068. * jQuery(element).on('click', _.before(5, addContactToList));
  27069. * // => Allows adding up to 4 contacts to the list.
  27070. */
  27071. function before(n, func) {
  27072. var result;
  27073. if (typeof func != 'function') {
  27074. throw new TypeError(FUNC_ERROR_TEXT);
  27075. }
  27076. n = toInteger(n);
  27077. return function() {
  27078. if (--n > 0) {
  27079. result = func.apply(this, arguments);
  27080. }
  27081. if (n <= 1) {
  27082. func = undefined;
  27083. }
  27084. return result;
  27085. };
  27086. }
  27087. /**
  27088. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  27089. * and `partials` prepended to the arguments it receives.
  27090. *
  27091. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  27092. * may be used as a placeholder for partially applied arguments.
  27093. *
  27094. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  27095. * property of bound functions.
  27096. *
  27097. * @static
  27098. * @memberOf _
  27099. * @since 0.1.0
  27100. * @category Function
  27101. * @param {Function} func The function to bind.
  27102. * @param {*} thisArg The `this` binding of `func`.
  27103. * @param {...*} [partials] The arguments to be partially applied.
  27104. * @returns {Function} Returns the new bound function.
  27105. * @example
  27106. *
  27107. * function greet(greeting, punctuation) {
  27108. * return greeting + ' ' + this.user + punctuation;
  27109. * }
  27110. *
  27111. * var object = { 'user': 'fred' };
  27112. *
  27113. * var bound = _.bind(greet, object, 'hi');
  27114. * bound('!');
  27115. * // => 'hi fred!'
  27116. *
  27117. * // Bound with placeholders.
  27118. * var bound = _.bind(greet, object, _, '!');
  27119. * bound('hi');
  27120. * // => 'hi fred!'
  27121. */
  27122. var bind = baseRest(function(func, thisArg, partials) {
  27123. var bitmask = WRAP_BIND_FLAG;
  27124. if (partials.length) {
  27125. var holders = replaceHolders(partials, getHolder(bind));
  27126. bitmask |= WRAP_PARTIAL_FLAG;
  27127. }
  27128. return createWrap(func, bitmask, thisArg, partials, holders);
  27129. });
  27130. /**
  27131. * Creates a function that invokes the method at `object[key]` with `partials`
  27132. * prepended to the arguments it receives.
  27133. *
  27134. * This method differs from `_.bind` by allowing bound functions to reference
  27135. * methods that may be redefined or don't yet exist. See
  27136. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  27137. * for more details.
  27138. *
  27139. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  27140. * builds, may be used as a placeholder for partially applied arguments.
  27141. *
  27142. * @static
  27143. * @memberOf _
  27144. * @since 0.10.0
  27145. * @category Function
  27146. * @param {Object} object The object to invoke the method on.
  27147. * @param {string} key The key of the method.
  27148. * @param {...*} [partials] The arguments to be partially applied.
  27149. * @returns {Function} Returns the new bound function.
  27150. * @example
  27151. *
  27152. * var object = {
  27153. * 'user': 'fred',
  27154. * 'greet': function(greeting, punctuation) {
  27155. * return greeting + ' ' + this.user + punctuation;
  27156. * }
  27157. * };
  27158. *
  27159. * var bound = _.bindKey(object, 'greet', 'hi');
  27160. * bound('!');
  27161. * // => 'hi fred!'
  27162. *
  27163. * object.greet = function(greeting, punctuation) {
  27164. * return greeting + 'ya ' + this.user + punctuation;
  27165. * };
  27166. *
  27167. * bound('!');
  27168. * // => 'hiya fred!'
  27169. *
  27170. * // Bound with placeholders.
  27171. * var bound = _.bindKey(object, 'greet', _, '!');
  27172. * bound('hi');
  27173. * // => 'hiya fred!'
  27174. */
  27175. var bindKey = baseRest(function(object, key, partials) {
  27176. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  27177. if (partials.length) {
  27178. var holders = replaceHolders(partials, getHolder(bindKey));
  27179. bitmask |= WRAP_PARTIAL_FLAG;
  27180. }
  27181. return createWrap(key, bitmask, object, partials, holders);
  27182. });
  27183. /**
  27184. * Creates a function that accepts arguments of `func` and either invokes
  27185. * `func` returning its result, if at least `arity` number of arguments have
  27186. * been provided, or returns a function that accepts the remaining `func`
  27187. * arguments, and so on. The arity of `func` may be specified if `func.length`
  27188. * is not sufficient.
  27189. *
  27190. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  27191. * may be used as a placeholder for provided arguments.
  27192. *
  27193. * **Note:** This method doesn't set the "length" property of curried functions.
  27194. *
  27195. * @static
  27196. * @memberOf _
  27197. * @since 2.0.0
  27198. * @category Function
  27199. * @param {Function} func The function to curry.
  27200. * @param {number} [arity=func.length] The arity of `func`.
  27201. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27202. * @returns {Function} Returns the new curried function.
  27203. * @example
  27204. *
  27205. * var abc = function(a, b, c) {
  27206. * return [a, b, c];
  27207. * };
  27208. *
  27209. * var curried = _.curry(abc);
  27210. *
  27211. * curried(1)(2)(3);
  27212. * // => [1, 2, 3]
  27213. *
  27214. * curried(1, 2)(3);
  27215. * // => [1, 2, 3]
  27216. *
  27217. * curried(1, 2, 3);
  27218. * // => [1, 2, 3]
  27219. *
  27220. * // Curried with placeholders.
  27221. * curried(1)(_, 3)(2);
  27222. * // => [1, 2, 3]
  27223. */
  27224. function curry(func, arity, guard) {
  27225. arity = guard ? undefined : arity;
  27226. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27227. result.placeholder = curry.placeholder;
  27228. return result;
  27229. }
  27230. /**
  27231. * This method is like `_.curry` except that arguments are applied to `func`
  27232. * in the manner of `_.partialRight` instead of `_.partial`.
  27233. *
  27234. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  27235. * builds, may be used as a placeholder for provided arguments.
  27236. *
  27237. * **Note:** This method doesn't set the "length" property of curried functions.
  27238. *
  27239. * @static
  27240. * @memberOf _
  27241. * @since 3.0.0
  27242. * @category Function
  27243. * @param {Function} func The function to curry.
  27244. * @param {number} [arity=func.length] The arity of `func`.
  27245. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27246. * @returns {Function} Returns the new curried function.
  27247. * @example
  27248. *
  27249. * var abc = function(a, b, c) {
  27250. * return [a, b, c];
  27251. * };
  27252. *
  27253. * var curried = _.curryRight(abc);
  27254. *
  27255. * curried(3)(2)(1);
  27256. * // => [1, 2, 3]
  27257. *
  27258. * curried(2, 3)(1);
  27259. * // => [1, 2, 3]
  27260. *
  27261. * curried(1, 2, 3);
  27262. * // => [1, 2, 3]
  27263. *
  27264. * // Curried with placeholders.
  27265. * curried(3)(1, _)(2);
  27266. * // => [1, 2, 3]
  27267. */
  27268. function curryRight(func, arity, guard) {
  27269. arity = guard ? undefined : arity;
  27270. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27271. result.placeholder = curryRight.placeholder;
  27272. return result;
  27273. }
  27274. /**
  27275. * Creates a debounced function that delays invoking `func` until after `wait`
  27276. * milliseconds have elapsed since the last time the debounced function was
  27277. * invoked. The debounced function comes with a `cancel` method to cancel
  27278. * delayed `func` invocations and a `flush` method to immediately invoke them.
  27279. * Provide `options` to indicate whether `func` should be invoked on the
  27280. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  27281. * with the last arguments provided to the debounced function. Subsequent
  27282. * calls to the debounced function return the result of the last `func`
  27283. * invocation.
  27284. *
  27285. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27286. * invoked on the trailing edge of the timeout only if the debounced function
  27287. * is invoked more than once during the `wait` timeout.
  27288. *
  27289. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27290. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27291. *
  27292. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27293. * for details over the differences between `_.debounce` and `_.throttle`.
  27294. *
  27295. * @static
  27296. * @memberOf _
  27297. * @since 0.1.0
  27298. * @category Function
  27299. * @param {Function} func The function to debounce.
  27300. * @param {number} [wait=0] The number of milliseconds to delay.
  27301. * @param {Object} [options={}] The options object.
  27302. * @param {boolean} [options.leading=false]
  27303. * Specify invoking on the leading edge of the timeout.
  27304. * @param {number} [options.maxWait]
  27305. * The maximum time `func` is allowed to be delayed before it's invoked.
  27306. * @param {boolean} [options.trailing=true]
  27307. * Specify invoking on the trailing edge of the timeout.
  27308. * @returns {Function} Returns the new debounced function.
  27309. * @example
  27310. *
  27311. * // Avoid costly calculations while the window size is in flux.
  27312. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  27313. *
  27314. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  27315. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  27316. * 'leading': true,
  27317. * 'trailing': false
  27318. * }));
  27319. *
  27320. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  27321. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  27322. * var source = new EventSource('/stream');
  27323. * jQuery(source).on('message', debounced);
  27324. *
  27325. * // Cancel the trailing debounced invocation.
  27326. * jQuery(window).on('popstate', debounced.cancel);
  27327. */
  27328. function debounce(func, wait, options) {
  27329. var lastArgs,
  27330. lastThis,
  27331. maxWait,
  27332. result,
  27333. timerId,
  27334. lastCallTime,
  27335. lastInvokeTime = 0,
  27336. leading = false,
  27337. maxing = false,
  27338. trailing = true;
  27339. if (typeof func != 'function') {
  27340. throw new TypeError(FUNC_ERROR_TEXT);
  27341. }
  27342. wait = toNumber(wait) || 0;
  27343. if (isObject(options)) {
  27344. leading = !!options.leading;
  27345. maxing = 'maxWait' in options;
  27346. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  27347. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27348. }
  27349. function invokeFunc(time) {
  27350. var args = lastArgs,
  27351. thisArg = lastThis;
  27352. lastArgs = lastThis = undefined;
  27353. lastInvokeTime = time;
  27354. result = func.apply(thisArg, args);
  27355. return result;
  27356. }
  27357. function leadingEdge(time) {
  27358. // Reset any `maxWait` timer.
  27359. lastInvokeTime = time;
  27360. // Start the timer for the trailing edge.
  27361. timerId = setTimeout(timerExpired, wait);
  27362. // Invoke the leading edge.
  27363. return leading ? invokeFunc(time) : result;
  27364. }
  27365. function remainingWait(time) {
  27366. var timeSinceLastCall = time - lastCallTime,
  27367. timeSinceLastInvoke = time - lastInvokeTime,
  27368. timeWaiting = wait - timeSinceLastCall;
  27369. return maxing
  27370. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  27371. : timeWaiting;
  27372. }
  27373. function shouldInvoke(time) {
  27374. var timeSinceLastCall = time - lastCallTime,
  27375. timeSinceLastInvoke = time - lastInvokeTime;
  27376. // Either this is the first call, activity has stopped and we're at the
  27377. // trailing edge, the system time has gone backwards and we're treating
  27378. // it as the trailing edge, or we've hit the `maxWait` limit.
  27379. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  27380. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  27381. }
  27382. function timerExpired() {
  27383. var time = now();
  27384. if (shouldInvoke(time)) {
  27385. return trailingEdge(time);
  27386. }
  27387. // Restart the timer.
  27388. timerId = setTimeout(timerExpired, remainingWait(time));
  27389. }
  27390. function trailingEdge(time) {
  27391. timerId = undefined;
  27392. // Only invoke if we have `lastArgs` which means `func` has been
  27393. // debounced at least once.
  27394. if (trailing && lastArgs) {
  27395. return invokeFunc(time);
  27396. }
  27397. lastArgs = lastThis = undefined;
  27398. return result;
  27399. }
  27400. function cancel() {
  27401. if (timerId !== undefined) {
  27402. clearTimeout(timerId);
  27403. }
  27404. lastInvokeTime = 0;
  27405. lastArgs = lastCallTime = lastThis = timerId = undefined;
  27406. }
  27407. function flush() {
  27408. return timerId === undefined ? result : trailingEdge(now());
  27409. }
  27410. function debounced() {
  27411. var time = now(),
  27412. isInvoking = shouldInvoke(time);
  27413. lastArgs = arguments;
  27414. lastThis = this;
  27415. lastCallTime = time;
  27416. if (isInvoking) {
  27417. if (timerId === undefined) {
  27418. return leadingEdge(lastCallTime);
  27419. }
  27420. if (maxing) {
  27421. // Handle invocations in a tight loop.
  27422. clearTimeout(timerId);
  27423. timerId = setTimeout(timerExpired, wait);
  27424. return invokeFunc(lastCallTime);
  27425. }
  27426. }
  27427. if (timerId === undefined) {
  27428. timerId = setTimeout(timerExpired, wait);
  27429. }
  27430. return result;
  27431. }
  27432. debounced.cancel = cancel;
  27433. debounced.flush = flush;
  27434. return debounced;
  27435. }
  27436. /**
  27437. * Defers invoking the `func` until the current call stack has cleared. Any
  27438. * additional arguments are provided to `func` when it's invoked.
  27439. *
  27440. * @static
  27441. * @memberOf _
  27442. * @since 0.1.0
  27443. * @category Function
  27444. * @param {Function} func The function to defer.
  27445. * @param {...*} [args] The arguments to invoke `func` with.
  27446. * @returns {number} Returns the timer id.
  27447. * @example
  27448. *
  27449. * _.defer(function(text) {
  27450. * console.log(text);
  27451. * }, 'deferred');
  27452. * // => Logs 'deferred' after one millisecond.
  27453. */
  27454. var defer = baseRest(function(func, args) {
  27455. return baseDelay(func, 1, args);
  27456. });
  27457. /**
  27458. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  27459. * provided to `func` when it's invoked.
  27460. *
  27461. * @static
  27462. * @memberOf _
  27463. * @since 0.1.0
  27464. * @category Function
  27465. * @param {Function} func The function to delay.
  27466. * @param {number} wait The number of milliseconds to delay invocation.
  27467. * @param {...*} [args] The arguments to invoke `func` with.
  27468. * @returns {number} Returns the timer id.
  27469. * @example
  27470. *
  27471. * _.delay(function(text) {
  27472. * console.log(text);
  27473. * }, 1000, 'later');
  27474. * // => Logs 'later' after one second.
  27475. */
  27476. var delay = baseRest(function(func, wait, args) {
  27477. return baseDelay(func, toNumber(wait) || 0, args);
  27478. });
  27479. /**
  27480. * Creates a function that invokes `func` with arguments reversed.
  27481. *
  27482. * @static
  27483. * @memberOf _
  27484. * @since 4.0.0
  27485. * @category Function
  27486. * @param {Function} func The function to flip arguments for.
  27487. * @returns {Function} Returns the new flipped function.
  27488. * @example
  27489. *
  27490. * var flipped = _.flip(function() {
  27491. * return _.toArray(arguments);
  27492. * });
  27493. *
  27494. * flipped('a', 'b', 'c', 'd');
  27495. * // => ['d', 'c', 'b', 'a']
  27496. */
  27497. function flip(func) {
  27498. return createWrap(func, WRAP_FLIP_FLAG);
  27499. }
  27500. /**
  27501. * Creates a function that memoizes the result of `func`. If `resolver` is
  27502. * provided, it determines the cache key for storing the result based on the
  27503. * arguments provided to the memoized function. By default, the first argument
  27504. * provided to the memoized function is used as the map cache key. The `func`
  27505. * is invoked with the `this` binding of the memoized function.
  27506. *
  27507. * **Note:** The cache is exposed as the `cache` property on the memoized
  27508. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  27509. * constructor with one whose instances implement the
  27510. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  27511. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  27512. *
  27513. * @static
  27514. * @memberOf _
  27515. * @since 0.1.0
  27516. * @category Function
  27517. * @param {Function} func The function to have its output memoized.
  27518. * @param {Function} [resolver] The function to resolve the cache key.
  27519. * @returns {Function} Returns the new memoized function.
  27520. * @example
  27521. *
  27522. * var object = { 'a': 1, 'b': 2 };
  27523. * var other = { 'c': 3, 'd': 4 };
  27524. *
  27525. * var values = _.memoize(_.values);
  27526. * values(object);
  27527. * // => [1, 2]
  27528. *
  27529. * values(other);
  27530. * // => [3, 4]
  27531. *
  27532. * object.a = 2;
  27533. * values(object);
  27534. * // => [1, 2]
  27535. *
  27536. * // Modify the result cache.
  27537. * values.cache.set(object, ['a', 'b']);
  27538. * values(object);
  27539. * // => ['a', 'b']
  27540. *
  27541. * // Replace `_.memoize.Cache`.
  27542. * _.memoize.Cache = WeakMap;
  27543. */
  27544. function memoize(func, resolver) {
  27545. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  27546. throw new TypeError(FUNC_ERROR_TEXT);
  27547. }
  27548. var memoized = function() {
  27549. var args = arguments,
  27550. key = resolver ? resolver.apply(this, args) : args[0],
  27551. cache = memoized.cache;
  27552. if (cache.has(key)) {
  27553. return cache.get(key);
  27554. }
  27555. var result = func.apply(this, args);
  27556. memoized.cache = cache.set(key, result) || cache;
  27557. return result;
  27558. };
  27559. memoized.cache = new (memoize.Cache || MapCache);
  27560. return memoized;
  27561. }
  27562. // Expose `MapCache`.
  27563. memoize.Cache = MapCache;
  27564. /**
  27565. * Creates a function that negates the result of the predicate `func`. The
  27566. * `func` predicate is invoked with the `this` binding and arguments of the
  27567. * created function.
  27568. *
  27569. * @static
  27570. * @memberOf _
  27571. * @since 3.0.0
  27572. * @category Function
  27573. * @param {Function} predicate The predicate to negate.
  27574. * @returns {Function} Returns the new negated function.
  27575. * @example
  27576. *
  27577. * function isEven(n) {
  27578. * return n % 2 == 0;
  27579. * }
  27580. *
  27581. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  27582. * // => [1, 3, 5]
  27583. */
  27584. function negate(predicate) {
  27585. if (typeof predicate != 'function') {
  27586. throw new TypeError(FUNC_ERROR_TEXT);
  27587. }
  27588. return function() {
  27589. var args = arguments;
  27590. switch (args.length) {
  27591. case 0: return !predicate.call(this);
  27592. case 1: return !predicate.call(this, args[0]);
  27593. case 2: return !predicate.call(this, args[0], args[1]);
  27594. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  27595. }
  27596. return !predicate.apply(this, args);
  27597. };
  27598. }
  27599. /**
  27600. * Creates a function that is restricted to invoking `func` once. Repeat calls
  27601. * to the function return the value of the first invocation. The `func` is
  27602. * invoked with the `this` binding and arguments of the created function.
  27603. *
  27604. * @static
  27605. * @memberOf _
  27606. * @since 0.1.0
  27607. * @category Function
  27608. * @param {Function} func The function to restrict.
  27609. * @returns {Function} Returns the new restricted function.
  27610. * @example
  27611. *
  27612. * var initialize = _.once(createApplication);
  27613. * initialize();
  27614. * initialize();
  27615. * // => `createApplication` is invoked once
  27616. */
  27617. function once(func) {
  27618. return before(2, func);
  27619. }
  27620. /**
  27621. * Creates a function that invokes `func` with its arguments transformed.
  27622. *
  27623. * @static
  27624. * @since 4.0.0
  27625. * @memberOf _
  27626. * @category Function
  27627. * @param {Function} func The function to wrap.
  27628. * @param {...(Function|Function[])} [transforms=[_.identity]]
  27629. * The argument transforms.
  27630. * @returns {Function} Returns the new function.
  27631. * @example
  27632. *
  27633. * function doubled(n) {
  27634. * return n * 2;
  27635. * }
  27636. *
  27637. * function square(n) {
  27638. * return n * n;
  27639. * }
  27640. *
  27641. * var func = _.overArgs(function(x, y) {
  27642. * return [x, y];
  27643. * }, [square, doubled]);
  27644. *
  27645. * func(9, 3);
  27646. * // => [81, 6]
  27647. *
  27648. * func(10, 5);
  27649. * // => [100, 10]
  27650. */
  27651. var overArgs = castRest(function(func, transforms) {
  27652. transforms = (transforms.length == 1 && isArray(transforms[0]))
  27653. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  27654. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  27655. var funcsLength = transforms.length;
  27656. return baseRest(function(args) {
  27657. var index = -1,
  27658. length = nativeMin(args.length, funcsLength);
  27659. while (++index < length) {
  27660. args[index] = transforms[index].call(this, args[index]);
  27661. }
  27662. return apply(func, this, args);
  27663. });
  27664. });
  27665. /**
  27666. * Creates a function that invokes `func` with `partials` prepended to the
  27667. * arguments it receives. This method is like `_.bind` except it does **not**
  27668. * alter the `this` binding.
  27669. *
  27670. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  27671. * builds, may be used as a placeholder for partially applied arguments.
  27672. *
  27673. * **Note:** This method doesn't set the "length" property of partially
  27674. * applied functions.
  27675. *
  27676. * @static
  27677. * @memberOf _
  27678. * @since 0.2.0
  27679. * @category Function
  27680. * @param {Function} func The function to partially apply arguments to.
  27681. * @param {...*} [partials] The arguments to be partially applied.
  27682. * @returns {Function} Returns the new partially applied function.
  27683. * @example
  27684. *
  27685. * function greet(greeting, name) {
  27686. * return greeting + ' ' + name;
  27687. * }
  27688. *
  27689. * var sayHelloTo = _.partial(greet, 'hello');
  27690. * sayHelloTo('fred');
  27691. * // => 'hello fred'
  27692. *
  27693. * // Partially applied with placeholders.
  27694. * var greetFred = _.partial(greet, _, 'fred');
  27695. * greetFred('hi');
  27696. * // => 'hi fred'
  27697. */
  27698. var partial = baseRest(function(func, partials) {
  27699. var holders = replaceHolders(partials, getHolder(partial));
  27700. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  27701. });
  27702. /**
  27703. * This method is like `_.partial` except that partially applied arguments
  27704. * are appended to the arguments it receives.
  27705. *
  27706. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  27707. * builds, may be used as a placeholder for partially applied arguments.
  27708. *
  27709. * **Note:** This method doesn't set the "length" property of partially
  27710. * applied functions.
  27711. *
  27712. * @static
  27713. * @memberOf _
  27714. * @since 1.0.0
  27715. * @category Function
  27716. * @param {Function} func The function to partially apply arguments to.
  27717. * @param {...*} [partials] The arguments to be partially applied.
  27718. * @returns {Function} Returns the new partially applied function.
  27719. * @example
  27720. *
  27721. * function greet(greeting, name) {
  27722. * return greeting + ' ' + name;
  27723. * }
  27724. *
  27725. * var greetFred = _.partialRight(greet, 'fred');
  27726. * greetFred('hi');
  27727. * // => 'hi fred'
  27728. *
  27729. * // Partially applied with placeholders.
  27730. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  27731. * sayHelloTo('fred');
  27732. * // => 'hello fred'
  27733. */
  27734. var partialRight = baseRest(function(func, partials) {
  27735. var holders = replaceHolders(partials, getHolder(partialRight));
  27736. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  27737. });
  27738. /**
  27739. * Creates a function that invokes `func` with arguments arranged according
  27740. * to the specified `indexes` where the argument value at the first index is
  27741. * provided as the first argument, the argument value at the second index is
  27742. * provided as the second argument, and so on.
  27743. *
  27744. * @static
  27745. * @memberOf _
  27746. * @since 3.0.0
  27747. * @category Function
  27748. * @param {Function} func The function to rearrange arguments for.
  27749. * @param {...(number|number[])} indexes The arranged argument indexes.
  27750. * @returns {Function} Returns the new function.
  27751. * @example
  27752. *
  27753. * var rearged = _.rearg(function(a, b, c) {
  27754. * return [a, b, c];
  27755. * }, [2, 0, 1]);
  27756. *
  27757. * rearged('b', 'c', 'a')
  27758. * // => ['a', 'b', 'c']
  27759. */
  27760. var rearg = flatRest(function(func, indexes) {
  27761. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  27762. });
  27763. /**
  27764. * Creates a function that invokes `func` with the `this` binding of the
  27765. * created function and arguments from `start` and beyond provided as
  27766. * an array.
  27767. *
  27768. * **Note:** This method is based on the
  27769. * [rest parameter](https://mdn.io/rest_parameters).
  27770. *
  27771. * @static
  27772. * @memberOf _
  27773. * @since 4.0.0
  27774. * @category Function
  27775. * @param {Function} func The function to apply a rest parameter to.
  27776. * @param {number} [start=func.length-1] The start position of the rest parameter.
  27777. * @returns {Function} Returns the new function.
  27778. * @example
  27779. *
  27780. * var say = _.rest(function(what, names) {
  27781. * return what + ' ' + _.initial(names).join(', ') +
  27782. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  27783. * });
  27784. *
  27785. * say('hello', 'fred', 'barney', 'pebbles');
  27786. * // => 'hello fred, barney, & pebbles'
  27787. */
  27788. function rest(func, start) {
  27789. if (typeof func != 'function') {
  27790. throw new TypeError(FUNC_ERROR_TEXT);
  27791. }
  27792. start = start === undefined ? start : toInteger(start);
  27793. return baseRest(func, start);
  27794. }
  27795. /**
  27796. * Creates a function that invokes `func` with the `this` binding of the
  27797. * create function and an array of arguments much like
  27798. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  27799. *
  27800. * **Note:** This method is based on the
  27801. * [spread operator](https://mdn.io/spread_operator).
  27802. *
  27803. * @static
  27804. * @memberOf _
  27805. * @since 3.2.0
  27806. * @category Function
  27807. * @param {Function} func The function to spread arguments over.
  27808. * @param {number} [start=0] The start position of the spread.
  27809. * @returns {Function} Returns the new function.
  27810. * @example
  27811. *
  27812. * var say = _.spread(function(who, what) {
  27813. * return who + ' says ' + what;
  27814. * });
  27815. *
  27816. * say(['fred', 'hello']);
  27817. * // => 'fred says hello'
  27818. *
  27819. * var numbers = Promise.all([
  27820. * Promise.resolve(40),
  27821. * Promise.resolve(36)
  27822. * ]);
  27823. *
  27824. * numbers.then(_.spread(function(x, y) {
  27825. * return x + y;
  27826. * }));
  27827. * // => a Promise of 76
  27828. */
  27829. function spread(func, start) {
  27830. if (typeof func != 'function') {
  27831. throw new TypeError(FUNC_ERROR_TEXT);
  27832. }
  27833. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  27834. return baseRest(function(args) {
  27835. var array = args[start],
  27836. otherArgs = castSlice(args, 0, start);
  27837. if (array) {
  27838. arrayPush(otherArgs, array);
  27839. }
  27840. return apply(func, this, otherArgs);
  27841. });
  27842. }
  27843. /**
  27844. * Creates a throttled function that only invokes `func` at most once per
  27845. * every `wait` milliseconds. The throttled function comes with a `cancel`
  27846. * method to cancel delayed `func` invocations and a `flush` method to
  27847. * immediately invoke them. Provide `options` to indicate whether `func`
  27848. * should be invoked on the leading and/or trailing edge of the `wait`
  27849. * timeout. The `func` is invoked with the last arguments provided to the
  27850. * throttled function. Subsequent calls to the throttled function return the
  27851. * result of the last `func` invocation.
  27852. *
  27853. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27854. * invoked on the trailing edge of the timeout only if the throttled function
  27855. * is invoked more than once during the `wait` timeout.
  27856. *
  27857. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27858. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27859. *
  27860. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27861. * for details over the differences between `_.throttle` and `_.debounce`.
  27862. *
  27863. * @static
  27864. * @memberOf _
  27865. * @since 0.1.0
  27866. * @category Function
  27867. * @param {Function} func The function to throttle.
  27868. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  27869. * @param {Object} [options={}] The options object.
  27870. * @param {boolean} [options.leading=true]
  27871. * Specify invoking on the leading edge of the timeout.
  27872. * @param {boolean} [options.trailing=true]
  27873. * Specify invoking on the trailing edge of the timeout.
  27874. * @returns {Function} Returns the new throttled function.
  27875. * @example
  27876. *
  27877. * // Avoid excessively updating the position while scrolling.
  27878. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  27879. *
  27880. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  27881. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  27882. * jQuery(element).on('click', throttled);
  27883. *
  27884. * // Cancel the trailing throttled invocation.
  27885. * jQuery(window).on('popstate', throttled.cancel);
  27886. */
  27887. function throttle(func, wait, options) {
  27888. var leading = true,
  27889. trailing = true;
  27890. if (typeof func != 'function') {
  27891. throw new TypeError(FUNC_ERROR_TEXT);
  27892. }
  27893. if (isObject(options)) {
  27894. leading = 'leading' in options ? !!options.leading : leading;
  27895. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27896. }
  27897. return debounce(func, wait, {
  27898. 'leading': leading,
  27899. 'maxWait': wait,
  27900. 'trailing': trailing
  27901. });
  27902. }
  27903. /**
  27904. * Creates a function that accepts up to one argument, ignoring any
  27905. * additional arguments.
  27906. *
  27907. * @static
  27908. * @memberOf _
  27909. * @since 4.0.0
  27910. * @category Function
  27911. * @param {Function} func The function to cap arguments for.
  27912. * @returns {Function} Returns the new capped function.
  27913. * @example
  27914. *
  27915. * _.map(['6', '8', '10'], _.unary(parseInt));
  27916. * // => [6, 8, 10]
  27917. */
  27918. function unary(func) {
  27919. return ary(func, 1);
  27920. }
  27921. /**
  27922. * Creates a function that provides `value` to `wrapper` as its first
  27923. * argument. Any additional arguments provided to the function are appended
  27924. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  27925. * binding of the created function.
  27926. *
  27927. * @static
  27928. * @memberOf _
  27929. * @since 0.1.0
  27930. * @category Function
  27931. * @param {*} value The value to wrap.
  27932. * @param {Function} [wrapper=identity] The wrapper function.
  27933. * @returns {Function} Returns the new function.
  27934. * @example
  27935. *
  27936. * var p = _.wrap(_.escape, function(func, text) {
  27937. * return '<p>' + func(text) + '</p>';
  27938. * });
  27939. *
  27940. * p('fred, barney, & pebbles');
  27941. * // => '<p>fred, barney, &amp; pebbles</p>'
  27942. */
  27943. function wrap(value, wrapper) {
  27944. return partial(castFunction(wrapper), value);
  27945. }
  27946. /*------------------------------------------------------------------------*/
  27947. /**
  27948. * Casts `value` as an array if it's not one.
  27949. *
  27950. * @static
  27951. * @memberOf _
  27952. * @since 4.4.0
  27953. * @category Lang
  27954. * @param {*} value The value to inspect.
  27955. * @returns {Array} Returns the cast array.
  27956. * @example
  27957. *
  27958. * _.castArray(1);
  27959. * // => [1]
  27960. *
  27961. * _.castArray({ 'a': 1 });
  27962. * // => [{ 'a': 1 }]
  27963. *
  27964. * _.castArray('abc');
  27965. * // => ['abc']
  27966. *
  27967. * _.castArray(null);
  27968. * // => [null]
  27969. *
  27970. * _.castArray(undefined);
  27971. * // => [undefined]
  27972. *
  27973. * _.castArray();
  27974. * // => []
  27975. *
  27976. * var array = [1, 2, 3];
  27977. * console.log(_.castArray(array) === array);
  27978. * // => true
  27979. */
  27980. function castArray() {
  27981. if (!arguments.length) {
  27982. return [];
  27983. }
  27984. var value = arguments[0];
  27985. return isArray(value) ? value : [value];
  27986. }
  27987. /**
  27988. * Creates a shallow clone of `value`.
  27989. *
  27990. * **Note:** This method is loosely based on the
  27991. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  27992. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  27993. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  27994. * arrays. The own enumerable properties of `arguments` objects are cloned
  27995. * as plain objects. An empty object is returned for uncloneable values such
  27996. * as error objects, functions, DOM nodes, and WeakMaps.
  27997. *
  27998. * @static
  27999. * @memberOf _
  28000. * @since 0.1.0
  28001. * @category Lang
  28002. * @param {*} value The value to clone.
  28003. * @returns {*} Returns the cloned value.
  28004. * @see _.cloneDeep
  28005. * @example
  28006. *
  28007. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28008. *
  28009. * var shallow = _.clone(objects);
  28010. * console.log(shallow[0] === objects[0]);
  28011. * // => true
  28012. */
  28013. function clone(value) {
  28014. return baseClone(value, CLONE_SYMBOLS_FLAG);
  28015. }
  28016. /**
  28017. * This method is like `_.clone` except that it accepts `customizer` which
  28018. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  28019. * cloning is handled by the method instead. The `customizer` is invoked with
  28020. * up to four arguments; (value [, index|key, object, stack]).
  28021. *
  28022. * @static
  28023. * @memberOf _
  28024. * @since 4.0.0
  28025. * @category Lang
  28026. * @param {*} value The value to clone.
  28027. * @param {Function} [customizer] The function to customize cloning.
  28028. * @returns {*} Returns the cloned value.
  28029. * @see _.cloneDeepWith
  28030. * @example
  28031. *
  28032. * function customizer(value) {
  28033. * if (_.isElement(value)) {
  28034. * return value.cloneNode(false);
  28035. * }
  28036. * }
  28037. *
  28038. * var el = _.cloneWith(document.body, customizer);
  28039. *
  28040. * console.log(el === document.body);
  28041. * // => false
  28042. * console.log(el.nodeName);
  28043. * // => 'BODY'
  28044. * console.log(el.childNodes.length);
  28045. * // => 0
  28046. */
  28047. function cloneWith(value, customizer) {
  28048. customizer = typeof customizer == 'function' ? customizer : undefined;
  28049. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  28050. }
  28051. /**
  28052. * This method is like `_.clone` except that it recursively clones `value`.
  28053. *
  28054. * @static
  28055. * @memberOf _
  28056. * @since 1.0.0
  28057. * @category Lang
  28058. * @param {*} value The value to recursively clone.
  28059. * @returns {*} Returns the deep cloned value.
  28060. * @see _.clone
  28061. * @example
  28062. *
  28063. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28064. *
  28065. * var deep = _.cloneDeep(objects);
  28066. * console.log(deep[0] === objects[0]);
  28067. * // => false
  28068. */
  28069. function cloneDeep(value) {
  28070. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  28071. }
  28072. /**
  28073. * This method is like `_.cloneWith` except that it recursively clones `value`.
  28074. *
  28075. * @static
  28076. * @memberOf _
  28077. * @since 4.0.0
  28078. * @category Lang
  28079. * @param {*} value The value to recursively clone.
  28080. * @param {Function} [customizer] The function to customize cloning.
  28081. * @returns {*} Returns the deep cloned value.
  28082. * @see _.cloneWith
  28083. * @example
  28084. *
  28085. * function customizer(value) {
  28086. * if (_.isElement(value)) {
  28087. * return value.cloneNode(true);
  28088. * }
  28089. * }
  28090. *
  28091. * var el = _.cloneDeepWith(document.body, customizer);
  28092. *
  28093. * console.log(el === document.body);
  28094. * // => false
  28095. * console.log(el.nodeName);
  28096. * // => 'BODY'
  28097. * console.log(el.childNodes.length);
  28098. * // => 20
  28099. */
  28100. function cloneDeepWith(value, customizer) {
  28101. customizer = typeof customizer == 'function' ? customizer : undefined;
  28102. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  28103. }
  28104. /**
  28105. * Checks if `object` conforms to `source` by invoking the predicate
  28106. * properties of `source` with the corresponding property values of `object`.
  28107. *
  28108. * **Note:** This method is equivalent to `_.conforms` when `source` is
  28109. * partially applied.
  28110. *
  28111. * @static
  28112. * @memberOf _
  28113. * @since 4.14.0
  28114. * @category Lang
  28115. * @param {Object} object The object to inspect.
  28116. * @param {Object} source The object of property predicates to conform to.
  28117. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  28118. * @example
  28119. *
  28120. * var object = { 'a': 1, 'b': 2 };
  28121. *
  28122. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  28123. * // => true
  28124. *
  28125. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  28126. * // => false
  28127. */
  28128. function conformsTo(object, source) {
  28129. return source == null || baseConformsTo(object, source, keys(source));
  28130. }
  28131. /**
  28132. * Performs a
  28133. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  28134. * comparison between two values to determine if they are equivalent.
  28135. *
  28136. * @static
  28137. * @memberOf _
  28138. * @since 4.0.0
  28139. * @category Lang
  28140. * @param {*} value The value to compare.
  28141. * @param {*} other The other value to compare.
  28142. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28143. * @example
  28144. *
  28145. * var object = { 'a': 1 };
  28146. * var other = { 'a': 1 };
  28147. *
  28148. * _.eq(object, object);
  28149. * // => true
  28150. *
  28151. * _.eq(object, other);
  28152. * // => false
  28153. *
  28154. * _.eq('a', 'a');
  28155. * // => true
  28156. *
  28157. * _.eq('a', Object('a'));
  28158. * // => false
  28159. *
  28160. * _.eq(NaN, NaN);
  28161. * // => true
  28162. */
  28163. function eq(value, other) {
  28164. return value === other || (value !== value && other !== other);
  28165. }
  28166. /**
  28167. * Checks if `value` is greater than `other`.
  28168. *
  28169. * @static
  28170. * @memberOf _
  28171. * @since 3.9.0
  28172. * @category Lang
  28173. * @param {*} value The value to compare.
  28174. * @param {*} other The other value to compare.
  28175. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  28176. * else `false`.
  28177. * @see _.lt
  28178. * @example
  28179. *
  28180. * _.gt(3, 1);
  28181. * // => true
  28182. *
  28183. * _.gt(3, 3);
  28184. * // => false
  28185. *
  28186. * _.gt(1, 3);
  28187. * // => false
  28188. */
  28189. var gt = createRelationalOperation(baseGt);
  28190. /**
  28191. * Checks if `value` is greater than or equal to `other`.
  28192. *
  28193. * @static
  28194. * @memberOf _
  28195. * @since 3.9.0
  28196. * @category Lang
  28197. * @param {*} value The value to compare.
  28198. * @param {*} other The other value to compare.
  28199. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  28200. * `other`, else `false`.
  28201. * @see _.lte
  28202. * @example
  28203. *
  28204. * _.gte(3, 1);
  28205. * // => true
  28206. *
  28207. * _.gte(3, 3);
  28208. * // => true
  28209. *
  28210. * _.gte(1, 3);
  28211. * // => false
  28212. */
  28213. var gte = createRelationalOperation(function(value, other) {
  28214. return value >= other;
  28215. });
  28216. /**
  28217. * Checks if `value` is likely an `arguments` object.
  28218. *
  28219. * @static
  28220. * @memberOf _
  28221. * @since 0.1.0
  28222. * @category Lang
  28223. * @param {*} value The value to check.
  28224. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  28225. * else `false`.
  28226. * @example
  28227. *
  28228. * _.isArguments(function() { return arguments; }());
  28229. * // => true
  28230. *
  28231. * _.isArguments([1, 2, 3]);
  28232. * // => false
  28233. */
  28234. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  28235. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  28236. !propertyIsEnumerable.call(value, 'callee');
  28237. };
  28238. /**
  28239. * Checks if `value` is classified as an `Array` object.
  28240. *
  28241. * @static
  28242. * @memberOf _
  28243. * @since 0.1.0
  28244. * @category Lang
  28245. * @param {*} value The value to check.
  28246. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  28247. * @example
  28248. *
  28249. * _.isArray([1, 2, 3]);
  28250. * // => true
  28251. *
  28252. * _.isArray(document.body.children);
  28253. * // => false
  28254. *
  28255. * _.isArray('abc');
  28256. * // => false
  28257. *
  28258. * _.isArray(_.noop);
  28259. * // => false
  28260. */
  28261. var isArray = Array.isArray;
  28262. /**
  28263. * Checks if `value` is classified as an `ArrayBuffer` object.
  28264. *
  28265. * @static
  28266. * @memberOf _
  28267. * @since 4.3.0
  28268. * @category Lang
  28269. * @param {*} value The value to check.
  28270. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  28271. * @example
  28272. *
  28273. * _.isArrayBuffer(new ArrayBuffer(2));
  28274. * // => true
  28275. *
  28276. * _.isArrayBuffer(new Array(2));
  28277. * // => false
  28278. */
  28279. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  28280. /**
  28281. * Checks if `value` is array-like. A value is considered array-like if it's
  28282. * not a function and has a `value.length` that's an integer greater than or
  28283. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  28284. *
  28285. * @static
  28286. * @memberOf _
  28287. * @since 4.0.0
  28288. * @category Lang
  28289. * @param {*} value The value to check.
  28290. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  28291. * @example
  28292. *
  28293. * _.isArrayLike([1, 2, 3]);
  28294. * // => true
  28295. *
  28296. * _.isArrayLike(document.body.children);
  28297. * // => true
  28298. *
  28299. * _.isArrayLike('abc');
  28300. * // => true
  28301. *
  28302. * _.isArrayLike(_.noop);
  28303. * // => false
  28304. */
  28305. function isArrayLike(value) {
  28306. return value != null && isLength(value.length) && !isFunction(value);
  28307. }
  28308. /**
  28309. * This method is like `_.isArrayLike` except that it also checks if `value`
  28310. * is an object.
  28311. *
  28312. * @static
  28313. * @memberOf _
  28314. * @since 4.0.0
  28315. * @category Lang
  28316. * @param {*} value The value to check.
  28317. * @returns {boolean} Returns `true` if `value` is an array-like object,
  28318. * else `false`.
  28319. * @example
  28320. *
  28321. * _.isArrayLikeObject([1, 2, 3]);
  28322. * // => true
  28323. *
  28324. * _.isArrayLikeObject(document.body.children);
  28325. * // => true
  28326. *
  28327. * _.isArrayLikeObject('abc');
  28328. * // => false
  28329. *
  28330. * _.isArrayLikeObject(_.noop);
  28331. * // => false
  28332. */
  28333. function isArrayLikeObject(value) {
  28334. return isObjectLike(value) && isArrayLike(value);
  28335. }
  28336. /**
  28337. * Checks if `value` is classified as a boolean primitive or object.
  28338. *
  28339. * @static
  28340. * @memberOf _
  28341. * @since 0.1.0
  28342. * @category Lang
  28343. * @param {*} value The value to check.
  28344. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  28345. * @example
  28346. *
  28347. * _.isBoolean(false);
  28348. * // => true
  28349. *
  28350. * _.isBoolean(null);
  28351. * // => false
  28352. */
  28353. function isBoolean(value) {
  28354. return value === true || value === false ||
  28355. (isObjectLike(value) && baseGetTag(value) == boolTag);
  28356. }
  28357. /**
  28358. * Checks if `value` is a buffer.
  28359. *
  28360. * @static
  28361. * @memberOf _
  28362. * @since 4.3.0
  28363. * @category Lang
  28364. * @param {*} value The value to check.
  28365. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  28366. * @example
  28367. *
  28368. * _.isBuffer(new Buffer(2));
  28369. * // => true
  28370. *
  28371. * _.isBuffer(new Uint8Array(2));
  28372. * // => false
  28373. */
  28374. var isBuffer = nativeIsBuffer || stubFalse;
  28375. /**
  28376. * Checks if `value` is classified as a `Date` object.
  28377. *
  28378. * @static
  28379. * @memberOf _
  28380. * @since 0.1.0
  28381. * @category Lang
  28382. * @param {*} value The value to check.
  28383. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  28384. * @example
  28385. *
  28386. * _.isDate(new Date);
  28387. * // => true
  28388. *
  28389. * _.isDate('Mon April 23 2012');
  28390. * // => false
  28391. */
  28392. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  28393. /**
  28394. * Checks if `value` is likely a DOM element.
  28395. *
  28396. * @static
  28397. * @memberOf _
  28398. * @since 0.1.0
  28399. * @category Lang
  28400. * @param {*} value The value to check.
  28401. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  28402. * @example
  28403. *
  28404. * _.isElement(document.body);
  28405. * // => true
  28406. *
  28407. * _.isElement('<body>');
  28408. * // => false
  28409. */
  28410. function isElement(value) {
  28411. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  28412. }
  28413. /**
  28414. * Checks if `value` is an empty object, collection, map, or set.
  28415. *
  28416. * Objects are considered empty if they have no own enumerable string keyed
  28417. * properties.
  28418. *
  28419. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  28420. * jQuery-like collections are considered empty if they have a `length` of `0`.
  28421. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  28422. *
  28423. * @static
  28424. * @memberOf _
  28425. * @since 0.1.0
  28426. * @category Lang
  28427. * @param {*} value The value to check.
  28428. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  28429. * @example
  28430. *
  28431. * _.isEmpty(null);
  28432. * // => true
  28433. *
  28434. * _.isEmpty(true);
  28435. * // => true
  28436. *
  28437. * _.isEmpty(1);
  28438. * // => true
  28439. *
  28440. * _.isEmpty([1, 2, 3]);
  28441. * // => false
  28442. *
  28443. * _.isEmpty({ 'a': 1 });
  28444. * // => false
  28445. */
  28446. function isEmpty(value) {
  28447. if (value == null) {
  28448. return true;
  28449. }
  28450. if (isArrayLike(value) &&
  28451. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  28452. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  28453. return !value.length;
  28454. }
  28455. var tag = getTag(value);
  28456. if (tag == mapTag || tag == setTag) {
  28457. return !value.size;
  28458. }
  28459. if (isPrototype(value)) {
  28460. return !baseKeys(value).length;
  28461. }
  28462. for (var key in value) {
  28463. if (hasOwnProperty.call(value, key)) {
  28464. return false;
  28465. }
  28466. }
  28467. return true;
  28468. }
  28469. /**
  28470. * Performs a deep comparison between two values to determine if they are
  28471. * equivalent.
  28472. *
  28473. * **Note:** This method supports comparing arrays, array buffers, booleans,
  28474. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  28475. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  28476. * by their own, not inherited, enumerable properties. Functions and DOM
  28477. * nodes are compared by strict equality, i.e. `===`.
  28478. *
  28479. * @static
  28480. * @memberOf _
  28481. * @since 0.1.0
  28482. * @category Lang
  28483. * @param {*} value The value to compare.
  28484. * @param {*} other The other value to compare.
  28485. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28486. * @example
  28487. *
  28488. * var object = { 'a': 1 };
  28489. * var other = { 'a': 1 };
  28490. *
  28491. * _.isEqual(object, other);
  28492. * // => true
  28493. *
  28494. * object === other;
  28495. * // => false
  28496. */
  28497. function isEqual(value, other) {
  28498. return baseIsEqual(value, other);
  28499. }
  28500. /**
  28501. * This method is like `_.isEqual` except that it accepts `customizer` which
  28502. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28503. * are handled by the method instead. The `customizer` is invoked with up to
  28504. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  28505. *
  28506. * @static
  28507. * @memberOf _
  28508. * @since 4.0.0
  28509. * @category Lang
  28510. * @param {*} value The value to compare.
  28511. * @param {*} other The other value to compare.
  28512. * @param {Function} [customizer] The function to customize comparisons.
  28513. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28514. * @example
  28515. *
  28516. * function isGreeting(value) {
  28517. * return /^h(?:i|ello)$/.test(value);
  28518. * }
  28519. *
  28520. * function customizer(objValue, othValue) {
  28521. * if (isGreeting(objValue) && isGreeting(othValue)) {
  28522. * return true;
  28523. * }
  28524. * }
  28525. *
  28526. * var array = ['hello', 'goodbye'];
  28527. * var other = ['hi', 'goodbye'];
  28528. *
  28529. * _.isEqualWith(array, other, customizer);
  28530. * // => true
  28531. */
  28532. function isEqualWith(value, other, customizer) {
  28533. customizer = typeof customizer == 'function' ? customizer : undefined;
  28534. var result = customizer ? customizer(value, other) : undefined;
  28535. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  28536. }
  28537. /**
  28538. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  28539. * `SyntaxError`, `TypeError`, or `URIError` object.
  28540. *
  28541. * @static
  28542. * @memberOf _
  28543. * @since 3.0.0
  28544. * @category Lang
  28545. * @param {*} value The value to check.
  28546. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  28547. * @example
  28548. *
  28549. * _.isError(new Error);
  28550. * // => true
  28551. *
  28552. * _.isError(Error);
  28553. * // => false
  28554. */
  28555. function isError(value) {
  28556. if (!isObjectLike(value)) {
  28557. return false;
  28558. }
  28559. var tag = baseGetTag(value);
  28560. return tag == errorTag || tag == domExcTag ||
  28561. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  28562. }
  28563. /**
  28564. * Checks if `value` is a finite primitive number.
  28565. *
  28566. * **Note:** This method is based on
  28567. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  28568. *
  28569. * @static
  28570. * @memberOf _
  28571. * @since 0.1.0
  28572. * @category Lang
  28573. * @param {*} value The value to check.
  28574. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  28575. * @example
  28576. *
  28577. * _.isFinite(3);
  28578. * // => true
  28579. *
  28580. * _.isFinite(Number.MIN_VALUE);
  28581. * // => true
  28582. *
  28583. * _.isFinite(Infinity);
  28584. * // => false
  28585. *
  28586. * _.isFinite('3');
  28587. * // => false
  28588. */
  28589. function isFinite(value) {
  28590. return typeof value == 'number' && nativeIsFinite(value);
  28591. }
  28592. /**
  28593. * Checks if `value` is classified as a `Function` object.
  28594. *
  28595. * @static
  28596. * @memberOf _
  28597. * @since 0.1.0
  28598. * @category Lang
  28599. * @param {*} value The value to check.
  28600. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  28601. * @example
  28602. *
  28603. * _.isFunction(_);
  28604. * // => true
  28605. *
  28606. * _.isFunction(/abc/);
  28607. * // => false
  28608. */
  28609. function isFunction(value) {
  28610. if (!isObject(value)) {
  28611. return false;
  28612. }
  28613. // The use of `Object#toString` avoids issues with the `typeof` operator
  28614. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  28615. var tag = baseGetTag(value);
  28616. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  28617. }
  28618. /**
  28619. * Checks if `value` is an integer.
  28620. *
  28621. * **Note:** This method is based on
  28622. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  28623. *
  28624. * @static
  28625. * @memberOf _
  28626. * @since 4.0.0
  28627. * @category Lang
  28628. * @param {*} value The value to check.
  28629. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  28630. * @example
  28631. *
  28632. * _.isInteger(3);
  28633. * // => true
  28634. *
  28635. * _.isInteger(Number.MIN_VALUE);
  28636. * // => false
  28637. *
  28638. * _.isInteger(Infinity);
  28639. * // => false
  28640. *
  28641. * _.isInteger('3');
  28642. * // => false
  28643. */
  28644. function isInteger(value) {
  28645. return typeof value == 'number' && value == toInteger(value);
  28646. }
  28647. /**
  28648. * Checks if `value` is a valid array-like length.
  28649. *
  28650. * **Note:** This method is loosely based on
  28651. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28652. *
  28653. * @static
  28654. * @memberOf _
  28655. * @since 4.0.0
  28656. * @category Lang
  28657. * @param {*} value The value to check.
  28658. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  28659. * @example
  28660. *
  28661. * _.isLength(3);
  28662. * // => true
  28663. *
  28664. * _.isLength(Number.MIN_VALUE);
  28665. * // => false
  28666. *
  28667. * _.isLength(Infinity);
  28668. * // => false
  28669. *
  28670. * _.isLength('3');
  28671. * // => false
  28672. */
  28673. function isLength(value) {
  28674. return typeof value == 'number' &&
  28675. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  28676. }
  28677. /**
  28678. * Checks if `value` is the
  28679. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  28680. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  28681. *
  28682. * @static
  28683. * @memberOf _
  28684. * @since 0.1.0
  28685. * @category Lang
  28686. * @param {*} value The value to check.
  28687. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  28688. * @example
  28689. *
  28690. * _.isObject({});
  28691. * // => true
  28692. *
  28693. * _.isObject([1, 2, 3]);
  28694. * // => true
  28695. *
  28696. * _.isObject(_.noop);
  28697. * // => true
  28698. *
  28699. * _.isObject(null);
  28700. * // => false
  28701. */
  28702. function isObject(value) {
  28703. var type = typeof value;
  28704. return value != null && (type == 'object' || type == 'function');
  28705. }
  28706. /**
  28707. * Checks if `value` is object-like. A value is object-like if it's not `null`
  28708. * and has a `typeof` result of "object".
  28709. *
  28710. * @static
  28711. * @memberOf _
  28712. * @since 4.0.0
  28713. * @category Lang
  28714. * @param {*} value The value to check.
  28715. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  28716. * @example
  28717. *
  28718. * _.isObjectLike({});
  28719. * // => true
  28720. *
  28721. * _.isObjectLike([1, 2, 3]);
  28722. * // => true
  28723. *
  28724. * _.isObjectLike(_.noop);
  28725. * // => false
  28726. *
  28727. * _.isObjectLike(null);
  28728. * // => false
  28729. */
  28730. function isObjectLike(value) {
  28731. return value != null && typeof value == 'object';
  28732. }
  28733. /**
  28734. * Checks if `value` is classified as a `Map` object.
  28735. *
  28736. * @static
  28737. * @memberOf _
  28738. * @since 4.3.0
  28739. * @category Lang
  28740. * @param {*} value The value to check.
  28741. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  28742. * @example
  28743. *
  28744. * _.isMap(new Map);
  28745. * // => true
  28746. *
  28747. * _.isMap(new WeakMap);
  28748. * // => false
  28749. */
  28750. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  28751. /**
  28752. * Performs a partial deep comparison between `object` and `source` to
  28753. * determine if `object` contains equivalent property values.
  28754. *
  28755. * **Note:** This method is equivalent to `_.matches` when `source` is
  28756. * partially applied.
  28757. *
  28758. * Partial comparisons will match empty array and empty object `source`
  28759. * values against any array or object value, respectively. See `_.isEqual`
  28760. * for a list of supported value comparisons.
  28761. *
  28762. * @static
  28763. * @memberOf _
  28764. * @since 3.0.0
  28765. * @category Lang
  28766. * @param {Object} object The object to inspect.
  28767. * @param {Object} source The object of property values to match.
  28768. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28769. * @example
  28770. *
  28771. * var object = { 'a': 1, 'b': 2 };
  28772. *
  28773. * _.isMatch(object, { 'b': 2 });
  28774. * // => true
  28775. *
  28776. * _.isMatch(object, { 'b': 1 });
  28777. * // => false
  28778. */
  28779. function isMatch(object, source) {
  28780. return object === source || baseIsMatch(object, source, getMatchData(source));
  28781. }
  28782. /**
  28783. * This method is like `_.isMatch` except that it accepts `customizer` which
  28784. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28785. * are handled by the method instead. The `customizer` is invoked with five
  28786. * arguments: (objValue, srcValue, index|key, object, source).
  28787. *
  28788. * @static
  28789. * @memberOf _
  28790. * @since 4.0.0
  28791. * @category Lang
  28792. * @param {Object} object The object to inspect.
  28793. * @param {Object} source The object of property values to match.
  28794. * @param {Function} [customizer] The function to customize comparisons.
  28795. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28796. * @example
  28797. *
  28798. * function isGreeting(value) {
  28799. * return /^h(?:i|ello)$/.test(value);
  28800. * }
  28801. *
  28802. * function customizer(objValue, srcValue) {
  28803. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  28804. * return true;
  28805. * }
  28806. * }
  28807. *
  28808. * var object = { 'greeting': 'hello' };
  28809. * var source = { 'greeting': 'hi' };
  28810. *
  28811. * _.isMatchWith(object, source, customizer);
  28812. * // => true
  28813. */
  28814. function isMatchWith(object, source, customizer) {
  28815. customizer = typeof customizer == 'function' ? customizer : undefined;
  28816. return baseIsMatch(object, source, getMatchData(source), customizer);
  28817. }
  28818. /**
  28819. * Checks if `value` is `NaN`.
  28820. *
  28821. * **Note:** This method is based on
  28822. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  28823. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  28824. * `undefined` and other non-number values.
  28825. *
  28826. * @static
  28827. * @memberOf _
  28828. * @since 0.1.0
  28829. * @category Lang
  28830. * @param {*} value The value to check.
  28831. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  28832. * @example
  28833. *
  28834. * _.isNaN(NaN);
  28835. * // => true
  28836. *
  28837. * _.isNaN(new Number(NaN));
  28838. * // => true
  28839. *
  28840. * isNaN(undefined);
  28841. * // => true
  28842. *
  28843. * _.isNaN(undefined);
  28844. * // => false
  28845. */
  28846. function isNaN(value) {
  28847. // An `NaN` primitive is the only value that is not equal to itself.
  28848. // Perform the `toStringTag` check first to avoid errors with some
  28849. // ActiveX objects in IE.
  28850. return isNumber(value) && value != +value;
  28851. }
  28852. /**
  28853. * Checks if `value` is a pristine native function.
  28854. *
  28855. * **Note:** This method can't reliably detect native functions in the presence
  28856. * of the core-js package because core-js circumvents this kind of detection.
  28857. * Despite multiple requests, the core-js maintainer has made it clear: any
  28858. * attempt to fix the detection will be obstructed. As a result, we're left
  28859. * with little choice but to throw an error. Unfortunately, this also affects
  28860. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  28861. * which rely on core-js.
  28862. *
  28863. * @static
  28864. * @memberOf _
  28865. * @since 3.0.0
  28866. * @category Lang
  28867. * @param {*} value The value to check.
  28868. * @returns {boolean} Returns `true` if `value` is a native function,
  28869. * else `false`.
  28870. * @example
  28871. *
  28872. * _.isNative(Array.prototype.push);
  28873. * // => true
  28874. *
  28875. * _.isNative(_);
  28876. * // => false
  28877. */
  28878. function isNative(value) {
  28879. if (isMaskable(value)) {
  28880. throw new Error(CORE_ERROR_TEXT);
  28881. }
  28882. return baseIsNative(value);
  28883. }
  28884. /**
  28885. * Checks if `value` is `null`.
  28886. *
  28887. * @static
  28888. * @memberOf _
  28889. * @since 0.1.0
  28890. * @category Lang
  28891. * @param {*} value The value to check.
  28892. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  28893. * @example
  28894. *
  28895. * _.isNull(null);
  28896. * // => true
  28897. *
  28898. * _.isNull(void 0);
  28899. * // => false
  28900. */
  28901. function isNull(value) {
  28902. return value === null;
  28903. }
  28904. /**
  28905. * Checks if `value` is `null` or `undefined`.
  28906. *
  28907. * @static
  28908. * @memberOf _
  28909. * @since 4.0.0
  28910. * @category Lang
  28911. * @param {*} value The value to check.
  28912. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  28913. * @example
  28914. *
  28915. * _.isNil(null);
  28916. * // => true
  28917. *
  28918. * _.isNil(void 0);
  28919. * // => true
  28920. *
  28921. * _.isNil(NaN);
  28922. * // => false
  28923. */
  28924. function isNil(value) {
  28925. return value == null;
  28926. }
  28927. /**
  28928. * Checks if `value` is classified as a `Number` primitive or object.
  28929. *
  28930. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  28931. * classified as numbers, use the `_.isFinite` method.
  28932. *
  28933. * @static
  28934. * @memberOf _
  28935. * @since 0.1.0
  28936. * @category Lang
  28937. * @param {*} value The value to check.
  28938. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  28939. * @example
  28940. *
  28941. * _.isNumber(3);
  28942. * // => true
  28943. *
  28944. * _.isNumber(Number.MIN_VALUE);
  28945. * // => true
  28946. *
  28947. * _.isNumber(Infinity);
  28948. * // => true
  28949. *
  28950. * _.isNumber('3');
  28951. * // => false
  28952. */
  28953. function isNumber(value) {
  28954. return typeof value == 'number' ||
  28955. (isObjectLike(value) && baseGetTag(value) == numberTag);
  28956. }
  28957. /**
  28958. * Checks if `value` is a plain object, that is, an object created by the
  28959. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  28960. *
  28961. * @static
  28962. * @memberOf _
  28963. * @since 0.8.0
  28964. * @category Lang
  28965. * @param {*} value The value to check.
  28966. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  28967. * @example
  28968. *
  28969. * function Foo() {
  28970. * this.a = 1;
  28971. * }
  28972. *
  28973. * _.isPlainObject(new Foo);
  28974. * // => false
  28975. *
  28976. * _.isPlainObject([1, 2, 3]);
  28977. * // => false
  28978. *
  28979. * _.isPlainObject({ 'x': 0, 'y': 0 });
  28980. * // => true
  28981. *
  28982. * _.isPlainObject(Object.create(null));
  28983. * // => true
  28984. */
  28985. function isPlainObject(value) {
  28986. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  28987. return false;
  28988. }
  28989. var proto = getPrototype(value);
  28990. if (proto === null) {
  28991. return true;
  28992. }
  28993. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  28994. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  28995. funcToString.call(Ctor) == objectCtorString;
  28996. }
  28997. /**
  28998. * Checks if `value` is classified as a `RegExp` object.
  28999. *
  29000. * @static
  29001. * @memberOf _
  29002. * @since 0.1.0
  29003. * @category Lang
  29004. * @param {*} value The value to check.
  29005. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  29006. * @example
  29007. *
  29008. * _.isRegExp(/abc/);
  29009. * // => true
  29010. *
  29011. * _.isRegExp('/abc/');
  29012. * // => false
  29013. */
  29014. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  29015. /**
  29016. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  29017. * double precision number which isn't the result of a rounded unsafe integer.
  29018. *
  29019. * **Note:** This method is based on
  29020. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  29021. *
  29022. * @static
  29023. * @memberOf _
  29024. * @since 4.0.0
  29025. * @category Lang
  29026. * @param {*} value The value to check.
  29027. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  29028. * @example
  29029. *
  29030. * _.isSafeInteger(3);
  29031. * // => true
  29032. *
  29033. * _.isSafeInteger(Number.MIN_VALUE);
  29034. * // => false
  29035. *
  29036. * _.isSafeInteger(Infinity);
  29037. * // => false
  29038. *
  29039. * _.isSafeInteger('3');
  29040. * // => false
  29041. */
  29042. function isSafeInteger(value) {
  29043. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  29044. }
  29045. /**
  29046. * Checks if `value` is classified as a `Set` object.
  29047. *
  29048. * @static
  29049. * @memberOf _
  29050. * @since 4.3.0
  29051. * @category Lang
  29052. * @param {*} value The value to check.
  29053. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  29054. * @example
  29055. *
  29056. * _.isSet(new Set);
  29057. * // => true
  29058. *
  29059. * _.isSet(new WeakSet);
  29060. * // => false
  29061. */
  29062. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  29063. /**
  29064. * Checks if `value` is classified as a `String` primitive or object.
  29065. *
  29066. * @static
  29067. * @since 0.1.0
  29068. * @memberOf _
  29069. * @category Lang
  29070. * @param {*} value The value to check.
  29071. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  29072. * @example
  29073. *
  29074. * _.isString('abc');
  29075. * // => true
  29076. *
  29077. * _.isString(1);
  29078. * // => false
  29079. */
  29080. function isString(value) {
  29081. return typeof value == 'string' ||
  29082. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  29083. }
  29084. /**
  29085. * Checks if `value` is classified as a `Symbol` primitive or object.
  29086. *
  29087. * @static
  29088. * @memberOf _
  29089. * @since 4.0.0
  29090. * @category Lang
  29091. * @param {*} value The value to check.
  29092. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  29093. * @example
  29094. *
  29095. * _.isSymbol(Symbol.iterator);
  29096. * // => true
  29097. *
  29098. * _.isSymbol('abc');
  29099. * // => false
  29100. */
  29101. function isSymbol(value) {
  29102. return typeof value == 'symbol' ||
  29103. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  29104. }
  29105. /**
  29106. * Checks if `value` is classified as a typed array.
  29107. *
  29108. * @static
  29109. * @memberOf _
  29110. * @since 3.0.0
  29111. * @category Lang
  29112. * @param {*} value The value to check.
  29113. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  29114. * @example
  29115. *
  29116. * _.isTypedArray(new Uint8Array);
  29117. * // => true
  29118. *
  29119. * _.isTypedArray([]);
  29120. * // => false
  29121. */
  29122. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  29123. /**
  29124. * Checks if `value` is `undefined`.
  29125. *
  29126. * @static
  29127. * @since 0.1.0
  29128. * @memberOf _
  29129. * @category Lang
  29130. * @param {*} value The value to check.
  29131. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  29132. * @example
  29133. *
  29134. * _.isUndefined(void 0);
  29135. * // => true
  29136. *
  29137. * _.isUndefined(null);
  29138. * // => false
  29139. */
  29140. function isUndefined(value) {
  29141. return value === undefined;
  29142. }
  29143. /**
  29144. * Checks if `value` is classified as a `WeakMap` object.
  29145. *
  29146. * @static
  29147. * @memberOf _
  29148. * @since 4.3.0
  29149. * @category Lang
  29150. * @param {*} value The value to check.
  29151. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  29152. * @example
  29153. *
  29154. * _.isWeakMap(new WeakMap);
  29155. * // => true
  29156. *
  29157. * _.isWeakMap(new Map);
  29158. * // => false
  29159. */
  29160. function isWeakMap(value) {
  29161. return isObjectLike(value) && getTag(value) == weakMapTag;
  29162. }
  29163. /**
  29164. * Checks if `value` is classified as a `WeakSet` object.
  29165. *
  29166. * @static
  29167. * @memberOf _
  29168. * @since 4.3.0
  29169. * @category Lang
  29170. * @param {*} value The value to check.
  29171. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  29172. * @example
  29173. *
  29174. * _.isWeakSet(new WeakSet);
  29175. * // => true
  29176. *
  29177. * _.isWeakSet(new Set);
  29178. * // => false
  29179. */
  29180. function isWeakSet(value) {
  29181. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  29182. }
  29183. /**
  29184. * Checks if `value` is less than `other`.
  29185. *
  29186. * @static
  29187. * @memberOf _
  29188. * @since 3.9.0
  29189. * @category Lang
  29190. * @param {*} value The value to compare.
  29191. * @param {*} other The other value to compare.
  29192. * @returns {boolean} Returns `true` if `value` is less than `other`,
  29193. * else `false`.
  29194. * @see _.gt
  29195. * @example
  29196. *
  29197. * _.lt(1, 3);
  29198. * // => true
  29199. *
  29200. * _.lt(3, 3);
  29201. * // => false
  29202. *
  29203. * _.lt(3, 1);
  29204. * // => false
  29205. */
  29206. var lt = createRelationalOperation(baseLt);
  29207. /**
  29208. * Checks if `value` is less than or equal to `other`.
  29209. *
  29210. * @static
  29211. * @memberOf _
  29212. * @since 3.9.0
  29213. * @category Lang
  29214. * @param {*} value The value to compare.
  29215. * @param {*} other The other value to compare.
  29216. * @returns {boolean} Returns `true` if `value` is less than or equal to
  29217. * `other`, else `false`.
  29218. * @see _.gte
  29219. * @example
  29220. *
  29221. * _.lte(1, 3);
  29222. * // => true
  29223. *
  29224. * _.lte(3, 3);
  29225. * // => true
  29226. *
  29227. * _.lte(3, 1);
  29228. * // => false
  29229. */
  29230. var lte = createRelationalOperation(function(value, other) {
  29231. return value <= other;
  29232. });
  29233. /**
  29234. * Converts `value` to an array.
  29235. *
  29236. * @static
  29237. * @since 0.1.0
  29238. * @memberOf _
  29239. * @category Lang
  29240. * @param {*} value The value to convert.
  29241. * @returns {Array} Returns the converted array.
  29242. * @example
  29243. *
  29244. * _.toArray({ 'a': 1, 'b': 2 });
  29245. * // => [1, 2]
  29246. *
  29247. * _.toArray('abc');
  29248. * // => ['a', 'b', 'c']
  29249. *
  29250. * _.toArray(1);
  29251. * // => []
  29252. *
  29253. * _.toArray(null);
  29254. * // => []
  29255. */
  29256. function toArray(value) {
  29257. if (!value) {
  29258. return [];
  29259. }
  29260. if (isArrayLike(value)) {
  29261. return isString(value) ? stringToArray(value) : copyArray(value);
  29262. }
  29263. if (symIterator && value[symIterator]) {
  29264. return iteratorToArray(value[symIterator]());
  29265. }
  29266. var tag = getTag(value),
  29267. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  29268. return func(value);
  29269. }
  29270. /**
  29271. * Converts `value` to a finite number.
  29272. *
  29273. * @static
  29274. * @memberOf _
  29275. * @since 4.12.0
  29276. * @category Lang
  29277. * @param {*} value The value to convert.
  29278. * @returns {number} Returns the converted number.
  29279. * @example
  29280. *
  29281. * _.toFinite(3.2);
  29282. * // => 3.2
  29283. *
  29284. * _.toFinite(Number.MIN_VALUE);
  29285. * // => 5e-324
  29286. *
  29287. * _.toFinite(Infinity);
  29288. * // => 1.7976931348623157e+308
  29289. *
  29290. * _.toFinite('3.2');
  29291. * // => 3.2
  29292. */
  29293. function toFinite(value) {
  29294. if (!value) {
  29295. return value === 0 ? value : 0;
  29296. }
  29297. value = toNumber(value);
  29298. if (value === INFINITY || value === -INFINITY) {
  29299. var sign = (value < 0 ? -1 : 1);
  29300. return sign * MAX_INTEGER;
  29301. }
  29302. return value === value ? value : 0;
  29303. }
  29304. /**
  29305. * Converts `value` to an integer.
  29306. *
  29307. * **Note:** This method is loosely based on
  29308. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  29309. *
  29310. * @static
  29311. * @memberOf _
  29312. * @since 4.0.0
  29313. * @category Lang
  29314. * @param {*} value The value to convert.
  29315. * @returns {number} Returns the converted integer.
  29316. * @example
  29317. *
  29318. * _.toInteger(3.2);
  29319. * // => 3
  29320. *
  29321. * _.toInteger(Number.MIN_VALUE);
  29322. * // => 0
  29323. *
  29324. * _.toInteger(Infinity);
  29325. * // => 1.7976931348623157e+308
  29326. *
  29327. * _.toInteger('3.2');
  29328. * // => 3
  29329. */
  29330. function toInteger(value) {
  29331. var result = toFinite(value),
  29332. remainder = result % 1;
  29333. return result === result ? (remainder ? result - remainder : result) : 0;
  29334. }
  29335. /**
  29336. * Converts `value` to an integer suitable for use as the length of an
  29337. * array-like object.
  29338. *
  29339. * **Note:** This method is based on
  29340. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  29341. *
  29342. * @static
  29343. * @memberOf _
  29344. * @since 4.0.0
  29345. * @category Lang
  29346. * @param {*} value The value to convert.
  29347. * @returns {number} Returns the converted integer.
  29348. * @example
  29349. *
  29350. * _.toLength(3.2);
  29351. * // => 3
  29352. *
  29353. * _.toLength(Number.MIN_VALUE);
  29354. * // => 0
  29355. *
  29356. * _.toLength(Infinity);
  29357. * // => 4294967295
  29358. *
  29359. * _.toLength('3.2');
  29360. * // => 3
  29361. */
  29362. function toLength(value) {
  29363. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  29364. }
  29365. /**
  29366. * Converts `value` to a number.
  29367. *
  29368. * @static
  29369. * @memberOf _
  29370. * @since 4.0.0
  29371. * @category Lang
  29372. * @param {*} value The value to process.
  29373. * @returns {number} Returns the number.
  29374. * @example
  29375. *
  29376. * _.toNumber(3.2);
  29377. * // => 3.2
  29378. *
  29379. * _.toNumber(Number.MIN_VALUE);
  29380. * // => 5e-324
  29381. *
  29382. * _.toNumber(Infinity);
  29383. * // => Infinity
  29384. *
  29385. * _.toNumber('3.2');
  29386. * // => 3.2
  29387. */
  29388. function toNumber(value) {
  29389. if (typeof value == 'number') {
  29390. return value;
  29391. }
  29392. if (isSymbol(value)) {
  29393. return NAN;
  29394. }
  29395. if (isObject(value)) {
  29396. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  29397. value = isObject(other) ? (other + '') : other;
  29398. }
  29399. if (typeof value != 'string') {
  29400. return value === 0 ? value : +value;
  29401. }
  29402. value = value.replace(reTrim, '');
  29403. var isBinary = reIsBinary.test(value);
  29404. return (isBinary || reIsOctal.test(value))
  29405. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  29406. : (reIsBadHex.test(value) ? NAN : +value);
  29407. }
  29408. /**
  29409. * Converts `value` to a plain object flattening inherited enumerable string
  29410. * keyed properties of `value` to own properties of the plain object.
  29411. *
  29412. * @static
  29413. * @memberOf _
  29414. * @since 3.0.0
  29415. * @category Lang
  29416. * @param {*} value The value to convert.
  29417. * @returns {Object} Returns the converted plain object.
  29418. * @example
  29419. *
  29420. * function Foo() {
  29421. * this.b = 2;
  29422. * }
  29423. *
  29424. * Foo.prototype.c = 3;
  29425. *
  29426. * _.assign({ 'a': 1 }, new Foo);
  29427. * // => { 'a': 1, 'b': 2 }
  29428. *
  29429. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  29430. * // => { 'a': 1, 'b': 2, 'c': 3 }
  29431. */
  29432. function toPlainObject(value) {
  29433. return copyObject(value, keysIn(value));
  29434. }
  29435. /**
  29436. * Converts `value` to a safe integer. A safe integer can be compared and
  29437. * represented correctly.
  29438. *
  29439. * @static
  29440. * @memberOf _
  29441. * @since 4.0.0
  29442. * @category Lang
  29443. * @param {*} value The value to convert.
  29444. * @returns {number} Returns the converted integer.
  29445. * @example
  29446. *
  29447. * _.toSafeInteger(3.2);
  29448. * // => 3
  29449. *
  29450. * _.toSafeInteger(Number.MIN_VALUE);
  29451. * // => 0
  29452. *
  29453. * _.toSafeInteger(Infinity);
  29454. * // => 9007199254740991
  29455. *
  29456. * _.toSafeInteger('3.2');
  29457. * // => 3
  29458. */
  29459. function toSafeInteger(value) {
  29460. return value
  29461. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  29462. : (value === 0 ? value : 0);
  29463. }
  29464. /**
  29465. * Converts `value` to a string. An empty string is returned for `null`
  29466. * and `undefined` values. The sign of `-0` is preserved.
  29467. *
  29468. * @static
  29469. * @memberOf _
  29470. * @since 4.0.0
  29471. * @category Lang
  29472. * @param {*} value The value to convert.
  29473. * @returns {string} Returns the converted string.
  29474. * @example
  29475. *
  29476. * _.toString(null);
  29477. * // => ''
  29478. *
  29479. * _.toString(-0);
  29480. * // => '-0'
  29481. *
  29482. * _.toString([1, 2, 3]);
  29483. * // => '1,2,3'
  29484. */
  29485. function toString(value) {
  29486. return value == null ? '' : baseToString(value);
  29487. }
  29488. /*------------------------------------------------------------------------*/
  29489. /**
  29490. * Assigns own enumerable string keyed properties of source objects to the
  29491. * destination object. Source objects are applied from left to right.
  29492. * Subsequent sources overwrite property assignments of previous sources.
  29493. *
  29494. * **Note:** This method mutates `object` and is loosely based on
  29495. * [`Object.assign`](https://mdn.io/Object/assign).
  29496. *
  29497. * @static
  29498. * @memberOf _
  29499. * @since 0.10.0
  29500. * @category Object
  29501. * @param {Object} object The destination object.
  29502. * @param {...Object} [sources] The source objects.
  29503. * @returns {Object} Returns `object`.
  29504. * @see _.assignIn
  29505. * @example
  29506. *
  29507. * function Foo() {
  29508. * this.a = 1;
  29509. * }
  29510. *
  29511. * function Bar() {
  29512. * this.c = 3;
  29513. * }
  29514. *
  29515. * Foo.prototype.b = 2;
  29516. * Bar.prototype.d = 4;
  29517. *
  29518. * _.assign({ 'a': 0 }, new Foo, new Bar);
  29519. * // => { 'a': 1, 'c': 3 }
  29520. */
  29521. var assign = createAssigner(function(object, source) {
  29522. if (isPrototype(source) || isArrayLike(source)) {
  29523. copyObject(source, keys(source), object);
  29524. return;
  29525. }
  29526. for (var key in source) {
  29527. if (hasOwnProperty.call(source, key)) {
  29528. assignValue(object, key, source[key]);
  29529. }
  29530. }
  29531. });
  29532. /**
  29533. * This method is like `_.assign` except that it iterates over own and
  29534. * inherited source properties.
  29535. *
  29536. * **Note:** This method mutates `object`.
  29537. *
  29538. * @static
  29539. * @memberOf _
  29540. * @since 4.0.0
  29541. * @alias extend
  29542. * @category Object
  29543. * @param {Object} object The destination object.
  29544. * @param {...Object} [sources] The source objects.
  29545. * @returns {Object} Returns `object`.
  29546. * @see _.assign
  29547. * @example
  29548. *
  29549. * function Foo() {
  29550. * this.a = 1;
  29551. * }
  29552. *
  29553. * function Bar() {
  29554. * this.c = 3;
  29555. * }
  29556. *
  29557. * Foo.prototype.b = 2;
  29558. * Bar.prototype.d = 4;
  29559. *
  29560. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  29561. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  29562. */
  29563. var assignIn = createAssigner(function(object, source) {
  29564. copyObject(source, keysIn(source), object);
  29565. });
  29566. /**
  29567. * This method is like `_.assignIn` except that it accepts `customizer`
  29568. * which is invoked to produce the assigned values. If `customizer` returns
  29569. * `undefined`, assignment is handled by the method instead. The `customizer`
  29570. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29571. *
  29572. * **Note:** This method mutates `object`.
  29573. *
  29574. * @static
  29575. * @memberOf _
  29576. * @since 4.0.0
  29577. * @alias extendWith
  29578. * @category Object
  29579. * @param {Object} object The destination object.
  29580. * @param {...Object} sources The source objects.
  29581. * @param {Function} [customizer] The function to customize assigned values.
  29582. * @returns {Object} Returns `object`.
  29583. * @see _.assignWith
  29584. * @example
  29585. *
  29586. * function customizer(objValue, srcValue) {
  29587. * return _.isUndefined(objValue) ? srcValue : objValue;
  29588. * }
  29589. *
  29590. * var defaults = _.partialRight(_.assignInWith, customizer);
  29591. *
  29592. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29593. * // => { 'a': 1, 'b': 2 }
  29594. */
  29595. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  29596. copyObject(source, keysIn(source), object, customizer);
  29597. });
  29598. /**
  29599. * This method is like `_.assign` except that it accepts `customizer`
  29600. * which is invoked to produce the assigned values. If `customizer` returns
  29601. * `undefined`, assignment is handled by the method instead. The `customizer`
  29602. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29603. *
  29604. * **Note:** This method mutates `object`.
  29605. *
  29606. * @static
  29607. * @memberOf _
  29608. * @since 4.0.0
  29609. * @category Object
  29610. * @param {Object} object The destination object.
  29611. * @param {...Object} sources The source objects.
  29612. * @param {Function} [customizer] The function to customize assigned values.
  29613. * @returns {Object} Returns `object`.
  29614. * @see _.assignInWith
  29615. * @example
  29616. *
  29617. * function customizer(objValue, srcValue) {
  29618. * return _.isUndefined(objValue) ? srcValue : objValue;
  29619. * }
  29620. *
  29621. * var defaults = _.partialRight(_.assignWith, customizer);
  29622. *
  29623. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29624. * // => { 'a': 1, 'b': 2 }
  29625. */
  29626. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  29627. copyObject(source, keys(source), object, customizer);
  29628. });
  29629. /**
  29630. * Creates an array of values corresponding to `paths` of `object`.
  29631. *
  29632. * @static
  29633. * @memberOf _
  29634. * @since 1.0.0
  29635. * @category Object
  29636. * @param {Object} object The object to iterate over.
  29637. * @param {...(string|string[])} [paths] The property paths to pick.
  29638. * @returns {Array} Returns the picked values.
  29639. * @example
  29640. *
  29641. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  29642. *
  29643. * _.at(object, ['a[0].b.c', 'a[1]']);
  29644. * // => [3, 4]
  29645. */
  29646. var at = flatRest(baseAt);
  29647. /**
  29648. * Creates an object that inherits from the `prototype` object. If a
  29649. * `properties` object is given, its own enumerable string keyed properties
  29650. * are assigned to the created object.
  29651. *
  29652. * @static
  29653. * @memberOf _
  29654. * @since 2.3.0
  29655. * @category Object
  29656. * @param {Object} prototype The object to inherit from.
  29657. * @param {Object} [properties] The properties to assign to the object.
  29658. * @returns {Object} Returns the new object.
  29659. * @example
  29660. *
  29661. * function Shape() {
  29662. * this.x = 0;
  29663. * this.y = 0;
  29664. * }
  29665. *
  29666. * function Circle() {
  29667. * Shape.call(this);
  29668. * }
  29669. *
  29670. * Circle.prototype = _.create(Shape.prototype, {
  29671. * 'constructor': Circle
  29672. * });
  29673. *
  29674. * var circle = new Circle;
  29675. * circle instanceof Circle;
  29676. * // => true
  29677. *
  29678. * circle instanceof Shape;
  29679. * // => true
  29680. */
  29681. function create(prototype, properties) {
  29682. var result = baseCreate(prototype);
  29683. return properties == null ? result : baseAssign(result, properties);
  29684. }
  29685. /**
  29686. * Assigns own and inherited enumerable string keyed properties of source
  29687. * objects to the destination object for all destination properties that
  29688. * resolve to `undefined`. Source objects are applied from left to right.
  29689. * Once a property is set, additional values of the same property are ignored.
  29690. *
  29691. * **Note:** This method mutates `object`.
  29692. *
  29693. * @static
  29694. * @since 0.1.0
  29695. * @memberOf _
  29696. * @category Object
  29697. * @param {Object} object The destination object.
  29698. * @param {...Object} [sources] The source objects.
  29699. * @returns {Object} Returns `object`.
  29700. * @see _.defaultsDeep
  29701. * @example
  29702. *
  29703. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29704. * // => { 'a': 1, 'b': 2 }
  29705. */
  29706. var defaults = baseRest(function(object, sources) {
  29707. object = Object(object);
  29708. var index = -1;
  29709. var length = sources.length;
  29710. var guard = length > 2 ? sources[2] : undefined;
  29711. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  29712. length = 1;
  29713. }
  29714. while (++index < length) {
  29715. var source = sources[index];
  29716. var props = keysIn(source);
  29717. var propsIndex = -1;
  29718. var propsLength = props.length;
  29719. while (++propsIndex < propsLength) {
  29720. var key = props[propsIndex];
  29721. var value = object[key];
  29722. if (value === undefined ||
  29723. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  29724. object[key] = source[key];
  29725. }
  29726. }
  29727. }
  29728. return object;
  29729. });
  29730. /**
  29731. * This method is like `_.defaults` except that it recursively assigns
  29732. * default properties.
  29733. *
  29734. * **Note:** This method mutates `object`.
  29735. *
  29736. * @static
  29737. * @memberOf _
  29738. * @since 3.10.0
  29739. * @category Object
  29740. * @param {Object} object The destination object.
  29741. * @param {...Object} [sources] The source objects.
  29742. * @returns {Object} Returns `object`.
  29743. * @see _.defaults
  29744. * @example
  29745. *
  29746. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  29747. * // => { 'a': { 'b': 2, 'c': 3 } }
  29748. */
  29749. var defaultsDeep = baseRest(function(args) {
  29750. args.push(undefined, customDefaultsMerge);
  29751. return apply(mergeWith, undefined, args);
  29752. });
  29753. /**
  29754. * This method is like `_.find` except that it returns the key of the first
  29755. * element `predicate` returns truthy for instead of the element itself.
  29756. *
  29757. * @static
  29758. * @memberOf _
  29759. * @since 1.1.0
  29760. * @category Object
  29761. * @param {Object} object The object to inspect.
  29762. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29763. * @returns {string|undefined} Returns the key of the matched element,
  29764. * else `undefined`.
  29765. * @example
  29766. *
  29767. * var users = {
  29768. * 'barney': { 'age': 36, 'active': true },
  29769. * 'fred': { 'age': 40, 'active': false },
  29770. * 'pebbles': { 'age': 1, 'active': true }
  29771. * };
  29772. *
  29773. * _.findKey(users, function(o) { return o.age < 40; });
  29774. * // => 'barney' (iteration order is not guaranteed)
  29775. *
  29776. * // The `_.matches` iteratee shorthand.
  29777. * _.findKey(users, { 'age': 1, 'active': true });
  29778. * // => 'pebbles'
  29779. *
  29780. * // The `_.matchesProperty` iteratee shorthand.
  29781. * _.findKey(users, ['active', false]);
  29782. * // => 'fred'
  29783. *
  29784. * // The `_.property` iteratee shorthand.
  29785. * _.findKey(users, 'active');
  29786. * // => 'barney'
  29787. */
  29788. function findKey(object, predicate) {
  29789. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  29790. }
  29791. /**
  29792. * This method is like `_.findKey` except that it iterates over elements of
  29793. * a collection in the opposite order.
  29794. *
  29795. * @static
  29796. * @memberOf _
  29797. * @since 2.0.0
  29798. * @category Object
  29799. * @param {Object} object The object to inspect.
  29800. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29801. * @returns {string|undefined} Returns the key of the matched element,
  29802. * else `undefined`.
  29803. * @example
  29804. *
  29805. * var users = {
  29806. * 'barney': { 'age': 36, 'active': true },
  29807. * 'fred': { 'age': 40, 'active': false },
  29808. * 'pebbles': { 'age': 1, 'active': true }
  29809. * };
  29810. *
  29811. * _.findLastKey(users, function(o) { return o.age < 40; });
  29812. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  29813. *
  29814. * // The `_.matches` iteratee shorthand.
  29815. * _.findLastKey(users, { 'age': 36, 'active': true });
  29816. * // => 'barney'
  29817. *
  29818. * // The `_.matchesProperty` iteratee shorthand.
  29819. * _.findLastKey(users, ['active', false]);
  29820. * // => 'fred'
  29821. *
  29822. * // The `_.property` iteratee shorthand.
  29823. * _.findLastKey(users, 'active');
  29824. * // => 'pebbles'
  29825. */
  29826. function findLastKey(object, predicate) {
  29827. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  29828. }
  29829. /**
  29830. * Iterates over own and inherited enumerable string keyed properties of an
  29831. * object and invokes `iteratee` for each property. The iteratee is invoked
  29832. * with three arguments: (value, key, object). Iteratee functions may exit
  29833. * iteration early by explicitly returning `false`.
  29834. *
  29835. * @static
  29836. * @memberOf _
  29837. * @since 0.3.0
  29838. * @category Object
  29839. * @param {Object} object The object to iterate over.
  29840. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29841. * @returns {Object} Returns `object`.
  29842. * @see _.forInRight
  29843. * @example
  29844. *
  29845. * function Foo() {
  29846. * this.a = 1;
  29847. * this.b = 2;
  29848. * }
  29849. *
  29850. * Foo.prototype.c = 3;
  29851. *
  29852. * _.forIn(new Foo, function(value, key) {
  29853. * console.log(key);
  29854. * });
  29855. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  29856. */
  29857. function forIn(object, iteratee) {
  29858. return object == null
  29859. ? object
  29860. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  29861. }
  29862. /**
  29863. * This method is like `_.forIn` except that it iterates over properties of
  29864. * `object` in the opposite order.
  29865. *
  29866. * @static
  29867. * @memberOf _
  29868. * @since 2.0.0
  29869. * @category Object
  29870. * @param {Object} object The object to iterate over.
  29871. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29872. * @returns {Object} Returns `object`.
  29873. * @see _.forIn
  29874. * @example
  29875. *
  29876. * function Foo() {
  29877. * this.a = 1;
  29878. * this.b = 2;
  29879. * }
  29880. *
  29881. * Foo.prototype.c = 3;
  29882. *
  29883. * _.forInRight(new Foo, function(value, key) {
  29884. * console.log(key);
  29885. * });
  29886. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  29887. */
  29888. function forInRight(object, iteratee) {
  29889. return object == null
  29890. ? object
  29891. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  29892. }
  29893. /**
  29894. * Iterates over own enumerable string keyed properties of an object and
  29895. * invokes `iteratee` for each property. The iteratee is invoked with three
  29896. * arguments: (value, key, object). Iteratee functions may exit iteration
  29897. * early by explicitly returning `false`.
  29898. *
  29899. * @static
  29900. * @memberOf _
  29901. * @since 0.3.0
  29902. * @category Object
  29903. * @param {Object} object The object to iterate over.
  29904. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29905. * @returns {Object} Returns `object`.
  29906. * @see _.forOwnRight
  29907. * @example
  29908. *
  29909. * function Foo() {
  29910. * this.a = 1;
  29911. * this.b = 2;
  29912. * }
  29913. *
  29914. * Foo.prototype.c = 3;
  29915. *
  29916. * _.forOwn(new Foo, function(value, key) {
  29917. * console.log(key);
  29918. * });
  29919. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  29920. */
  29921. function forOwn(object, iteratee) {
  29922. return object && baseForOwn(object, getIteratee(iteratee, 3));
  29923. }
  29924. /**
  29925. * This method is like `_.forOwn` except that it iterates over properties of
  29926. * `object` in the opposite order.
  29927. *
  29928. * @static
  29929. * @memberOf _
  29930. * @since 2.0.0
  29931. * @category Object
  29932. * @param {Object} object The object to iterate over.
  29933. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29934. * @returns {Object} Returns `object`.
  29935. * @see _.forOwn
  29936. * @example
  29937. *
  29938. * function Foo() {
  29939. * this.a = 1;
  29940. * this.b = 2;
  29941. * }
  29942. *
  29943. * Foo.prototype.c = 3;
  29944. *
  29945. * _.forOwnRight(new Foo, function(value, key) {
  29946. * console.log(key);
  29947. * });
  29948. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  29949. */
  29950. function forOwnRight(object, iteratee) {
  29951. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  29952. }
  29953. /**
  29954. * Creates an array of function property names from own enumerable properties
  29955. * of `object`.
  29956. *
  29957. * @static
  29958. * @since 0.1.0
  29959. * @memberOf _
  29960. * @category Object
  29961. * @param {Object} object The object to inspect.
  29962. * @returns {Array} Returns the function names.
  29963. * @see _.functionsIn
  29964. * @example
  29965. *
  29966. * function Foo() {
  29967. * this.a = _.constant('a');
  29968. * this.b = _.constant('b');
  29969. * }
  29970. *
  29971. * Foo.prototype.c = _.constant('c');
  29972. *
  29973. * _.functions(new Foo);
  29974. * // => ['a', 'b']
  29975. */
  29976. function functions(object) {
  29977. return object == null ? [] : baseFunctions(object, keys(object));
  29978. }
  29979. /**
  29980. * Creates an array of function property names from own and inherited
  29981. * enumerable properties of `object`.
  29982. *
  29983. * @static
  29984. * @memberOf _
  29985. * @since 4.0.0
  29986. * @category Object
  29987. * @param {Object} object The object to inspect.
  29988. * @returns {Array} Returns the function names.
  29989. * @see _.functions
  29990. * @example
  29991. *
  29992. * function Foo() {
  29993. * this.a = _.constant('a');
  29994. * this.b = _.constant('b');
  29995. * }
  29996. *
  29997. * Foo.prototype.c = _.constant('c');
  29998. *
  29999. * _.functionsIn(new Foo);
  30000. * // => ['a', 'b', 'c']
  30001. */
  30002. function functionsIn(object) {
  30003. return object == null ? [] : baseFunctions(object, keysIn(object));
  30004. }
  30005. /**
  30006. * Gets the value at `path` of `object`. If the resolved value is
  30007. * `undefined`, the `defaultValue` is returned in its place.
  30008. *
  30009. * @static
  30010. * @memberOf _
  30011. * @since 3.7.0
  30012. * @category Object
  30013. * @param {Object} object The object to query.
  30014. * @param {Array|string} path The path of the property to get.
  30015. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30016. * @returns {*} Returns the resolved value.
  30017. * @example
  30018. *
  30019. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30020. *
  30021. * _.get(object, 'a[0].b.c');
  30022. * // => 3
  30023. *
  30024. * _.get(object, ['a', '0', 'b', 'c']);
  30025. * // => 3
  30026. *
  30027. * _.get(object, 'a.b.c', 'default');
  30028. * // => 'default'
  30029. */
  30030. function get(object, path, defaultValue) {
  30031. var result = object == null ? undefined : baseGet(object, path);
  30032. return result === undefined ? defaultValue : result;
  30033. }
  30034. /**
  30035. * Checks if `path` is a direct property of `object`.
  30036. *
  30037. * @static
  30038. * @since 0.1.0
  30039. * @memberOf _
  30040. * @category Object
  30041. * @param {Object} object The object to query.
  30042. * @param {Array|string} path The path to check.
  30043. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30044. * @example
  30045. *
  30046. * var object = { 'a': { 'b': 2 } };
  30047. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  30048. *
  30049. * _.has(object, 'a');
  30050. * // => true
  30051. *
  30052. * _.has(object, 'a.b');
  30053. * // => true
  30054. *
  30055. * _.has(object, ['a', 'b']);
  30056. * // => true
  30057. *
  30058. * _.has(other, 'a');
  30059. * // => false
  30060. */
  30061. function has(object, path) {
  30062. return object != null && hasPath(object, path, baseHas);
  30063. }
  30064. /**
  30065. * Checks if `path` is a direct or inherited property of `object`.
  30066. *
  30067. * @static
  30068. * @memberOf _
  30069. * @since 4.0.0
  30070. * @category Object
  30071. * @param {Object} object The object to query.
  30072. * @param {Array|string} path The path to check.
  30073. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30074. * @example
  30075. *
  30076. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  30077. *
  30078. * _.hasIn(object, 'a');
  30079. * // => true
  30080. *
  30081. * _.hasIn(object, 'a.b');
  30082. * // => true
  30083. *
  30084. * _.hasIn(object, ['a', 'b']);
  30085. * // => true
  30086. *
  30087. * _.hasIn(object, 'b');
  30088. * // => false
  30089. */
  30090. function hasIn(object, path) {
  30091. return object != null && hasPath(object, path, baseHasIn);
  30092. }
  30093. /**
  30094. * Creates an object composed of the inverted keys and values of `object`.
  30095. * If `object` contains duplicate values, subsequent values overwrite
  30096. * property assignments of previous values.
  30097. *
  30098. * @static
  30099. * @memberOf _
  30100. * @since 0.7.0
  30101. * @category Object
  30102. * @param {Object} object The object to invert.
  30103. * @returns {Object} Returns the new inverted object.
  30104. * @example
  30105. *
  30106. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30107. *
  30108. * _.invert(object);
  30109. * // => { '1': 'c', '2': 'b' }
  30110. */
  30111. var invert = createInverter(function(result, value, key) {
  30112. if (value != null &&
  30113. typeof value.toString != 'function') {
  30114. value = nativeObjectToString.call(value);
  30115. }
  30116. result[value] = key;
  30117. }, constant(identity));
  30118. /**
  30119. * This method is like `_.invert` except that the inverted object is generated
  30120. * from the results of running each element of `object` thru `iteratee`. The
  30121. * corresponding inverted value of each inverted key is an array of keys
  30122. * responsible for generating the inverted value. The iteratee is invoked
  30123. * with one argument: (value).
  30124. *
  30125. * @static
  30126. * @memberOf _
  30127. * @since 4.1.0
  30128. * @category Object
  30129. * @param {Object} object The object to invert.
  30130. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  30131. * @returns {Object} Returns the new inverted object.
  30132. * @example
  30133. *
  30134. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30135. *
  30136. * _.invertBy(object);
  30137. * // => { '1': ['a', 'c'], '2': ['b'] }
  30138. *
  30139. * _.invertBy(object, function(value) {
  30140. * return 'group' + value;
  30141. * });
  30142. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  30143. */
  30144. var invertBy = createInverter(function(result, value, key) {
  30145. if (value != null &&
  30146. typeof value.toString != 'function') {
  30147. value = nativeObjectToString.call(value);
  30148. }
  30149. if (hasOwnProperty.call(result, value)) {
  30150. result[value].push(key);
  30151. } else {
  30152. result[value] = [key];
  30153. }
  30154. }, getIteratee);
  30155. /**
  30156. * Invokes the method at `path` of `object`.
  30157. *
  30158. * @static
  30159. * @memberOf _
  30160. * @since 4.0.0
  30161. * @category Object
  30162. * @param {Object} object The object to query.
  30163. * @param {Array|string} path The path of the method to invoke.
  30164. * @param {...*} [args] The arguments to invoke the method with.
  30165. * @returns {*} Returns the result of the invoked method.
  30166. * @example
  30167. *
  30168. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  30169. *
  30170. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  30171. * // => [2, 3]
  30172. */
  30173. var invoke = baseRest(baseInvoke);
  30174. /**
  30175. * Creates an array of the own enumerable property names of `object`.
  30176. *
  30177. * **Note:** Non-object values are coerced to objects. See the
  30178. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  30179. * for more details.
  30180. *
  30181. * @static
  30182. * @since 0.1.0
  30183. * @memberOf _
  30184. * @category Object
  30185. * @param {Object} object The object to query.
  30186. * @returns {Array} Returns the array of property names.
  30187. * @example
  30188. *
  30189. * function Foo() {
  30190. * this.a = 1;
  30191. * this.b = 2;
  30192. * }
  30193. *
  30194. * Foo.prototype.c = 3;
  30195. *
  30196. * _.keys(new Foo);
  30197. * // => ['a', 'b'] (iteration order is not guaranteed)
  30198. *
  30199. * _.keys('hi');
  30200. * // => ['0', '1']
  30201. */
  30202. function keys(object) {
  30203. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  30204. }
  30205. /**
  30206. * Creates an array of the own and inherited enumerable property names of `object`.
  30207. *
  30208. * **Note:** Non-object values are coerced to objects.
  30209. *
  30210. * @static
  30211. * @memberOf _
  30212. * @since 3.0.0
  30213. * @category Object
  30214. * @param {Object} object The object to query.
  30215. * @returns {Array} Returns the array of property names.
  30216. * @example
  30217. *
  30218. * function Foo() {
  30219. * this.a = 1;
  30220. * this.b = 2;
  30221. * }
  30222. *
  30223. * Foo.prototype.c = 3;
  30224. *
  30225. * _.keysIn(new Foo);
  30226. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  30227. */
  30228. function keysIn(object) {
  30229. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  30230. }
  30231. /**
  30232. * The opposite of `_.mapValues`; this method creates an object with the
  30233. * same values as `object` and keys generated by running each own enumerable
  30234. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  30235. * with three arguments: (value, key, object).
  30236. *
  30237. * @static
  30238. * @memberOf _
  30239. * @since 3.8.0
  30240. * @category Object
  30241. * @param {Object} object The object to iterate over.
  30242. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30243. * @returns {Object} Returns the new mapped object.
  30244. * @see _.mapValues
  30245. * @example
  30246. *
  30247. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  30248. * return key + value;
  30249. * });
  30250. * // => { 'a1': 1, 'b2': 2 }
  30251. */
  30252. function mapKeys(object, iteratee) {
  30253. var result = {};
  30254. iteratee = getIteratee(iteratee, 3);
  30255. baseForOwn(object, function(value, key, object) {
  30256. baseAssignValue(result, iteratee(value, key, object), value);
  30257. });
  30258. return result;
  30259. }
  30260. /**
  30261. * Creates an object with the same keys as `object` and values generated
  30262. * by running each own enumerable string keyed property of `object` thru
  30263. * `iteratee`. The iteratee is invoked with three arguments:
  30264. * (value, key, object).
  30265. *
  30266. * @static
  30267. * @memberOf _
  30268. * @since 2.4.0
  30269. * @category Object
  30270. * @param {Object} object The object to iterate over.
  30271. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30272. * @returns {Object} Returns the new mapped object.
  30273. * @see _.mapKeys
  30274. * @example
  30275. *
  30276. * var users = {
  30277. * 'fred': { 'user': 'fred', 'age': 40 },
  30278. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  30279. * };
  30280. *
  30281. * _.mapValues(users, function(o) { return o.age; });
  30282. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30283. *
  30284. * // The `_.property` iteratee shorthand.
  30285. * _.mapValues(users, 'age');
  30286. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30287. */
  30288. function mapValues(object, iteratee) {
  30289. var result = {};
  30290. iteratee = getIteratee(iteratee, 3);
  30291. baseForOwn(object, function(value, key, object) {
  30292. baseAssignValue(result, key, iteratee(value, key, object));
  30293. });
  30294. return result;
  30295. }
  30296. /**
  30297. * This method is like `_.assign` except that it recursively merges own and
  30298. * inherited enumerable string keyed properties of source objects into the
  30299. * destination object. Source properties that resolve to `undefined` are
  30300. * skipped if a destination value exists. Array and plain object properties
  30301. * are merged recursively. Other objects and value types are overridden by
  30302. * assignment. Source objects are applied from left to right. Subsequent
  30303. * sources overwrite property assignments of previous sources.
  30304. *
  30305. * **Note:** This method mutates `object`.
  30306. *
  30307. * @static
  30308. * @memberOf _
  30309. * @since 0.5.0
  30310. * @category Object
  30311. * @param {Object} object The destination object.
  30312. * @param {...Object} [sources] The source objects.
  30313. * @returns {Object} Returns `object`.
  30314. * @example
  30315. *
  30316. * var object = {
  30317. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  30318. * };
  30319. *
  30320. * var other = {
  30321. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  30322. * };
  30323. *
  30324. * _.merge(object, other);
  30325. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  30326. */
  30327. var merge = createAssigner(function(object, source, srcIndex) {
  30328. baseMerge(object, source, srcIndex);
  30329. });
  30330. /**
  30331. * This method is like `_.merge` except that it accepts `customizer` which
  30332. * is invoked to produce the merged values of the destination and source
  30333. * properties. If `customizer` returns `undefined`, merging is handled by the
  30334. * method instead. The `customizer` is invoked with six arguments:
  30335. * (objValue, srcValue, key, object, source, stack).
  30336. *
  30337. * **Note:** This method mutates `object`.
  30338. *
  30339. * @static
  30340. * @memberOf _
  30341. * @since 4.0.0
  30342. * @category Object
  30343. * @param {Object} object The destination object.
  30344. * @param {...Object} sources The source objects.
  30345. * @param {Function} customizer The function to customize assigned values.
  30346. * @returns {Object} Returns `object`.
  30347. * @example
  30348. *
  30349. * function customizer(objValue, srcValue) {
  30350. * if (_.isArray(objValue)) {
  30351. * return objValue.concat(srcValue);
  30352. * }
  30353. * }
  30354. *
  30355. * var object = { 'a': [1], 'b': [2] };
  30356. * var other = { 'a': [3], 'b': [4] };
  30357. *
  30358. * _.mergeWith(object, other, customizer);
  30359. * // => { 'a': [1, 3], 'b': [2, 4] }
  30360. */
  30361. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  30362. baseMerge(object, source, srcIndex, customizer);
  30363. });
  30364. /**
  30365. * The opposite of `_.pick`; this method creates an object composed of the
  30366. * own and inherited enumerable property paths of `object` that are not omitted.
  30367. *
  30368. * **Note:** This method is considerably slower than `_.pick`.
  30369. *
  30370. * @static
  30371. * @since 0.1.0
  30372. * @memberOf _
  30373. * @category Object
  30374. * @param {Object} object The source object.
  30375. * @param {...(string|string[])} [paths] The property paths to omit.
  30376. * @returns {Object} Returns the new object.
  30377. * @example
  30378. *
  30379. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30380. *
  30381. * _.omit(object, ['a', 'c']);
  30382. * // => { 'b': '2' }
  30383. */
  30384. var omit = flatRest(function(object, paths) {
  30385. var result = {};
  30386. if (object == null) {
  30387. return result;
  30388. }
  30389. var isDeep = false;
  30390. paths = arrayMap(paths, function(path) {
  30391. path = castPath(path, object);
  30392. isDeep || (isDeep = path.length > 1);
  30393. return path;
  30394. });
  30395. copyObject(object, getAllKeysIn(object), result);
  30396. if (isDeep) {
  30397. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  30398. }
  30399. var length = paths.length;
  30400. while (length--) {
  30401. baseUnset(result, paths[length]);
  30402. }
  30403. return result;
  30404. });
  30405. /**
  30406. * The opposite of `_.pickBy`; this method creates an object composed of
  30407. * the own and inherited enumerable string keyed properties of `object` that
  30408. * `predicate` doesn't return truthy for. The predicate is invoked with two
  30409. * arguments: (value, key).
  30410. *
  30411. * @static
  30412. * @memberOf _
  30413. * @since 4.0.0
  30414. * @category Object
  30415. * @param {Object} object The source object.
  30416. * @param {Function} [predicate=_.identity] The function invoked per property.
  30417. * @returns {Object} Returns the new object.
  30418. * @example
  30419. *
  30420. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30421. *
  30422. * _.omitBy(object, _.isNumber);
  30423. * // => { 'b': '2' }
  30424. */
  30425. function omitBy(object, predicate) {
  30426. return pickBy(object, negate(getIteratee(predicate)));
  30427. }
  30428. /**
  30429. * Creates an object composed of the picked `object` properties.
  30430. *
  30431. * @static
  30432. * @since 0.1.0
  30433. * @memberOf _
  30434. * @category Object
  30435. * @param {Object} object The source object.
  30436. * @param {...(string|string[])} [paths] The property paths to pick.
  30437. * @returns {Object} Returns the new object.
  30438. * @example
  30439. *
  30440. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30441. *
  30442. * _.pick(object, ['a', 'c']);
  30443. * // => { 'a': 1, 'c': 3 }
  30444. */
  30445. var pick = flatRest(function(object, paths) {
  30446. return object == null ? {} : basePick(object, paths);
  30447. });
  30448. /**
  30449. * Creates an object composed of the `object` properties `predicate` returns
  30450. * truthy for. The predicate is invoked with two arguments: (value, key).
  30451. *
  30452. * @static
  30453. * @memberOf _
  30454. * @since 4.0.0
  30455. * @category Object
  30456. * @param {Object} object The source object.
  30457. * @param {Function} [predicate=_.identity] The function invoked per property.
  30458. * @returns {Object} Returns the new object.
  30459. * @example
  30460. *
  30461. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30462. *
  30463. * _.pickBy(object, _.isNumber);
  30464. * // => { 'a': 1, 'c': 3 }
  30465. */
  30466. function pickBy(object, predicate) {
  30467. if (object == null) {
  30468. return {};
  30469. }
  30470. var props = arrayMap(getAllKeysIn(object), function(prop) {
  30471. return [prop];
  30472. });
  30473. predicate = getIteratee(predicate);
  30474. return basePickBy(object, props, function(value, path) {
  30475. return predicate(value, path[0]);
  30476. });
  30477. }
  30478. /**
  30479. * This method is like `_.get` except that if the resolved value is a
  30480. * function it's invoked with the `this` binding of its parent object and
  30481. * its result is returned.
  30482. *
  30483. * @static
  30484. * @since 0.1.0
  30485. * @memberOf _
  30486. * @category Object
  30487. * @param {Object} object The object to query.
  30488. * @param {Array|string} path The path of the property to resolve.
  30489. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30490. * @returns {*} Returns the resolved value.
  30491. * @example
  30492. *
  30493. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  30494. *
  30495. * _.result(object, 'a[0].b.c1');
  30496. * // => 3
  30497. *
  30498. * _.result(object, 'a[0].b.c2');
  30499. * // => 4
  30500. *
  30501. * _.result(object, 'a[0].b.c3', 'default');
  30502. * // => 'default'
  30503. *
  30504. * _.result(object, 'a[0].b.c3', _.constant('default'));
  30505. * // => 'default'
  30506. */
  30507. function result(object, path, defaultValue) {
  30508. path = castPath(path, object);
  30509. var index = -1,
  30510. length = path.length;
  30511. // Ensure the loop is entered when path is empty.
  30512. if (!length) {
  30513. length = 1;
  30514. object = undefined;
  30515. }
  30516. while (++index < length) {
  30517. var value = object == null ? undefined : object[toKey(path[index])];
  30518. if (value === undefined) {
  30519. index = length;
  30520. value = defaultValue;
  30521. }
  30522. object = isFunction(value) ? value.call(object) : value;
  30523. }
  30524. return object;
  30525. }
  30526. /**
  30527. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  30528. * it's created. Arrays are created for missing index properties while objects
  30529. * are created for all other missing properties. Use `_.setWith` to customize
  30530. * `path` creation.
  30531. *
  30532. * **Note:** This method mutates `object`.
  30533. *
  30534. * @static
  30535. * @memberOf _
  30536. * @since 3.7.0
  30537. * @category Object
  30538. * @param {Object} object The object to modify.
  30539. * @param {Array|string} path The path of the property to set.
  30540. * @param {*} value The value to set.
  30541. * @returns {Object} Returns `object`.
  30542. * @example
  30543. *
  30544. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30545. *
  30546. * _.set(object, 'a[0].b.c', 4);
  30547. * console.log(object.a[0].b.c);
  30548. * // => 4
  30549. *
  30550. * _.set(object, ['x', '0', 'y', 'z'], 5);
  30551. * console.log(object.x[0].y.z);
  30552. * // => 5
  30553. */
  30554. function set(object, path, value) {
  30555. return object == null ? object : baseSet(object, path, value);
  30556. }
  30557. /**
  30558. * This method is like `_.set` except that it accepts `customizer` which is
  30559. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30560. * path creation is handled by the method instead. The `customizer` is invoked
  30561. * with three arguments: (nsValue, key, nsObject).
  30562. *
  30563. * **Note:** This method mutates `object`.
  30564. *
  30565. * @static
  30566. * @memberOf _
  30567. * @since 4.0.0
  30568. * @category Object
  30569. * @param {Object} object The object to modify.
  30570. * @param {Array|string} path The path of the property to set.
  30571. * @param {*} value The value to set.
  30572. * @param {Function} [customizer] The function to customize assigned values.
  30573. * @returns {Object} Returns `object`.
  30574. * @example
  30575. *
  30576. * var object = {};
  30577. *
  30578. * _.setWith(object, '[0][1]', 'a', Object);
  30579. * // => { '0': { '1': 'a' } }
  30580. */
  30581. function setWith(object, path, value, customizer) {
  30582. customizer = typeof customizer == 'function' ? customizer : undefined;
  30583. return object == null ? object : baseSet(object, path, value, customizer);
  30584. }
  30585. /**
  30586. * Creates an array of own enumerable string keyed-value pairs for `object`
  30587. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  30588. * entries are returned.
  30589. *
  30590. * @static
  30591. * @memberOf _
  30592. * @since 4.0.0
  30593. * @alias entries
  30594. * @category Object
  30595. * @param {Object} object The object to query.
  30596. * @returns {Array} Returns the key-value pairs.
  30597. * @example
  30598. *
  30599. * function Foo() {
  30600. * this.a = 1;
  30601. * this.b = 2;
  30602. * }
  30603. *
  30604. * Foo.prototype.c = 3;
  30605. *
  30606. * _.toPairs(new Foo);
  30607. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  30608. */
  30609. var toPairs = createToPairs(keys);
  30610. /**
  30611. * Creates an array of own and inherited enumerable string keyed-value pairs
  30612. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  30613. * or set, its entries are returned.
  30614. *
  30615. * @static
  30616. * @memberOf _
  30617. * @since 4.0.0
  30618. * @alias entriesIn
  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. * _.toPairsIn(new Foo);
  30632. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  30633. */
  30634. var toPairsIn = createToPairs(keysIn);
  30635. /**
  30636. * An alternative to `_.reduce`; this method transforms `object` to a new
  30637. * `accumulator` object which is the result of running each of its own
  30638. * enumerable string keyed properties thru `iteratee`, with each invocation
  30639. * potentially mutating the `accumulator` object. If `accumulator` is not
  30640. * provided, a new object with the same `[[Prototype]]` will be used. The
  30641. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  30642. * Iteratee functions may exit iteration early by explicitly returning `false`.
  30643. *
  30644. * @static
  30645. * @memberOf _
  30646. * @since 1.3.0
  30647. * @category Object
  30648. * @param {Object} object The object to iterate over.
  30649. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30650. * @param {*} [accumulator] The custom accumulator value.
  30651. * @returns {*} Returns the accumulated value.
  30652. * @example
  30653. *
  30654. * _.transform([2, 3, 4], function(result, n) {
  30655. * result.push(n *= n);
  30656. * return n % 2 == 0;
  30657. * }, []);
  30658. * // => [4, 9]
  30659. *
  30660. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  30661. * (result[value] || (result[value] = [])).push(key);
  30662. * }, {});
  30663. * // => { '1': ['a', 'c'], '2': ['b'] }
  30664. */
  30665. function transform(object, iteratee, accumulator) {
  30666. var isArr = isArray(object),
  30667. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  30668. iteratee = getIteratee(iteratee, 4);
  30669. if (accumulator == null) {
  30670. var Ctor = object && object.constructor;
  30671. if (isArrLike) {
  30672. accumulator = isArr ? new Ctor : [];
  30673. }
  30674. else if (isObject(object)) {
  30675. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  30676. }
  30677. else {
  30678. accumulator = {};
  30679. }
  30680. }
  30681. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  30682. return iteratee(accumulator, value, index, object);
  30683. });
  30684. return accumulator;
  30685. }
  30686. /**
  30687. * Removes the property at `path` of `object`.
  30688. *
  30689. * **Note:** This method mutates `object`.
  30690. *
  30691. * @static
  30692. * @memberOf _
  30693. * @since 4.0.0
  30694. * @category Object
  30695. * @param {Object} object The object to modify.
  30696. * @param {Array|string} path The path of the property to unset.
  30697. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  30698. * @example
  30699. *
  30700. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  30701. * _.unset(object, 'a[0].b.c');
  30702. * // => true
  30703. *
  30704. * console.log(object);
  30705. * // => { 'a': [{ 'b': {} }] };
  30706. *
  30707. * _.unset(object, ['a', '0', 'b', 'c']);
  30708. * // => true
  30709. *
  30710. * console.log(object);
  30711. * // => { 'a': [{ 'b': {} }] };
  30712. */
  30713. function unset(object, path) {
  30714. return object == null ? true : baseUnset(object, path);
  30715. }
  30716. /**
  30717. * This method is like `_.set` except that accepts `updater` to produce the
  30718. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  30719. * is invoked with one argument: (value).
  30720. *
  30721. * **Note:** This method mutates `object`.
  30722. *
  30723. * @static
  30724. * @memberOf _
  30725. * @since 4.6.0
  30726. * @category Object
  30727. * @param {Object} object The object to modify.
  30728. * @param {Array|string} path The path of the property to set.
  30729. * @param {Function} updater The function to produce the updated value.
  30730. * @returns {Object} Returns `object`.
  30731. * @example
  30732. *
  30733. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30734. *
  30735. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  30736. * console.log(object.a[0].b.c);
  30737. * // => 9
  30738. *
  30739. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  30740. * console.log(object.x[0].y.z);
  30741. * // => 0
  30742. */
  30743. function update(object, path, updater) {
  30744. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  30745. }
  30746. /**
  30747. * This method is like `_.update` except that it accepts `customizer` which is
  30748. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30749. * path creation is handled by the method instead. The `customizer` is invoked
  30750. * with three arguments: (nsValue, key, nsObject).
  30751. *
  30752. * **Note:** This method mutates `object`.
  30753. *
  30754. * @static
  30755. * @memberOf _
  30756. * @since 4.6.0
  30757. * @category Object
  30758. * @param {Object} object The object to modify.
  30759. * @param {Array|string} path The path of the property to set.
  30760. * @param {Function} updater The function to produce the updated value.
  30761. * @param {Function} [customizer] The function to customize assigned values.
  30762. * @returns {Object} Returns `object`.
  30763. * @example
  30764. *
  30765. * var object = {};
  30766. *
  30767. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  30768. * // => { '0': { '1': 'a' } }
  30769. */
  30770. function updateWith(object, path, updater, customizer) {
  30771. customizer = typeof customizer == 'function' ? customizer : undefined;
  30772. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  30773. }
  30774. /**
  30775. * Creates an array of the own enumerable string keyed property values of `object`.
  30776. *
  30777. * **Note:** Non-object values are coerced to objects.
  30778. *
  30779. * @static
  30780. * @since 0.1.0
  30781. * @memberOf _
  30782. * @category Object
  30783. * @param {Object} object The object to query.
  30784. * @returns {Array} Returns the array of property values.
  30785. * @example
  30786. *
  30787. * function Foo() {
  30788. * this.a = 1;
  30789. * this.b = 2;
  30790. * }
  30791. *
  30792. * Foo.prototype.c = 3;
  30793. *
  30794. * _.values(new Foo);
  30795. * // => [1, 2] (iteration order is not guaranteed)
  30796. *
  30797. * _.values('hi');
  30798. * // => ['h', 'i']
  30799. */
  30800. function values(object) {
  30801. return object == null ? [] : baseValues(object, keys(object));
  30802. }
  30803. /**
  30804. * Creates an array of the own and inherited enumerable string keyed property
  30805. * values of `object`.
  30806. *
  30807. * **Note:** Non-object values are coerced to objects.
  30808. *
  30809. * @static
  30810. * @memberOf _
  30811. * @since 3.0.0
  30812. * @category Object
  30813. * @param {Object} object The object to query.
  30814. * @returns {Array} Returns the array of property values.
  30815. * @example
  30816. *
  30817. * function Foo() {
  30818. * this.a = 1;
  30819. * this.b = 2;
  30820. * }
  30821. *
  30822. * Foo.prototype.c = 3;
  30823. *
  30824. * _.valuesIn(new Foo);
  30825. * // => [1, 2, 3] (iteration order is not guaranteed)
  30826. */
  30827. function valuesIn(object) {
  30828. return object == null ? [] : baseValues(object, keysIn(object));
  30829. }
  30830. /*------------------------------------------------------------------------*/
  30831. /**
  30832. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  30833. *
  30834. * @static
  30835. * @memberOf _
  30836. * @since 4.0.0
  30837. * @category Number
  30838. * @param {number} number The number to clamp.
  30839. * @param {number} [lower] The lower bound.
  30840. * @param {number} upper The upper bound.
  30841. * @returns {number} Returns the clamped number.
  30842. * @example
  30843. *
  30844. * _.clamp(-10, -5, 5);
  30845. * // => -5
  30846. *
  30847. * _.clamp(10, -5, 5);
  30848. * // => 5
  30849. */
  30850. function clamp(number, lower, upper) {
  30851. if (upper === undefined) {
  30852. upper = lower;
  30853. lower = undefined;
  30854. }
  30855. if (upper !== undefined) {
  30856. upper = toNumber(upper);
  30857. upper = upper === upper ? upper : 0;
  30858. }
  30859. if (lower !== undefined) {
  30860. lower = toNumber(lower);
  30861. lower = lower === lower ? lower : 0;
  30862. }
  30863. return baseClamp(toNumber(number), lower, upper);
  30864. }
  30865. /**
  30866. * Checks if `n` is between `start` and up to, but not including, `end`. If
  30867. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  30868. * If `start` is greater than `end` the params are swapped to support
  30869. * negative ranges.
  30870. *
  30871. * @static
  30872. * @memberOf _
  30873. * @since 3.3.0
  30874. * @category Number
  30875. * @param {number} number The number to check.
  30876. * @param {number} [start=0] The start of the range.
  30877. * @param {number} end The end of the range.
  30878. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  30879. * @see _.range, _.rangeRight
  30880. * @example
  30881. *
  30882. * _.inRange(3, 2, 4);
  30883. * // => true
  30884. *
  30885. * _.inRange(4, 8);
  30886. * // => true
  30887. *
  30888. * _.inRange(4, 2);
  30889. * // => false
  30890. *
  30891. * _.inRange(2, 2);
  30892. * // => false
  30893. *
  30894. * _.inRange(1.2, 2);
  30895. * // => true
  30896. *
  30897. * _.inRange(5.2, 4);
  30898. * // => false
  30899. *
  30900. * _.inRange(-3, -2, -6);
  30901. * // => true
  30902. */
  30903. function inRange(number, start, end) {
  30904. start = toFinite(start);
  30905. if (end === undefined) {
  30906. end = start;
  30907. start = 0;
  30908. } else {
  30909. end = toFinite(end);
  30910. }
  30911. number = toNumber(number);
  30912. return baseInRange(number, start, end);
  30913. }
  30914. /**
  30915. * Produces a random number between the inclusive `lower` and `upper` bounds.
  30916. * If only one argument is provided a number between `0` and the given number
  30917. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  30918. * floats, a floating-point number is returned instead of an integer.
  30919. *
  30920. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  30921. * floating-point values which can produce unexpected results.
  30922. *
  30923. * @static
  30924. * @memberOf _
  30925. * @since 0.7.0
  30926. * @category Number
  30927. * @param {number} [lower=0] The lower bound.
  30928. * @param {number} [upper=1] The upper bound.
  30929. * @param {boolean} [floating] Specify returning a floating-point number.
  30930. * @returns {number} Returns the random number.
  30931. * @example
  30932. *
  30933. * _.random(0, 5);
  30934. * // => an integer between 0 and 5
  30935. *
  30936. * _.random(5);
  30937. * // => also an integer between 0 and 5
  30938. *
  30939. * _.random(5, true);
  30940. * // => a floating-point number between 0 and 5
  30941. *
  30942. * _.random(1.2, 5.2);
  30943. * // => a floating-point number between 1.2 and 5.2
  30944. */
  30945. function random(lower, upper, floating) {
  30946. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  30947. upper = floating = undefined;
  30948. }
  30949. if (floating === undefined) {
  30950. if (typeof upper == 'boolean') {
  30951. floating = upper;
  30952. upper = undefined;
  30953. }
  30954. else if (typeof lower == 'boolean') {
  30955. floating = lower;
  30956. lower = undefined;
  30957. }
  30958. }
  30959. if (lower === undefined && upper === undefined) {
  30960. lower = 0;
  30961. upper = 1;
  30962. }
  30963. else {
  30964. lower = toFinite(lower);
  30965. if (upper === undefined) {
  30966. upper = lower;
  30967. lower = 0;
  30968. } else {
  30969. upper = toFinite(upper);
  30970. }
  30971. }
  30972. if (lower > upper) {
  30973. var temp = lower;
  30974. lower = upper;
  30975. upper = temp;
  30976. }
  30977. if (floating || lower % 1 || upper % 1) {
  30978. var rand = nativeRandom();
  30979. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  30980. }
  30981. return baseRandom(lower, upper);
  30982. }
  30983. /*------------------------------------------------------------------------*/
  30984. /**
  30985. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  30986. *
  30987. * @static
  30988. * @memberOf _
  30989. * @since 3.0.0
  30990. * @category String
  30991. * @param {string} [string=''] The string to convert.
  30992. * @returns {string} Returns the camel cased string.
  30993. * @example
  30994. *
  30995. * _.camelCase('Foo Bar');
  30996. * // => 'fooBar'
  30997. *
  30998. * _.camelCase('--foo-bar--');
  30999. * // => 'fooBar'
  31000. *
  31001. * _.camelCase('__FOO_BAR__');
  31002. * // => 'fooBar'
  31003. */
  31004. var camelCase = createCompounder(function(result, word, index) {
  31005. word = word.toLowerCase();
  31006. return result + (index ? capitalize(word) : word);
  31007. });
  31008. /**
  31009. * Converts the first character of `string` to upper case and the remaining
  31010. * to lower case.
  31011. *
  31012. * @static
  31013. * @memberOf _
  31014. * @since 3.0.0
  31015. * @category String
  31016. * @param {string} [string=''] The string to capitalize.
  31017. * @returns {string} Returns the capitalized string.
  31018. * @example
  31019. *
  31020. * _.capitalize('FRED');
  31021. * // => 'Fred'
  31022. */
  31023. function capitalize(string) {
  31024. return upperFirst(toString(string).toLowerCase());
  31025. }
  31026. /**
  31027. * Deburrs `string` by converting
  31028. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  31029. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  31030. * letters to basic Latin letters and removing
  31031. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  31032. *
  31033. * @static
  31034. * @memberOf _
  31035. * @since 3.0.0
  31036. * @category String
  31037. * @param {string} [string=''] The string to deburr.
  31038. * @returns {string} Returns the deburred string.
  31039. * @example
  31040. *
  31041. * _.deburr('déjà vu');
  31042. * // => 'deja vu'
  31043. */
  31044. function deburr(string) {
  31045. string = toString(string);
  31046. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  31047. }
  31048. /**
  31049. * Checks if `string` ends with the given target string.
  31050. *
  31051. * @static
  31052. * @memberOf _
  31053. * @since 3.0.0
  31054. * @category String
  31055. * @param {string} [string=''] The string to inspect.
  31056. * @param {string} [target] The string to search for.
  31057. * @param {number} [position=string.length] The position to search up to.
  31058. * @returns {boolean} Returns `true` if `string` ends with `target`,
  31059. * else `false`.
  31060. * @example
  31061. *
  31062. * _.endsWith('abc', 'c');
  31063. * // => true
  31064. *
  31065. * _.endsWith('abc', 'b');
  31066. * // => false
  31067. *
  31068. * _.endsWith('abc', 'b', 2);
  31069. * // => true
  31070. */
  31071. function endsWith(string, target, position) {
  31072. string = toString(string);
  31073. target = baseToString(target);
  31074. var length = string.length;
  31075. position = position === undefined
  31076. ? length
  31077. : baseClamp(toInteger(position), 0, length);
  31078. var end = position;
  31079. position -= target.length;
  31080. return position >= 0 && string.slice(position, end) == target;
  31081. }
  31082. /**
  31083. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  31084. * corresponding HTML entities.
  31085. *
  31086. * **Note:** No other characters are escaped. To escape additional
  31087. * characters use a third-party library like [_he_](https://mths.be/he).
  31088. *
  31089. * Though the ">" character is escaped for symmetry, characters like
  31090. * ">" and "/" don't need escaping in HTML and have no special meaning
  31091. * unless they're part of a tag or unquoted attribute value. See
  31092. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  31093. * (under "semi-related fun fact") for more details.
  31094. *
  31095. * When working with HTML you should always
  31096. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  31097. * XSS vectors.
  31098. *
  31099. * @static
  31100. * @since 0.1.0
  31101. * @memberOf _
  31102. * @category String
  31103. * @param {string} [string=''] The string to escape.
  31104. * @returns {string} Returns the escaped string.
  31105. * @example
  31106. *
  31107. * _.escape('fred, barney, & pebbles');
  31108. * // => 'fred, barney, &amp; pebbles'
  31109. */
  31110. function escape(string) {
  31111. string = toString(string);
  31112. return (string && reHasUnescapedHtml.test(string))
  31113. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  31114. : string;
  31115. }
  31116. /**
  31117. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  31118. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  31119. *
  31120. * @static
  31121. * @memberOf _
  31122. * @since 3.0.0
  31123. * @category String
  31124. * @param {string} [string=''] The string to escape.
  31125. * @returns {string} Returns the escaped string.
  31126. * @example
  31127. *
  31128. * _.escapeRegExp('[lodash](https://lodash.com/)');
  31129. * // => '\[lodash\]\(https://lodash\.com/\)'
  31130. */
  31131. function escapeRegExp(string) {
  31132. string = toString(string);
  31133. return (string && reHasRegExpChar.test(string))
  31134. ? string.replace(reRegExpChar, '\\$&')
  31135. : string;
  31136. }
  31137. /**
  31138. * Converts `string` to
  31139. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  31140. *
  31141. * @static
  31142. * @memberOf _
  31143. * @since 3.0.0
  31144. * @category String
  31145. * @param {string} [string=''] The string to convert.
  31146. * @returns {string} Returns the kebab cased string.
  31147. * @example
  31148. *
  31149. * _.kebabCase('Foo Bar');
  31150. * // => 'foo-bar'
  31151. *
  31152. * _.kebabCase('fooBar');
  31153. * // => 'foo-bar'
  31154. *
  31155. * _.kebabCase('__FOO_BAR__');
  31156. * // => 'foo-bar'
  31157. */
  31158. var kebabCase = createCompounder(function(result, word, index) {
  31159. return result + (index ? '-' : '') + word.toLowerCase();
  31160. });
  31161. /**
  31162. * Converts `string`, as space separated words, to lower case.
  31163. *
  31164. * @static
  31165. * @memberOf _
  31166. * @since 4.0.0
  31167. * @category String
  31168. * @param {string} [string=''] The string to convert.
  31169. * @returns {string} Returns the lower cased string.
  31170. * @example
  31171. *
  31172. * _.lowerCase('--Foo-Bar--');
  31173. * // => 'foo bar'
  31174. *
  31175. * _.lowerCase('fooBar');
  31176. * // => 'foo bar'
  31177. *
  31178. * _.lowerCase('__FOO_BAR__');
  31179. * // => 'foo bar'
  31180. */
  31181. var lowerCase = createCompounder(function(result, word, index) {
  31182. return result + (index ? ' ' : '') + word.toLowerCase();
  31183. });
  31184. /**
  31185. * Converts the first character of `string` to lower case.
  31186. *
  31187. * @static
  31188. * @memberOf _
  31189. * @since 4.0.0
  31190. * @category String
  31191. * @param {string} [string=''] The string to convert.
  31192. * @returns {string} Returns the converted string.
  31193. * @example
  31194. *
  31195. * _.lowerFirst('Fred');
  31196. * // => 'fred'
  31197. *
  31198. * _.lowerFirst('FRED');
  31199. * // => 'fRED'
  31200. */
  31201. var lowerFirst = createCaseFirst('toLowerCase');
  31202. /**
  31203. * Pads `string` on the left and right sides if it's shorter than `length`.
  31204. * Padding characters are truncated if they can't be evenly divided by `length`.
  31205. *
  31206. * @static
  31207. * @memberOf _
  31208. * @since 3.0.0
  31209. * @category String
  31210. * @param {string} [string=''] The string to pad.
  31211. * @param {number} [length=0] The padding length.
  31212. * @param {string} [chars=' '] The string used as padding.
  31213. * @returns {string} Returns the padded string.
  31214. * @example
  31215. *
  31216. * _.pad('abc', 8);
  31217. * // => ' abc '
  31218. *
  31219. * _.pad('abc', 8, '_-');
  31220. * // => '_-abc_-_'
  31221. *
  31222. * _.pad('abc', 3);
  31223. * // => 'abc'
  31224. */
  31225. function pad(string, length, chars) {
  31226. string = toString(string);
  31227. length = toInteger(length);
  31228. var strLength = length ? stringSize(string) : 0;
  31229. if (!length || strLength >= length) {
  31230. return string;
  31231. }
  31232. var mid = (length - strLength) / 2;
  31233. return (
  31234. createPadding(nativeFloor(mid), chars) +
  31235. string +
  31236. createPadding(nativeCeil(mid), chars)
  31237. );
  31238. }
  31239. /**
  31240. * Pads `string` on the right side if it's shorter than `length`. Padding
  31241. * characters are truncated if they exceed `length`.
  31242. *
  31243. * @static
  31244. * @memberOf _
  31245. * @since 4.0.0
  31246. * @category String
  31247. * @param {string} [string=''] The string to pad.
  31248. * @param {number} [length=0] The padding length.
  31249. * @param {string} [chars=' '] The string used as padding.
  31250. * @returns {string} Returns the padded string.
  31251. * @example
  31252. *
  31253. * _.padEnd('abc', 6);
  31254. * // => 'abc '
  31255. *
  31256. * _.padEnd('abc', 6, '_-');
  31257. * // => 'abc_-_'
  31258. *
  31259. * _.padEnd('abc', 3);
  31260. * // => 'abc'
  31261. */
  31262. function padEnd(string, length, chars) {
  31263. string = toString(string);
  31264. length = toInteger(length);
  31265. var strLength = length ? stringSize(string) : 0;
  31266. return (length && strLength < length)
  31267. ? (string + createPadding(length - strLength, chars))
  31268. : string;
  31269. }
  31270. /**
  31271. * Pads `string` on the left side if it's shorter than `length`. Padding
  31272. * characters are truncated if they exceed `length`.
  31273. *
  31274. * @static
  31275. * @memberOf _
  31276. * @since 4.0.0
  31277. * @category String
  31278. * @param {string} [string=''] The string to pad.
  31279. * @param {number} [length=0] The padding length.
  31280. * @param {string} [chars=' '] The string used as padding.
  31281. * @returns {string} Returns the padded string.
  31282. * @example
  31283. *
  31284. * _.padStart('abc', 6);
  31285. * // => ' abc'
  31286. *
  31287. * _.padStart('abc', 6, '_-');
  31288. * // => '_-_abc'
  31289. *
  31290. * _.padStart('abc', 3);
  31291. * // => 'abc'
  31292. */
  31293. function padStart(string, length, chars) {
  31294. string = toString(string);
  31295. length = toInteger(length);
  31296. var strLength = length ? stringSize(string) : 0;
  31297. return (length && strLength < length)
  31298. ? (createPadding(length - strLength, chars) + string)
  31299. : string;
  31300. }
  31301. /**
  31302. * Converts `string` to an integer of the specified radix. If `radix` is
  31303. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  31304. * hexadecimal, in which case a `radix` of `16` is used.
  31305. *
  31306. * **Note:** This method aligns with the
  31307. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  31308. *
  31309. * @static
  31310. * @memberOf _
  31311. * @since 1.1.0
  31312. * @category String
  31313. * @param {string} string The string to convert.
  31314. * @param {number} [radix=10] The radix to interpret `value` by.
  31315. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31316. * @returns {number} Returns the converted integer.
  31317. * @example
  31318. *
  31319. * _.parseInt('08');
  31320. * // => 8
  31321. *
  31322. * _.map(['6', '08', '10'], _.parseInt);
  31323. * // => [6, 8, 10]
  31324. */
  31325. function parseInt(string, radix, guard) {
  31326. if (guard || radix == null) {
  31327. radix = 0;
  31328. } else if (radix) {
  31329. radix = +radix;
  31330. }
  31331. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  31332. }
  31333. /**
  31334. * Repeats the given string `n` times.
  31335. *
  31336. * @static
  31337. * @memberOf _
  31338. * @since 3.0.0
  31339. * @category String
  31340. * @param {string} [string=''] The string to repeat.
  31341. * @param {number} [n=1] The number of times to repeat the string.
  31342. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31343. * @returns {string} Returns the repeated string.
  31344. * @example
  31345. *
  31346. * _.repeat('*', 3);
  31347. * // => '***'
  31348. *
  31349. * _.repeat('abc', 2);
  31350. * // => 'abcabc'
  31351. *
  31352. * _.repeat('abc', 0);
  31353. * // => ''
  31354. */
  31355. function repeat(string, n, guard) {
  31356. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  31357. n = 1;
  31358. } else {
  31359. n = toInteger(n);
  31360. }
  31361. return baseRepeat(toString(string), n);
  31362. }
  31363. /**
  31364. * Replaces matches for `pattern` in `string` with `replacement`.
  31365. *
  31366. * **Note:** This method is based on
  31367. * [`String#replace`](https://mdn.io/String/replace).
  31368. *
  31369. * @static
  31370. * @memberOf _
  31371. * @since 4.0.0
  31372. * @category String
  31373. * @param {string} [string=''] The string to modify.
  31374. * @param {RegExp|string} pattern The pattern to replace.
  31375. * @param {Function|string} replacement The match replacement.
  31376. * @returns {string} Returns the modified string.
  31377. * @example
  31378. *
  31379. * _.replace('Hi Fred', 'Fred', 'Barney');
  31380. * // => 'Hi Barney'
  31381. */
  31382. function replace() {
  31383. var args = arguments,
  31384. string = toString(args[0]);
  31385. return args.length < 3 ? string : string.replace(args[1], args[2]);
  31386. }
  31387. /**
  31388. * Converts `string` to
  31389. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  31390. *
  31391. * @static
  31392. * @memberOf _
  31393. * @since 3.0.0
  31394. * @category String
  31395. * @param {string} [string=''] The string to convert.
  31396. * @returns {string} Returns the snake cased string.
  31397. * @example
  31398. *
  31399. * _.snakeCase('Foo Bar');
  31400. * // => 'foo_bar'
  31401. *
  31402. * _.snakeCase('fooBar');
  31403. * // => 'foo_bar'
  31404. *
  31405. * _.snakeCase('--FOO-BAR--');
  31406. * // => 'foo_bar'
  31407. */
  31408. var snakeCase = createCompounder(function(result, word, index) {
  31409. return result + (index ? '_' : '') + word.toLowerCase();
  31410. });
  31411. /**
  31412. * Splits `string` by `separator`.
  31413. *
  31414. * **Note:** This method is based on
  31415. * [`String#split`](https://mdn.io/String/split).
  31416. *
  31417. * @static
  31418. * @memberOf _
  31419. * @since 4.0.0
  31420. * @category String
  31421. * @param {string} [string=''] The string to split.
  31422. * @param {RegExp|string} separator The separator pattern to split by.
  31423. * @param {number} [limit] The length to truncate results to.
  31424. * @returns {Array} Returns the string segments.
  31425. * @example
  31426. *
  31427. * _.split('a-b-c', '-', 2);
  31428. * // => ['a', 'b']
  31429. */
  31430. function split(string, separator, limit) {
  31431. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  31432. separator = limit = undefined;
  31433. }
  31434. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  31435. if (!limit) {
  31436. return [];
  31437. }
  31438. string = toString(string);
  31439. if (string && (
  31440. typeof separator == 'string' ||
  31441. (separator != null && !isRegExp(separator))
  31442. )) {
  31443. separator = baseToString(separator);
  31444. if (!separator && hasUnicode(string)) {
  31445. return castSlice(stringToArray(string), 0, limit);
  31446. }
  31447. }
  31448. return string.split(separator, limit);
  31449. }
  31450. /**
  31451. * Converts `string` to
  31452. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  31453. *
  31454. * @static
  31455. * @memberOf _
  31456. * @since 3.1.0
  31457. * @category String
  31458. * @param {string} [string=''] The string to convert.
  31459. * @returns {string} Returns the start cased string.
  31460. * @example
  31461. *
  31462. * _.startCase('--foo-bar--');
  31463. * // => 'Foo Bar'
  31464. *
  31465. * _.startCase('fooBar');
  31466. * // => 'Foo Bar'
  31467. *
  31468. * _.startCase('__FOO_BAR__');
  31469. * // => 'FOO BAR'
  31470. */
  31471. var startCase = createCompounder(function(result, word, index) {
  31472. return result + (index ? ' ' : '') + upperFirst(word);
  31473. });
  31474. /**
  31475. * Checks if `string` starts with the given target string.
  31476. *
  31477. * @static
  31478. * @memberOf _
  31479. * @since 3.0.0
  31480. * @category String
  31481. * @param {string} [string=''] The string to inspect.
  31482. * @param {string} [target] The string to search for.
  31483. * @param {number} [position=0] The position to search from.
  31484. * @returns {boolean} Returns `true` if `string` starts with `target`,
  31485. * else `false`.
  31486. * @example
  31487. *
  31488. * _.startsWith('abc', 'a');
  31489. * // => true
  31490. *
  31491. * _.startsWith('abc', 'b');
  31492. * // => false
  31493. *
  31494. * _.startsWith('abc', 'b', 1);
  31495. * // => true
  31496. */
  31497. function startsWith(string, target, position) {
  31498. string = toString(string);
  31499. position = position == null
  31500. ? 0
  31501. : baseClamp(toInteger(position), 0, string.length);
  31502. target = baseToString(target);
  31503. return string.slice(position, position + target.length) == target;
  31504. }
  31505. /**
  31506. * Creates a compiled template function that can interpolate data properties
  31507. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  31508. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  31509. * properties may be accessed as free variables in the template. If a setting
  31510. * object is given, it takes precedence over `_.templateSettings` values.
  31511. *
  31512. * **Note:** In the development build `_.template` utilizes
  31513. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  31514. * for easier debugging.
  31515. *
  31516. * For more information on precompiling templates see
  31517. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  31518. *
  31519. * For more information on Chrome extension sandboxes see
  31520. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  31521. *
  31522. * @static
  31523. * @since 0.1.0
  31524. * @memberOf _
  31525. * @category String
  31526. * @param {string} [string=''] The template string.
  31527. * @param {Object} [options={}] The options object.
  31528. * @param {RegExp} [options.escape=_.templateSettings.escape]
  31529. * The HTML "escape" delimiter.
  31530. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  31531. * The "evaluate" delimiter.
  31532. * @param {Object} [options.imports=_.templateSettings.imports]
  31533. * An object to import into the template as free variables.
  31534. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  31535. * The "interpolate" delimiter.
  31536. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  31537. * The sourceURL of the compiled template.
  31538. * @param {string} [options.variable='obj']
  31539. * The data object variable name.
  31540. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31541. * @returns {Function} Returns the compiled template function.
  31542. * @example
  31543. *
  31544. * // Use the "interpolate" delimiter to create a compiled template.
  31545. * var compiled = _.template('hello <%= user %>!');
  31546. * compiled({ 'user': 'fred' });
  31547. * // => 'hello fred!'
  31548. *
  31549. * // Use the HTML "escape" delimiter to escape data property values.
  31550. * var compiled = _.template('<b><%- value %></b>');
  31551. * compiled({ 'value': '<script>' });
  31552. * // => '<b>&lt;script&gt;</b>'
  31553. *
  31554. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  31555. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  31556. * compiled({ 'users': ['fred', 'barney'] });
  31557. * // => '<li>fred</li><li>barney</li>'
  31558. *
  31559. * // Use the internal `print` function in "evaluate" delimiters.
  31560. * var compiled = _.template('<% print("hello " + user); %>!');
  31561. * compiled({ 'user': 'barney' });
  31562. * // => 'hello barney!'
  31563. *
  31564. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  31565. * // Disable support by replacing the "interpolate" delimiter.
  31566. * var compiled = _.template('hello ${ user }!');
  31567. * compiled({ 'user': 'pebbles' });
  31568. * // => 'hello pebbles!'
  31569. *
  31570. * // Use backslashes to treat delimiters as plain text.
  31571. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  31572. * compiled({ 'value': 'ignored' });
  31573. * // => '<%- value %>'
  31574. *
  31575. * // Use the `imports` option to import `jQuery` as `jq`.
  31576. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  31577. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  31578. * compiled({ 'users': ['fred', 'barney'] });
  31579. * // => '<li>fred</li><li>barney</li>'
  31580. *
  31581. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  31582. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  31583. * compiled(data);
  31584. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  31585. *
  31586. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  31587. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  31588. * compiled.source;
  31589. * // => function(data) {
  31590. * // var __t, __p = '';
  31591. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  31592. * // return __p;
  31593. * // }
  31594. *
  31595. * // Use custom template delimiters.
  31596. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  31597. * var compiled = _.template('hello {{ user }}!');
  31598. * compiled({ 'user': 'mustache' });
  31599. * // => 'hello mustache!'
  31600. *
  31601. * // Use the `source` property to inline compiled templates for meaningful
  31602. * // line numbers in error messages and stack traces.
  31603. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  31604. * var JST = {\
  31605. * "main": ' + _.template(mainText).source + '\
  31606. * };\
  31607. * ');
  31608. */
  31609. function template(string, options, guard) {
  31610. // Based on John Resig's `tmpl` implementation
  31611. // (http://ejohn.org/blog/javascript-micro-templating/)
  31612. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  31613. var settings = lodash.templateSettings;
  31614. if (guard && isIterateeCall(string, options, guard)) {
  31615. options = undefined;
  31616. }
  31617. string = toString(string);
  31618. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  31619. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  31620. importsKeys = keys(imports),
  31621. importsValues = baseValues(imports, importsKeys);
  31622. var isEscaping,
  31623. isEvaluating,
  31624. index = 0,
  31625. interpolate = options.interpolate || reNoMatch,
  31626. source = "__p += '";
  31627. // Compile the regexp to match each delimiter.
  31628. var reDelimiters = RegExp(
  31629. (options.escape || reNoMatch).source + '|' +
  31630. interpolate.source + '|' +
  31631. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  31632. (options.evaluate || reNoMatch).source + '|$'
  31633. , 'g');
  31634. // Use a sourceURL for easier debugging.
  31635. // The sourceURL gets injected into the source that's eval-ed, so be careful
  31636. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  31637. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  31638. var sourceURL = '//# sourceURL=' +
  31639. (hasOwnProperty.call(options, 'sourceURL')
  31640. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  31641. : ('lodash.templateSources[' + (++templateCounter) + ']')
  31642. ) + '\n';
  31643. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  31644. interpolateValue || (interpolateValue = esTemplateValue);
  31645. // Escape characters that can't be included in string literals.
  31646. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  31647. // Replace delimiters with snippets.
  31648. if (escapeValue) {
  31649. isEscaping = true;
  31650. source += "' +\n__e(" + escapeValue + ") +\n'";
  31651. }
  31652. if (evaluateValue) {
  31653. isEvaluating = true;
  31654. source += "';\n" + evaluateValue + ";\n__p += '";
  31655. }
  31656. if (interpolateValue) {
  31657. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  31658. }
  31659. index = offset + match.length;
  31660. // The JS engine embedded in Adobe products needs `match` returned in
  31661. // order to produce the correct `offset` value.
  31662. return match;
  31663. });
  31664. source += "';\n";
  31665. // If `variable` is not specified wrap a with-statement around the generated
  31666. // code to add the data object to the top of the scope chain.
  31667. // Like with sourceURL, we take care to not check the option's prototype,
  31668. // as this configuration is a code injection vector.
  31669. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  31670. if (!variable) {
  31671. source = 'with (obj) {\n' + source + '\n}\n';
  31672. }
  31673. // Cleanup code by stripping empty strings.
  31674. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  31675. .replace(reEmptyStringMiddle, '$1')
  31676. .replace(reEmptyStringTrailing, '$1;');
  31677. // Frame code as the function body.
  31678. source = 'function(' + (variable || 'obj') + ') {\n' +
  31679. (variable
  31680. ? ''
  31681. : 'obj || (obj = {});\n'
  31682. ) +
  31683. "var __t, __p = ''" +
  31684. (isEscaping
  31685. ? ', __e = _.escape'
  31686. : ''
  31687. ) +
  31688. (isEvaluating
  31689. ? ', __j = Array.prototype.join;\n' +
  31690. "function print() { __p += __j.call(arguments, '') }\n"
  31691. : ';\n'
  31692. ) +
  31693. source +
  31694. 'return __p\n}';
  31695. var result = attempt(function() {
  31696. return Function(importsKeys, sourceURL + 'return ' + source)
  31697. .apply(undefined, importsValues);
  31698. });
  31699. // Provide the compiled function's source by its `toString` method or
  31700. // the `source` property as a convenience for inlining compiled templates.
  31701. result.source = source;
  31702. if (isError(result)) {
  31703. throw result;
  31704. }
  31705. return result;
  31706. }
  31707. /**
  31708. * Converts `string`, as a whole, to lower case just like
  31709. * [String#toLowerCase](https://mdn.io/toLowerCase).
  31710. *
  31711. * @static
  31712. * @memberOf _
  31713. * @since 4.0.0
  31714. * @category String
  31715. * @param {string} [string=''] The string to convert.
  31716. * @returns {string} Returns the lower cased string.
  31717. * @example
  31718. *
  31719. * _.toLower('--Foo-Bar--');
  31720. * // => '--foo-bar--'
  31721. *
  31722. * _.toLower('fooBar');
  31723. * // => 'foobar'
  31724. *
  31725. * _.toLower('__FOO_BAR__');
  31726. * // => '__foo_bar__'
  31727. */
  31728. function toLower(value) {
  31729. return toString(value).toLowerCase();
  31730. }
  31731. /**
  31732. * Converts `string`, as a whole, to upper case just like
  31733. * [String#toUpperCase](https://mdn.io/toUpperCase).
  31734. *
  31735. * @static
  31736. * @memberOf _
  31737. * @since 4.0.0
  31738. * @category String
  31739. * @param {string} [string=''] The string to convert.
  31740. * @returns {string} Returns the upper cased string.
  31741. * @example
  31742. *
  31743. * _.toUpper('--foo-bar--');
  31744. * // => '--FOO-BAR--'
  31745. *
  31746. * _.toUpper('fooBar');
  31747. * // => 'FOOBAR'
  31748. *
  31749. * _.toUpper('__foo_bar__');
  31750. * // => '__FOO_BAR__'
  31751. */
  31752. function toUpper(value) {
  31753. return toString(value).toUpperCase();
  31754. }
  31755. /**
  31756. * Removes leading and trailing whitespace or specified characters from `string`.
  31757. *
  31758. * @static
  31759. * @memberOf _
  31760. * @since 3.0.0
  31761. * @category String
  31762. * @param {string} [string=''] The string to trim.
  31763. * @param {string} [chars=whitespace] The characters to trim.
  31764. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31765. * @returns {string} Returns the trimmed string.
  31766. * @example
  31767. *
  31768. * _.trim(' abc ');
  31769. * // => 'abc'
  31770. *
  31771. * _.trim('-_-abc-_-', '_-');
  31772. * // => 'abc'
  31773. *
  31774. * _.map([' foo ', ' bar '], _.trim);
  31775. * // => ['foo', 'bar']
  31776. */
  31777. function trim(string, chars, guard) {
  31778. string = toString(string);
  31779. if (string && (guard || chars === undefined)) {
  31780. return string.replace(reTrim, '');
  31781. }
  31782. if (!string || !(chars = baseToString(chars))) {
  31783. return string;
  31784. }
  31785. var strSymbols = stringToArray(string),
  31786. chrSymbols = stringToArray(chars),
  31787. start = charsStartIndex(strSymbols, chrSymbols),
  31788. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  31789. return castSlice(strSymbols, start, end).join('');
  31790. }
  31791. /**
  31792. * Removes trailing whitespace or specified characters from `string`.
  31793. *
  31794. * @static
  31795. * @memberOf _
  31796. * @since 4.0.0
  31797. * @category String
  31798. * @param {string} [string=''] The string to trim.
  31799. * @param {string} [chars=whitespace] The characters to trim.
  31800. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31801. * @returns {string} Returns the trimmed string.
  31802. * @example
  31803. *
  31804. * _.trimEnd(' abc ');
  31805. * // => ' abc'
  31806. *
  31807. * _.trimEnd('-_-abc-_-', '_-');
  31808. * // => '-_-abc'
  31809. */
  31810. function trimEnd(string, chars, guard) {
  31811. string = toString(string);
  31812. if (string && (guard || chars === undefined)) {
  31813. return string.replace(reTrimEnd, '');
  31814. }
  31815. if (!string || !(chars = baseToString(chars))) {
  31816. return string;
  31817. }
  31818. var strSymbols = stringToArray(string),
  31819. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  31820. return castSlice(strSymbols, 0, end).join('');
  31821. }
  31822. /**
  31823. * Removes leading whitespace or specified characters from `string`.
  31824. *
  31825. * @static
  31826. * @memberOf _
  31827. * @since 4.0.0
  31828. * @category String
  31829. * @param {string} [string=''] The string to trim.
  31830. * @param {string} [chars=whitespace] The characters to trim.
  31831. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31832. * @returns {string} Returns the trimmed string.
  31833. * @example
  31834. *
  31835. * _.trimStart(' abc ');
  31836. * // => 'abc '
  31837. *
  31838. * _.trimStart('-_-abc-_-', '_-');
  31839. * // => 'abc-_-'
  31840. */
  31841. function trimStart(string, chars, guard) {
  31842. string = toString(string);
  31843. if (string && (guard || chars === undefined)) {
  31844. return string.replace(reTrimStart, '');
  31845. }
  31846. if (!string || !(chars = baseToString(chars))) {
  31847. return string;
  31848. }
  31849. var strSymbols = stringToArray(string),
  31850. start = charsStartIndex(strSymbols, stringToArray(chars));
  31851. return castSlice(strSymbols, start).join('');
  31852. }
  31853. /**
  31854. * Truncates `string` if it's longer than the given maximum string length.
  31855. * The last characters of the truncated string are replaced with the omission
  31856. * string which defaults to "...".
  31857. *
  31858. * @static
  31859. * @memberOf _
  31860. * @since 4.0.0
  31861. * @category String
  31862. * @param {string} [string=''] The string to truncate.
  31863. * @param {Object} [options={}] The options object.
  31864. * @param {number} [options.length=30] The maximum string length.
  31865. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  31866. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  31867. * @returns {string} Returns the truncated string.
  31868. * @example
  31869. *
  31870. * _.truncate('hi-diddly-ho there, neighborino');
  31871. * // => 'hi-diddly-ho there, neighbo...'
  31872. *
  31873. * _.truncate('hi-diddly-ho there, neighborino', {
  31874. * 'length': 24,
  31875. * 'separator': ' '
  31876. * });
  31877. * // => 'hi-diddly-ho there,...'
  31878. *
  31879. * _.truncate('hi-diddly-ho there, neighborino', {
  31880. * 'length': 24,
  31881. * 'separator': /,? +/
  31882. * });
  31883. * // => 'hi-diddly-ho there...'
  31884. *
  31885. * _.truncate('hi-diddly-ho there, neighborino', {
  31886. * 'omission': ' [...]'
  31887. * });
  31888. * // => 'hi-diddly-ho there, neig [...]'
  31889. */
  31890. function truncate(string, options) {
  31891. var length = DEFAULT_TRUNC_LENGTH,
  31892. omission = DEFAULT_TRUNC_OMISSION;
  31893. if (isObject(options)) {
  31894. var separator = 'separator' in options ? options.separator : separator;
  31895. length = 'length' in options ? toInteger(options.length) : length;
  31896. omission = 'omission' in options ? baseToString(options.omission) : omission;
  31897. }
  31898. string = toString(string);
  31899. var strLength = string.length;
  31900. if (hasUnicode(string)) {
  31901. var strSymbols = stringToArray(string);
  31902. strLength = strSymbols.length;
  31903. }
  31904. if (length >= strLength) {
  31905. return string;
  31906. }
  31907. var end = length - stringSize(omission);
  31908. if (end < 1) {
  31909. return omission;
  31910. }
  31911. var result = strSymbols
  31912. ? castSlice(strSymbols, 0, end).join('')
  31913. : string.slice(0, end);
  31914. if (separator === undefined) {
  31915. return result + omission;
  31916. }
  31917. if (strSymbols) {
  31918. end += (result.length - end);
  31919. }
  31920. if (isRegExp(separator)) {
  31921. if (string.slice(end).search(separator)) {
  31922. var match,
  31923. substring = result;
  31924. if (!separator.global) {
  31925. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  31926. }
  31927. separator.lastIndex = 0;
  31928. while ((match = separator.exec(substring))) {
  31929. var newEnd = match.index;
  31930. }
  31931. result = result.slice(0, newEnd === undefined ? end : newEnd);
  31932. }
  31933. } else if (string.indexOf(baseToString(separator), end) != end) {
  31934. var index = result.lastIndexOf(separator);
  31935. if (index > -1) {
  31936. result = result.slice(0, index);
  31937. }
  31938. }
  31939. return result + omission;
  31940. }
  31941. /**
  31942. * The inverse of `_.escape`; this method converts the HTML entities
  31943. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  31944. * their corresponding characters.
  31945. *
  31946. * **Note:** No other HTML entities are unescaped. To unescape additional
  31947. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  31948. *
  31949. * @static
  31950. * @memberOf _
  31951. * @since 0.6.0
  31952. * @category String
  31953. * @param {string} [string=''] The string to unescape.
  31954. * @returns {string} Returns the unescaped string.
  31955. * @example
  31956. *
  31957. * _.unescape('fred, barney, &amp; pebbles');
  31958. * // => 'fred, barney, & pebbles'
  31959. */
  31960. function unescape(string) {
  31961. string = toString(string);
  31962. return (string && reHasEscapedHtml.test(string))
  31963. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  31964. : string;
  31965. }
  31966. /**
  31967. * Converts `string`, as space separated words, to upper case.
  31968. *
  31969. * @static
  31970. * @memberOf _
  31971. * @since 4.0.0
  31972. * @category String
  31973. * @param {string} [string=''] The string to convert.
  31974. * @returns {string} Returns the upper cased string.
  31975. * @example
  31976. *
  31977. * _.upperCase('--foo-bar');
  31978. * // => 'FOO BAR'
  31979. *
  31980. * _.upperCase('fooBar');
  31981. * // => 'FOO BAR'
  31982. *
  31983. * _.upperCase('__foo_bar__');
  31984. * // => 'FOO BAR'
  31985. */
  31986. var upperCase = createCompounder(function(result, word, index) {
  31987. return result + (index ? ' ' : '') + word.toUpperCase();
  31988. });
  31989. /**
  31990. * Converts the first character of `string` to upper case.
  31991. *
  31992. * @static
  31993. * @memberOf _
  31994. * @since 4.0.0
  31995. * @category String
  31996. * @param {string} [string=''] The string to convert.
  31997. * @returns {string} Returns the converted string.
  31998. * @example
  31999. *
  32000. * _.upperFirst('fred');
  32001. * // => 'Fred'
  32002. *
  32003. * _.upperFirst('FRED');
  32004. * // => 'FRED'
  32005. */
  32006. var upperFirst = createCaseFirst('toUpperCase');
  32007. /**
  32008. * Splits `string` into an array of its words.
  32009. *
  32010. * @static
  32011. * @memberOf _
  32012. * @since 3.0.0
  32013. * @category String
  32014. * @param {string} [string=''] The string to inspect.
  32015. * @param {RegExp|string} [pattern] The pattern to match words.
  32016. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  32017. * @returns {Array} Returns the words of `string`.
  32018. * @example
  32019. *
  32020. * _.words('fred, barney, & pebbles');
  32021. * // => ['fred', 'barney', 'pebbles']
  32022. *
  32023. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  32024. * // => ['fred', 'barney', '&', 'pebbles']
  32025. */
  32026. function words(string, pattern, guard) {
  32027. string = toString(string);
  32028. pattern = guard ? undefined : pattern;
  32029. if (pattern === undefined) {
  32030. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  32031. }
  32032. return string.match(pattern) || [];
  32033. }
  32034. /*------------------------------------------------------------------------*/
  32035. /**
  32036. * Attempts to invoke `func`, returning either the result or the caught error
  32037. * object. Any additional arguments are provided to `func` when it's invoked.
  32038. *
  32039. * @static
  32040. * @memberOf _
  32041. * @since 3.0.0
  32042. * @category Util
  32043. * @param {Function} func The function to attempt.
  32044. * @param {...*} [args] The arguments to invoke `func` with.
  32045. * @returns {*} Returns the `func` result or error object.
  32046. * @example
  32047. *
  32048. * // Avoid throwing errors for invalid selectors.
  32049. * var elements = _.attempt(function(selector) {
  32050. * return document.querySelectorAll(selector);
  32051. * }, '>_>');
  32052. *
  32053. * if (_.isError(elements)) {
  32054. * elements = [];
  32055. * }
  32056. */
  32057. var attempt = baseRest(function(func, args) {
  32058. try {
  32059. return apply(func, undefined, args);
  32060. } catch (e) {
  32061. return isError(e) ? e : new Error(e);
  32062. }
  32063. });
  32064. /**
  32065. * Binds methods of an object to the object itself, overwriting the existing
  32066. * method.
  32067. *
  32068. * **Note:** This method doesn't set the "length" property of bound functions.
  32069. *
  32070. * @static
  32071. * @since 0.1.0
  32072. * @memberOf _
  32073. * @category Util
  32074. * @param {Object} object The object to bind and assign the bound methods to.
  32075. * @param {...(string|string[])} methodNames The object method names to bind.
  32076. * @returns {Object} Returns `object`.
  32077. * @example
  32078. *
  32079. * var view = {
  32080. * 'label': 'docs',
  32081. * 'click': function() {
  32082. * console.log('clicked ' + this.label);
  32083. * }
  32084. * };
  32085. *
  32086. * _.bindAll(view, ['click']);
  32087. * jQuery(element).on('click', view.click);
  32088. * // => Logs 'clicked docs' when clicked.
  32089. */
  32090. var bindAll = flatRest(function(object, methodNames) {
  32091. arrayEach(methodNames, function(key) {
  32092. key = toKey(key);
  32093. baseAssignValue(object, key, bind(object[key], object));
  32094. });
  32095. return object;
  32096. });
  32097. /**
  32098. * Creates a function that iterates over `pairs` and invokes the corresponding
  32099. * function of the first predicate to return truthy. The predicate-function
  32100. * pairs are invoked with the `this` binding and arguments of the created
  32101. * function.
  32102. *
  32103. * @static
  32104. * @memberOf _
  32105. * @since 4.0.0
  32106. * @category Util
  32107. * @param {Array} pairs The predicate-function pairs.
  32108. * @returns {Function} Returns the new composite function.
  32109. * @example
  32110. *
  32111. * var func = _.cond([
  32112. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  32113. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  32114. * [_.stubTrue, _.constant('no match')]
  32115. * ]);
  32116. *
  32117. * func({ 'a': 1, 'b': 2 });
  32118. * // => 'matches A'
  32119. *
  32120. * func({ 'a': 0, 'b': 1 });
  32121. * // => 'matches B'
  32122. *
  32123. * func({ 'a': '1', 'b': '2' });
  32124. * // => 'no match'
  32125. */
  32126. function cond(pairs) {
  32127. var length = pairs == null ? 0 : pairs.length,
  32128. toIteratee = getIteratee();
  32129. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  32130. if (typeof pair[1] != 'function') {
  32131. throw new TypeError(FUNC_ERROR_TEXT);
  32132. }
  32133. return [toIteratee(pair[0]), pair[1]];
  32134. });
  32135. return baseRest(function(args) {
  32136. var index = -1;
  32137. while (++index < length) {
  32138. var pair = pairs[index];
  32139. if (apply(pair[0], this, args)) {
  32140. return apply(pair[1], this, args);
  32141. }
  32142. }
  32143. });
  32144. }
  32145. /**
  32146. * Creates a function that invokes the predicate properties of `source` with
  32147. * the corresponding property values of a given object, returning `true` if
  32148. * all predicates return truthy, else `false`.
  32149. *
  32150. * **Note:** The created function is equivalent to `_.conformsTo` with
  32151. * `source` partially applied.
  32152. *
  32153. * @static
  32154. * @memberOf _
  32155. * @since 4.0.0
  32156. * @category Util
  32157. * @param {Object} source The object of property predicates to conform to.
  32158. * @returns {Function} Returns the new spec function.
  32159. * @example
  32160. *
  32161. * var objects = [
  32162. * { 'a': 2, 'b': 1 },
  32163. * { 'a': 1, 'b': 2 }
  32164. * ];
  32165. *
  32166. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  32167. * // => [{ 'a': 1, 'b': 2 }]
  32168. */
  32169. function conforms(source) {
  32170. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  32171. }
  32172. /**
  32173. * Creates a function that returns `value`.
  32174. *
  32175. * @static
  32176. * @memberOf _
  32177. * @since 2.4.0
  32178. * @category Util
  32179. * @param {*} value The value to return from the new function.
  32180. * @returns {Function} Returns the new constant function.
  32181. * @example
  32182. *
  32183. * var objects = _.times(2, _.constant({ 'a': 1 }));
  32184. *
  32185. * console.log(objects);
  32186. * // => [{ 'a': 1 }, { 'a': 1 }]
  32187. *
  32188. * console.log(objects[0] === objects[1]);
  32189. * // => true
  32190. */
  32191. function constant(value) {
  32192. return function() {
  32193. return value;
  32194. };
  32195. }
  32196. /**
  32197. * Checks `value` to determine whether a default value should be returned in
  32198. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  32199. * or `undefined`.
  32200. *
  32201. * @static
  32202. * @memberOf _
  32203. * @since 4.14.0
  32204. * @category Util
  32205. * @param {*} value The value to check.
  32206. * @param {*} defaultValue The default value.
  32207. * @returns {*} Returns the resolved value.
  32208. * @example
  32209. *
  32210. * _.defaultTo(1, 10);
  32211. * // => 1
  32212. *
  32213. * _.defaultTo(undefined, 10);
  32214. * // => 10
  32215. */
  32216. function defaultTo(value, defaultValue) {
  32217. return (value == null || value !== value) ? defaultValue : value;
  32218. }
  32219. /**
  32220. * Creates a function that returns the result of invoking the given functions
  32221. * with the `this` binding of the created function, where each successive
  32222. * invocation is supplied the return value of the previous.
  32223. *
  32224. * @static
  32225. * @memberOf _
  32226. * @since 3.0.0
  32227. * @category Util
  32228. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32229. * @returns {Function} Returns the new composite function.
  32230. * @see _.flowRight
  32231. * @example
  32232. *
  32233. * function square(n) {
  32234. * return n * n;
  32235. * }
  32236. *
  32237. * var addSquare = _.flow([_.add, square]);
  32238. * addSquare(1, 2);
  32239. * // => 9
  32240. */
  32241. var flow = createFlow();
  32242. /**
  32243. * This method is like `_.flow` except that it creates a function that
  32244. * invokes the given functions from right to left.
  32245. *
  32246. * @static
  32247. * @since 3.0.0
  32248. * @memberOf _
  32249. * @category Util
  32250. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32251. * @returns {Function} Returns the new composite function.
  32252. * @see _.flow
  32253. * @example
  32254. *
  32255. * function square(n) {
  32256. * return n * n;
  32257. * }
  32258. *
  32259. * var addSquare = _.flowRight([square, _.add]);
  32260. * addSquare(1, 2);
  32261. * // => 9
  32262. */
  32263. var flowRight = createFlow(true);
  32264. /**
  32265. * This method returns the first argument it receives.
  32266. *
  32267. * @static
  32268. * @since 0.1.0
  32269. * @memberOf _
  32270. * @category Util
  32271. * @param {*} value Any value.
  32272. * @returns {*} Returns `value`.
  32273. * @example
  32274. *
  32275. * var object = { 'a': 1 };
  32276. *
  32277. * console.log(_.identity(object) === object);
  32278. * // => true
  32279. */
  32280. function identity(value) {
  32281. return value;
  32282. }
  32283. /**
  32284. * Creates a function that invokes `func` with the arguments of the created
  32285. * function. If `func` is a property name, the created function returns the
  32286. * property value for a given element. If `func` is an array or object, the
  32287. * created function returns `true` for elements that contain the equivalent
  32288. * source properties, otherwise it returns `false`.
  32289. *
  32290. * @static
  32291. * @since 4.0.0
  32292. * @memberOf _
  32293. * @category Util
  32294. * @param {*} [func=_.identity] The value to convert to a callback.
  32295. * @returns {Function} Returns the callback.
  32296. * @example
  32297. *
  32298. * var users = [
  32299. * { 'user': 'barney', 'age': 36, 'active': true },
  32300. * { 'user': 'fred', 'age': 40, 'active': false }
  32301. * ];
  32302. *
  32303. * // The `_.matches` iteratee shorthand.
  32304. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  32305. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  32306. *
  32307. * // The `_.matchesProperty` iteratee shorthand.
  32308. * _.filter(users, _.iteratee(['user', 'fred']));
  32309. * // => [{ 'user': 'fred', 'age': 40 }]
  32310. *
  32311. * // The `_.property` iteratee shorthand.
  32312. * _.map(users, _.iteratee('user'));
  32313. * // => ['barney', 'fred']
  32314. *
  32315. * // Create custom iteratee shorthands.
  32316. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  32317. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  32318. * return func.test(string);
  32319. * };
  32320. * });
  32321. *
  32322. * _.filter(['abc', 'def'], /ef/);
  32323. * // => ['def']
  32324. */
  32325. function iteratee(func) {
  32326. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  32327. }
  32328. /**
  32329. * Creates a function that performs a partial deep comparison between a given
  32330. * object and `source`, returning `true` if the given object has equivalent
  32331. * property values, else `false`.
  32332. *
  32333. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  32334. * partially applied.
  32335. *
  32336. * Partial comparisons will match empty array and empty object `source`
  32337. * values against any array or object value, respectively. See `_.isEqual`
  32338. * for a list of supported value comparisons.
  32339. *
  32340. * @static
  32341. * @memberOf _
  32342. * @since 3.0.0
  32343. * @category Util
  32344. * @param {Object} source The object of property values to match.
  32345. * @returns {Function} Returns the new spec function.
  32346. * @example
  32347. *
  32348. * var objects = [
  32349. * { 'a': 1, 'b': 2, 'c': 3 },
  32350. * { 'a': 4, 'b': 5, 'c': 6 }
  32351. * ];
  32352. *
  32353. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  32354. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  32355. */
  32356. function matches(source) {
  32357. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  32358. }
  32359. /**
  32360. * Creates a function that performs a partial deep comparison between the
  32361. * value at `path` of a given object to `srcValue`, returning `true` if the
  32362. * object value is equivalent, else `false`.
  32363. *
  32364. * **Note:** Partial comparisons will match empty array and empty object
  32365. * `srcValue` values against any array or object value, respectively. See
  32366. * `_.isEqual` for a list of supported value comparisons.
  32367. *
  32368. * @static
  32369. * @memberOf _
  32370. * @since 3.2.0
  32371. * @category Util
  32372. * @param {Array|string} path The path of the property to get.
  32373. * @param {*} srcValue The value to match.
  32374. * @returns {Function} Returns the new spec function.
  32375. * @example
  32376. *
  32377. * var objects = [
  32378. * { 'a': 1, 'b': 2, 'c': 3 },
  32379. * { 'a': 4, 'b': 5, 'c': 6 }
  32380. * ];
  32381. *
  32382. * _.find(objects, _.matchesProperty('a', 4));
  32383. * // => { 'a': 4, 'b': 5, 'c': 6 }
  32384. */
  32385. function matchesProperty(path, srcValue) {
  32386. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  32387. }
  32388. /**
  32389. * Creates a function that invokes the method at `path` of a given object.
  32390. * Any additional arguments are provided to the invoked method.
  32391. *
  32392. * @static
  32393. * @memberOf _
  32394. * @since 3.7.0
  32395. * @category Util
  32396. * @param {Array|string} path The path of the method to invoke.
  32397. * @param {...*} [args] The arguments to invoke the method with.
  32398. * @returns {Function} Returns the new invoker function.
  32399. * @example
  32400. *
  32401. * var objects = [
  32402. * { 'a': { 'b': _.constant(2) } },
  32403. * { 'a': { 'b': _.constant(1) } }
  32404. * ];
  32405. *
  32406. * _.map(objects, _.method('a.b'));
  32407. * // => [2, 1]
  32408. *
  32409. * _.map(objects, _.method(['a', 'b']));
  32410. * // => [2, 1]
  32411. */
  32412. var method = baseRest(function(path, args) {
  32413. return function(object) {
  32414. return baseInvoke(object, path, args);
  32415. };
  32416. });
  32417. /**
  32418. * The opposite of `_.method`; this method creates a function that invokes
  32419. * the method at a given path of `object`. Any additional arguments are
  32420. * provided to the invoked method.
  32421. *
  32422. * @static
  32423. * @memberOf _
  32424. * @since 3.7.0
  32425. * @category Util
  32426. * @param {Object} object The object to query.
  32427. * @param {...*} [args] The arguments to invoke the method with.
  32428. * @returns {Function} Returns the new invoker function.
  32429. * @example
  32430. *
  32431. * var array = _.times(3, _.constant),
  32432. * object = { 'a': array, 'b': array, 'c': array };
  32433. *
  32434. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  32435. * // => [2, 0]
  32436. *
  32437. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  32438. * // => [2, 0]
  32439. */
  32440. var methodOf = baseRest(function(object, args) {
  32441. return function(path) {
  32442. return baseInvoke(object, path, args);
  32443. };
  32444. });
  32445. /**
  32446. * Adds all own enumerable string keyed function properties of a source
  32447. * object to the destination object. If `object` is a function, then methods
  32448. * are added to its prototype as well.
  32449. *
  32450. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  32451. * avoid conflicts caused by modifying the original.
  32452. *
  32453. * @static
  32454. * @since 0.1.0
  32455. * @memberOf _
  32456. * @category Util
  32457. * @param {Function|Object} [object=lodash] The destination object.
  32458. * @param {Object} source The object of functions to add.
  32459. * @param {Object} [options={}] The options object.
  32460. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  32461. * @returns {Function|Object} Returns `object`.
  32462. * @example
  32463. *
  32464. * function vowels(string) {
  32465. * return _.filter(string, function(v) {
  32466. * return /[aeiou]/i.test(v);
  32467. * });
  32468. * }
  32469. *
  32470. * _.mixin({ 'vowels': vowels });
  32471. * _.vowels('fred');
  32472. * // => ['e']
  32473. *
  32474. * _('fred').vowels().value();
  32475. * // => ['e']
  32476. *
  32477. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  32478. * _('fred').vowels();
  32479. * // => ['e']
  32480. */
  32481. function mixin(object, source, options) {
  32482. var props = keys(source),
  32483. methodNames = baseFunctions(source, props);
  32484. if (options == null &&
  32485. !(isObject(source) && (methodNames.length || !props.length))) {
  32486. options = source;
  32487. source = object;
  32488. object = this;
  32489. methodNames = baseFunctions(source, keys(source));
  32490. }
  32491. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  32492. isFunc = isFunction(object);
  32493. arrayEach(methodNames, function(methodName) {
  32494. var func = source[methodName];
  32495. object[methodName] = func;
  32496. if (isFunc) {
  32497. object.prototype[methodName] = function() {
  32498. var chainAll = this.__chain__;
  32499. if (chain || chainAll) {
  32500. var result = object(this.__wrapped__),
  32501. actions = result.__actions__ = copyArray(this.__actions__);
  32502. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  32503. result.__chain__ = chainAll;
  32504. return result;
  32505. }
  32506. return func.apply(object, arrayPush([this.value()], arguments));
  32507. };
  32508. }
  32509. });
  32510. return object;
  32511. }
  32512. /**
  32513. * Reverts the `_` variable to its previous value and returns a reference to
  32514. * the `lodash` function.
  32515. *
  32516. * @static
  32517. * @since 0.1.0
  32518. * @memberOf _
  32519. * @category Util
  32520. * @returns {Function} Returns the `lodash` function.
  32521. * @example
  32522. *
  32523. * var lodash = _.noConflict();
  32524. */
  32525. function noConflict() {
  32526. if (root._ === this) {
  32527. root._ = oldDash;
  32528. }
  32529. return this;
  32530. }
  32531. /**
  32532. * This method returns `undefined`.
  32533. *
  32534. * @static
  32535. * @memberOf _
  32536. * @since 2.3.0
  32537. * @category Util
  32538. * @example
  32539. *
  32540. * _.times(2, _.noop);
  32541. * // => [undefined, undefined]
  32542. */
  32543. function noop() {
  32544. // No operation performed.
  32545. }
  32546. /**
  32547. * Creates a function that gets the argument at index `n`. If `n` is negative,
  32548. * the nth argument from the end is returned.
  32549. *
  32550. * @static
  32551. * @memberOf _
  32552. * @since 4.0.0
  32553. * @category Util
  32554. * @param {number} [n=0] The index of the argument to return.
  32555. * @returns {Function} Returns the new pass-thru function.
  32556. * @example
  32557. *
  32558. * var func = _.nthArg(1);
  32559. * func('a', 'b', 'c', 'd');
  32560. * // => 'b'
  32561. *
  32562. * var func = _.nthArg(-2);
  32563. * func('a', 'b', 'c', 'd');
  32564. * // => 'c'
  32565. */
  32566. function nthArg(n) {
  32567. n = toInteger(n);
  32568. return baseRest(function(args) {
  32569. return baseNth(args, n);
  32570. });
  32571. }
  32572. /**
  32573. * Creates a function that invokes `iteratees` with the arguments it receives
  32574. * and returns their results.
  32575. *
  32576. * @static
  32577. * @memberOf _
  32578. * @since 4.0.0
  32579. * @category Util
  32580. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  32581. * The iteratees to invoke.
  32582. * @returns {Function} Returns the new function.
  32583. * @example
  32584. *
  32585. * var func = _.over([Math.max, Math.min]);
  32586. *
  32587. * func(1, 2, 3, 4);
  32588. * // => [4, 1]
  32589. */
  32590. var over = createOver(arrayMap);
  32591. /**
  32592. * Creates a function that checks if **all** of the `predicates` return
  32593. * truthy when invoked with the arguments it receives.
  32594. *
  32595. * @static
  32596. * @memberOf _
  32597. * @since 4.0.0
  32598. * @category Util
  32599. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32600. * The predicates to check.
  32601. * @returns {Function} Returns the new function.
  32602. * @example
  32603. *
  32604. * var func = _.overEvery([Boolean, isFinite]);
  32605. *
  32606. * func('1');
  32607. * // => true
  32608. *
  32609. * func(null);
  32610. * // => false
  32611. *
  32612. * func(NaN);
  32613. * // => false
  32614. */
  32615. var overEvery = createOver(arrayEvery);
  32616. /**
  32617. * Creates a function that checks if **any** 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 = _.overSome([Boolean, isFinite]);
  32630. *
  32631. * func('1');
  32632. * // => true
  32633. *
  32634. * func(null);
  32635. * // => true
  32636. *
  32637. * func(NaN);
  32638. * // => false
  32639. */
  32640. var overSome = createOver(arraySome);
  32641. /**
  32642. * Creates a function that returns the value at `path` of a given object.
  32643. *
  32644. * @static
  32645. * @memberOf _
  32646. * @since 2.4.0
  32647. * @category Util
  32648. * @param {Array|string} path The path of the property to get.
  32649. * @returns {Function} Returns the new accessor function.
  32650. * @example
  32651. *
  32652. * var objects = [
  32653. * { 'a': { 'b': 2 } },
  32654. * { 'a': { 'b': 1 } }
  32655. * ];
  32656. *
  32657. * _.map(objects, _.property('a.b'));
  32658. * // => [2, 1]
  32659. *
  32660. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  32661. * // => [1, 2]
  32662. */
  32663. function property(path) {
  32664. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  32665. }
  32666. /**
  32667. * The opposite of `_.property`; this method creates a function that returns
  32668. * the value at a given path of `object`.
  32669. *
  32670. * @static
  32671. * @memberOf _
  32672. * @since 3.0.0
  32673. * @category Util
  32674. * @param {Object} object The object to query.
  32675. * @returns {Function} Returns the new accessor function.
  32676. * @example
  32677. *
  32678. * var array = [0, 1, 2],
  32679. * object = { 'a': array, 'b': array, 'c': array };
  32680. *
  32681. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  32682. * // => [2, 0]
  32683. *
  32684. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  32685. * // => [2, 0]
  32686. */
  32687. function propertyOf(object) {
  32688. return function(path) {
  32689. return object == null ? undefined : baseGet(object, path);
  32690. };
  32691. }
  32692. /**
  32693. * Creates an array of numbers (positive and/or negative) progressing from
  32694. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  32695. * `start` is specified without an `end` or `step`. If `end` is not specified,
  32696. * it's set to `start` with `start` then set to `0`.
  32697. *
  32698. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  32699. * floating-point values which can produce unexpected results.
  32700. *
  32701. * @static
  32702. * @since 0.1.0
  32703. * @memberOf _
  32704. * @category Util
  32705. * @param {number} [start=0] The start of the range.
  32706. * @param {number} end The end of the range.
  32707. * @param {number} [step=1] The value to increment or decrement by.
  32708. * @returns {Array} Returns the range of numbers.
  32709. * @see _.inRange, _.rangeRight
  32710. * @example
  32711. *
  32712. * _.range(4);
  32713. * // => [0, 1, 2, 3]
  32714. *
  32715. * _.range(-4);
  32716. * // => [0, -1, -2, -3]
  32717. *
  32718. * _.range(1, 5);
  32719. * // => [1, 2, 3, 4]
  32720. *
  32721. * _.range(0, 20, 5);
  32722. * // => [0, 5, 10, 15]
  32723. *
  32724. * _.range(0, -4, -1);
  32725. * // => [0, -1, -2, -3]
  32726. *
  32727. * _.range(1, 4, 0);
  32728. * // => [1, 1, 1]
  32729. *
  32730. * _.range(0);
  32731. * // => []
  32732. */
  32733. var range = createRange();
  32734. /**
  32735. * This method is like `_.range` except that it populates values in
  32736. * descending order.
  32737. *
  32738. * @static
  32739. * @memberOf _
  32740. * @since 4.0.0
  32741. * @category Util
  32742. * @param {number} [start=0] The start of the range.
  32743. * @param {number} end The end of the range.
  32744. * @param {number} [step=1] The value to increment or decrement by.
  32745. * @returns {Array} Returns the range of numbers.
  32746. * @see _.inRange, _.range
  32747. * @example
  32748. *
  32749. * _.rangeRight(4);
  32750. * // => [3, 2, 1, 0]
  32751. *
  32752. * _.rangeRight(-4);
  32753. * // => [-3, -2, -1, 0]
  32754. *
  32755. * _.rangeRight(1, 5);
  32756. * // => [4, 3, 2, 1]
  32757. *
  32758. * _.rangeRight(0, 20, 5);
  32759. * // => [15, 10, 5, 0]
  32760. *
  32761. * _.rangeRight(0, -4, -1);
  32762. * // => [-3, -2, -1, 0]
  32763. *
  32764. * _.rangeRight(1, 4, 0);
  32765. * // => [1, 1, 1]
  32766. *
  32767. * _.rangeRight(0);
  32768. * // => []
  32769. */
  32770. var rangeRight = createRange(true);
  32771. /**
  32772. * This method returns a new empty array.
  32773. *
  32774. * @static
  32775. * @memberOf _
  32776. * @since 4.13.0
  32777. * @category Util
  32778. * @returns {Array} Returns the new empty array.
  32779. * @example
  32780. *
  32781. * var arrays = _.times(2, _.stubArray);
  32782. *
  32783. * console.log(arrays);
  32784. * // => [[], []]
  32785. *
  32786. * console.log(arrays[0] === arrays[1]);
  32787. * // => false
  32788. */
  32789. function stubArray() {
  32790. return [];
  32791. }
  32792. /**
  32793. * This method returns `false`.
  32794. *
  32795. * @static
  32796. * @memberOf _
  32797. * @since 4.13.0
  32798. * @category Util
  32799. * @returns {boolean} Returns `false`.
  32800. * @example
  32801. *
  32802. * _.times(2, _.stubFalse);
  32803. * // => [false, false]
  32804. */
  32805. function stubFalse() {
  32806. return false;
  32807. }
  32808. /**
  32809. * This method returns a new empty object.
  32810. *
  32811. * @static
  32812. * @memberOf _
  32813. * @since 4.13.0
  32814. * @category Util
  32815. * @returns {Object} Returns the new empty object.
  32816. * @example
  32817. *
  32818. * var objects = _.times(2, _.stubObject);
  32819. *
  32820. * console.log(objects);
  32821. * // => [{}, {}]
  32822. *
  32823. * console.log(objects[0] === objects[1]);
  32824. * // => false
  32825. */
  32826. function stubObject() {
  32827. return {};
  32828. }
  32829. /**
  32830. * This method returns an empty string.
  32831. *
  32832. * @static
  32833. * @memberOf _
  32834. * @since 4.13.0
  32835. * @category Util
  32836. * @returns {string} Returns the empty string.
  32837. * @example
  32838. *
  32839. * _.times(2, _.stubString);
  32840. * // => ['', '']
  32841. */
  32842. function stubString() {
  32843. return '';
  32844. }
  32845. /**
  32846. * This method returns `true`.
  32847. *
  32848. * @static
  32849. * @memberOf _
  32850. * @since 4.13.0
  32851. * @category Util
  32852. * @returns {boolean} Returns `true`.
  32853. * @example
  32854. *
  32855. * _.times(2, _.stubTrue);
  32856. * // => [true, true]
  32857. */
  32858. function stubTrue() {
  32859. return true;
  32860. }
  32861. /**
  32862. * Invokes the iteratee `n` times, returning an array of the results of
  32863. * each invocation. The iteratee is invoked with one argument; (index).
  32864. *
  32865. * @static
  32866. * @since 0.1.0
  32867. * @memberOf _
  32868. * @category Util
  32869. * @param {number} n The number of times to invoke `iteratee`.
  32870. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  32871. * @returns {Array} Returns the array of results.
  32872. * @example
  32873. *
  32874. * _.times(3, String);
  32875. * // => ['0', '1', '2']
  32876. *
  32877. * _.times(4, _.constant(0));
  32878. * // => [0, 0, 0, 0]
  32879. */
  32880. function times(n, iteratee) {
  32881. n = toInteger(n);
  32882. if (n < 1 || n > MAX_SAFE_INTEGER) {
  32883. return [];
  32884. }
  32885. var index = MAX_ARRAY_LENGTH,
  32886. length = nativeMin(n, MAX_ARRAY_LENGTH);
  32887. iteratee = getIteratee(iteratee);
  32888. n -= MAX_ARRAY_LENGTH;
  32889. var result = baseTimes(length, iteratee);
  32890. while (++index < n) {
  32891. iteratee(index);
  32892. }
  32893. return result;
  32894. }
  32895. /**
  32896. * Converts `value` to a property path array.
  32897. *
  32898. * @static
  32899. * @memberOf _
  32900. * @since 4.0.0
  32901. * @category Util
  32902. * @param {*} value The value to convert.
  32903. * @returns {Array} Returns the new property path array.
  32904. * @example
  32905. *
  32906. * _.toPath('a.b.c');
  32907. * // => ['a', 'b', 'c']
  32908. *
  32909. * _.toPath('a[0].b.c');
  32910. * // => ['a', '0', 'b', 'c']
  32911. */
  32912. function toPath(value) {
  32913. if (isArray(value)) {
  32914. return arrayMap(value, toKey);
  32915. }
  32916. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  32917. }
  32918. /**
  32919. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  32920. *
  32921. * @static
  32922. * @since 0.1.0
  32923. * @memberOf _
  32924. * @category Util
  32925. * @param {string} [prefix=''] The value to prefix the ID with.
  32926. * @returns {string} Returns the unique ID.
  32927. * @example
  32928. *
  32929. * _.uniqueId('contact_');
  32930. * // => 'contact_104'
  32931. *
  32932. * _.uniqueId();
  32933. * // => '105'
  32934. */
  32935. function uniqueId(prefix) {
  32936. var id = ++idCounter;
  32937. return toString(prefix) + id;
  32938. }
  32939. /*------------------------------------------------------------------------*/
  32940. /**
  32941. * Adds two numbers.
  32942. *
  32943. * @static
  32944. * @memberOf _
  32945. * @since 3.4.0
  32946. * @category Math
  32947. * @param {number} augend The first number in an addition.
  32948. * @param {number} addend The second number in an addition.
  32949. * @returns {number} Returns the total.
  32950. * @example
  32951. *
  32952. * _.add(6, 4);
  32953. * // => 10
  32954. */
  32955. var add = createMathOperation(function(augend, addend) {
  32956. return augend + addend;
  32957. }, 0);
  32958. /**
  32959. * Computes `number` rounded up to `precision`.
  32960. *
  32961. * @static
  32962. * @memberOf _
  32963. * @since 3.10.0
  32964. * @category Math
  32965. * @param {number} number The number to round up.
  32966. * @param {number} [precision=0] The precision to round up to.
  32967. * @returns {number} Returns the rounded up number.
  32968. * @example
  32969. *
  32970. * _.ceil(4.006);
  32971. * // => 5
  32972. *
  32973. * _.ceil(6.004, 2);
  32974. * // => 6.01
  32975. *
  32976. * _.ceil(6040, -2);
  32977. * // => 6100
  32978. */
  32979. var ceil = createRound('ceil');
  32980. /**
  32981. * Divide two numbers.
  32982. *
  32983. * @static
  32984. * @memberOf _
  32985. * @since 4.7.0
  32986. * @category Math
  32987. * @param {number} dividend The first number in a division.
  32988. * @param {number} divisor The second number in a division.
  32989. * @returns {number} Returns the quotient.
  32990. * @example
  32991. *
  32992. * _.divide(6, 4);
  32993. * // => 1.5
  32994. */
  32995. var divide = createMathOperation(function(dividend, divisor) {
  32996. return dividend / divisor;
  32997. }, 1);
  32998. /**
  32999. * Computes `number` rounded down to `precision`.
  33000. *
  33001. * @static
  33002. * @memberOf _
  33003. * @since 3.10.0
  33004. * @category Math
  33005. * @param {number} number The number to round down.
  33006. * @param {number} [precision=0] The precision to round down to.
  33007. * @returns {number} Returns the rounded down number.
  33008. * @example
  33009. *
  33010. * _.floor(4.006);
  33011. * // => 4
  33012. *
  33013. * _.floor(0.046, 2);
  33014. * // => 0.04
  33015. *
  33016. * _.floor(4060, -2);
  33017. * // => 4000
  33018. */
  33019. var floor = createRound('floor');
  33020. /**
  33021. * Computes the maximum value of `array`. If `array` is empty or falsey,
  33022. * `undefined` is returned.
  33023. *
  33024. * @static
  33025. * @since 0.1.0
  33026. * @memberOf _
  33027. * @category Math
  33028. * @param {Array} array The array to iterate over.
  33029. * @returns {*} Returns the maximum value.
  33030. * @example
  33031. *
  33032. * _.max([4, 2, 8, 6]);
  33033. * // => 8
  33034. *
  33035. * _.max([]);
  33036. * // => undefined
  33037. */
  33038. function max(array) {
  33039. return (array && array.length)
  33040. ? baseExtremum(array, identity, baseGt)
  33041. : undefined;
  33042. }
  33043. /**
  33044. * This method is like `_.max` except that it accepts `iteratee` which is
  33045. * invoked for each element in `array` to generate the criterion by which
  33046. * the value is ranked. The iteratee is invoked with one argument: (value).
  33047. *
  33048. * @static
  33049. * @memberOf _
  33050. * @since 4.0.0
  33051. * @category Math
  33052. * @param {Array} array The array to iterate over.
  33053. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33054. * @returns {*} Returns the maximum value.
  33055. * @example
  33056. *
  33057. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33058. *
  33059. * _.maxBy(objects, function(o) { return o.n; });
  33060. * // => { 'n': 2 }
  33061. *
  33062. * // The `_.property` iteratee shorthand.
  33063. * _.maxBy(objects, 'n');
  33064. * // => { 'n': 2 }
  33065. */
  33066. function maxBy(array, iteratee) {
  33067. return (array && array.length)
  33068. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  33069. : undefined;
  33070. }
  33071. /**
  33072. * Computes the mean of the values in `array`.
  33073. *
  33074. * @static
  33075. * @memberOf _
  33076. * @since 4.0.0
  33077. * @category Math
  33078. * @param {Array} array The array to iterate over.
  33079. * @returns {number} Returns the mean.
  33080. * @example
  33081. *
  33082. * _.mean([4, 2, 8, 6]);
  33083. * // => 5
  33084. */
  33085. function mean(array) {
  33086. return baseMean(array, identity);
  33087. }
  33088. /**
  33089. * This method is like `_.mean` except that it accepts `iteratee` which is
  33090. * invoked for each element in `array` to generate the value to be averaged.
  33091. * The iteratee is invoked with one argument: (value).
  33092. *
  33093. * @static
  33094. * @memberOf _
  33095. * @since 4.7.0
  33096. * @category Math
  33097. * @param {Array} array The array to iterate over.
  33098. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33099. * @returns {number} Returns the mean.
  33100. * @example
  33101. *
  33102. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33103. *
  33104. * _.meanBy(objects, function(o) { return o.n; });
  33105. * // => 5
  33106. *
  33107. * // The `_.property` iteratee shorthand.
  33108. * _.meanBy(objects, 'n');
  33109. * // => 5
  33110. */
  33111. function meanBy(array, iteratee) {
  33112. return baseMean(array, getIteratee(iteratee, 2));
  33113. }
  33114. /**
  33115. * Computes the minimum value of `array`. If `array` is empty or falsey,
  33116. * `undefined` is returned.
  33117. *
  33118. * @static
  33119. * @since 0.1.0
  33120. * @memberOf _
  33121. * @category Math
  33122. * @param {Array} array The array to iterate over.
  33123. * @returns {*} Returns the minimum value.
  33124. * @example
  33125. *
  33126. * _.min([4, 2, 8, 6]);
  33127. * // => 2
  33128. *
  33129. * _.min([]);
  33130. * // => undefined
  33131. */
  33132. function min(array) {
  33133. return (array && array.length)
  33134. ? baseExtremum(array, identity, baseLt)
  33135. : undefined;
  33136. }
  33137. /**
  33138. * This method is like `_.min` except that it accepts `iteratee` which is
  33139. * invoked for each element in `array` to generate the criterion by which
  33140. * the value is ranked. The iteratee is invoked with one argument: (value).
  33141. *
  33142. * @static
  33143. * @memberOf _
  33144. * @since 4.0.0
  33145. * @category Math
  33146. * @param {Array} array The array to iterate over.
  33147. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33148. * @returns {*} Returns the minimum value.
  33149. * @example
  33150. *
  33151. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33152. *
  33153. * _.minBy(objects, function(o) { return o.n; });
  33154. * // => { 'n': 1 }
  33155. *
  33156. * // The `_.property` iteratee shorthand.
  33157. * _.minBy(objects, 'n');
  33158. * // => { 'n': 1 }
  33159. */
  33160. function minBy(array, iteratee) {
  33161. return (array && array.length)
  33162. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  33163. : undefined;
  33164. }
  33165. /**
  33166. * Multiply two numbers.
  33167. *
  33168. * @static
  33169. * @memberOf _
  33170. * @since 4.7.0
  33171. * @category Math
  33172. * @param {number} multiplier The first number in a multiplication.
  33173. * @param {number} multiplicand The second number in a multiplication.
  33174. * @returns {number} Returns the product.
  33175. * @example
  33176. *
  33177. * _.multiply(6, 4);
  33178. * // => 24
  33179. */
  33180. var multiply = createMathOperation(function(multiplier, multiplicand) {
  33181. return multiplier * multiplicand;
  33182. }, 1);
  33183. /**
  33184. * Computes `number` rounded to `precision`.
  33185. *
  33186. * @static
  33187. * @memberOf _
  33188. * @since 3.10.0
  33189. * @category Math
  33190. * @param {number} number The number to round.
  33191. * @param {number} [precision=0] The precision to round to.
  33192. * @returns {number} Returns the rounded number.
  33193. * @example
  33194. *
  33195. * _.round(4.006);
  33196. * // => 4
  33197. *
  33198. * _.round(4.006, 2);
  33199. * // => 4.01
  33200. *
  33201. * _.round(4060, -2);
  33202. * // => 4100
  33203. */
  33204. var round = createRound('round');
  33205. /**
  33206. * Subtract two numbers.
  33207. *
  33208. * @static
  33209. * @memberOf _
  33210. * @since 4.0.0
  33211. * @category Math
  33212. * @param {number} minuend The first number in a subtraction.
  33213. * @param {number} subtrahend The second number in a subtraction.
  33214. * @returns {number} Returns the difference.
  33215. * @example
  33216. *
  33217. * _.subtract(6, 4);
  33218. * // => 2
  33219. */
  33220. var subtract = createMathOperation(function(minuend, subtrahend) {
  33221. return minuend - subtrahend;
  33222. }, 0);
  33223. /**
  33224. * Computes the sum of the values in `array`.
  33225. *
  33226. * @static
  33227. * @memberOf _
  33228. * @since 3.4.0
  33229. * @category Math
  33230. * @param {Array} array The array to iterate over.
  33231. * @returns {number} Returns the sum.
  33232. * @example
  33233. *
  33234. * _.sum([4, 2, 8, 6]);
  33235. * // => 20
  33236. */
  33237. function sum(array) {
  33238. return (array && array.length)
  33239. ? baseSum(array, identity)
  33240. : 0;
  33241. }
  33242. /**
  33243. * This method is like `_.sum` except that it accepts `iteratee` which is
  33244. * invoked for each element in `array` to generate the value to be summed.
  33245. * The iteratee is invoked with one argument: (value).
  33246. *
  33247. * @static
  33248. * @memberOf _
  33249. * @since 4.0.0
  33250. * @category Math
  33251. * @param {Array} array The array to iterate over.
  33252. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33253. * @returns {number} Returns the sum.
  33254. * @example
  33255. *
  33256. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33257. *
  33258. * _.sumBy(objects, function(o) { return o.n; });
  33259. * // => 20
  33260. *
  33261. * // The `_.property` iteratee shorthand.
  33262. * _.sumBy(objects, 'n');
  33263. * // => 20
  33264. */
  33265. function sumBy(array, iteratee) {
  33266. return (array && array.length)
  33267. ? baseSum(array, getIteratee(iteratee, 2))
  33268. : 0;
  33269. }
  33270. /*------------------------------------------------------------------------*/
  33271. // Add methods that return wrapped values in chain sequences.
  33272. lodash.after = after;
  33273. lodash.ary = ary;
  33274. lodash.assign = assign;
  33275. lodash.assignIn = assignIn;
  33276. lodash.assignInWith = assignInWith;
  33277. lodash.assignWith = assignWith;
  33278. lodash.at = at;
  33279. lodash.before = before;
  33280. lodash.bind = bind;
  33281. lodash.bindAll = bindAll;
  33282. lodash.bindKey = bindKey;
  33283. lodash.castArray = castArray;
  33284. lodash.chain = chain;
  33285. lodash.chunk = chunk;
  33286. lodash.compact = compact;
  33287. lodash.concat = concat;
  33288. lodash.cond = cond;
  33289. lodash.conforms = conforms;
  33290. lodash.constant = constant;
  33291. lodash.countBy = countBy;
  33292. lodash.create = create;
  33293. lodash.curry = curry;
  33294. lodash.curryRight = curryRight;
  33295. lodash.debounce = debounce;
  33296. lodash.defaults = defaults;
  33297. lodash.defaultsDeep = defaultsDeep;
  33298. lodash.defer = defer;
  33299. lodash.delay = delay;
  33300. lodash.difference = difference;
  33301. lodash.differenceBy = differenceBy;
  33302. lodash.differenceWith = differenceWith;
  33303. lodash.drop = drop;
  33304. lodash.dropRight = dropRight;
  33305. lodash.dropRightWhile = dropRightWhile;
  33306. lodash.dropWhile = dropWhile;
  33307. lodash.fill = fill;
  33308. lodash.filter = filter;
  33309. lodash.flatMap = flatMap;
  33310. lodash.flatMapDeep = flatMapDeep;
  33311. lodash.flatMapDepth = flatMapDepth;
  33312. lodash.flatten = flatten;
  33313. lodash.flattenDeep = flattenDeep;
  33314. lodash.flattenDepth = flattenDepth;
  33315. lodash.flip = flip;
  33316. lodash.flow = flow;
  33317. lodash.flowRight = flowRight;
  33318. lodash.fromPairs = fromPairs;
  33319. lodash.functions = functions;
  33320. lodash.functionsIn = functionsIn;
  33321. lodash.groupBy = groupBy;
  33322. lodash.initial = initial;
  33323. lodash.intersection = intersection;
  33324. lodash.intersectionBy = intersectionBy;
  33325. lodash.intersectionWith = intersectionWith;
  33326. lodash.invert = invert;
  33327. lodash.invertBy = invertBy;
  33328. lodash.invokeMap = invokeMap;
  33329. lodash.iteratee = iteratee;
  33330. lodash.keyBy = keyBy;
  33331. lodash.keys = keys;
  33332. lodash.keysIn = keysIn;
  33333. lodash.map = map;
  33334. lodash.mapKeys = mapKeys;
  33335. lodash.mapValues = mapValues;
  33336. lodash.matches = matches;
  33337. lodash.matchesProperty = matchesProperty;
  33338. lodash.memoize = memoize;
  33339. lodash.merge = merge;
  33340. lodash.mergeWith = mergeWith;
  33341. lodash.method = method;
  33342. lodash.methodOf = methodOf;
  33343. lodash.mixin = mixin;
  33344. lodash.negate = negate;
  33345. lodash.nthArg = nthArg;
  33346. lodash.omit = omit;
  33347. lodash.omitBy = omitBy;
  33348. lodash.once = once;
  33349. lodash.orderBy = orderBy;
  33350. lodash.over = over;
  33351. lodash.overArgs = overArgs;
  33352. lodash.overEvery = overEvery;
  33353. lodash.overSome = overSome;
  33354. lodash.partial = partial;
  33355. lodash.partialRight = partialRight;
  33356. lodash.partition = partition;
  33357. lodash.pick = pick;
  33358. lodash.pickBy = pickBy;
  33359. lodash.property = property;
  33360. lodash.propertyOf = propertyOf;
  33361. lodash.pull = pull;
  33362. lodash.pullAll = pullAll;
  33363. lodash.pullAllBy = pullAllBy;
  33364. lodash.pullAllWith = pullAllWith;
  33365. lodash.pullAt = pullAt;
  33366. lodash.range = range;
  33367. lodash.rangeRight = rangeRight;
  33368. lodash.rearg = rearg;
  33369. lodash.reject = reject;
  33370. lodash.remove = remove;
  33371. lodash.rest = rest;
  33372. lodash.reverse = reverse;
  33373. lodash.sampleSize = sampleSize;
  33374. lodash.set = set;
  33375. lodash.setWith = setWith;
  33376. lodash.shuffle = shuffle;
  33377. lodash.slice = slice;
  33378. lodash.sortBy = sortBy;
  33379. lodash.sortedUniq = sortedUniq;
  33380. lodash.sortedUniqBy = sortedUniqBy;
  33381. lodash.split = split;
  33382. lodash.spread = spread;
  33383. lodash.tail = tail;
  33384. lodash.take = take;
  33385. lodash.takeRight = takeRight;
  33386. lodash.takeRightWhile = takeRightWhile;
  33387. lodash.takeWhile = takeWhile;
  33388. lodash.tap = tap;
  33389. lodash.throttle = throttle;
  33390. lodash.thru = thru;
  33391. lodash.toArray = toArray;
  33392. lodash.toPairs = toPairs;
  33393. lodash.toPairsIn = toPairsIn;
  33394. lodash.toPath = toPath;
  33395. lodash.toPlainObject = toPlainObject;
  33396. lodash.transform = transform;
  33397. lodash.unary = unary;
  33398. lodash.union = union;
  33399. lodash.unionBy = unionBy;
  33400. lodash.unionWith = unionWith;
  33401. lodash.uniq = uniq;
  33402. lodash.uniqBy = uniqBy;
  33403. lodash.uniqWith = uniqWith;
  33404. lodash.unset = unset;
  33405. lodash.unzip = unzip;
  33406. lodash.unzipWith = unzipWith;
  33407. lodash.update = update;
  33408. lodash.updateWith = updateWith;
  33409. lodash.values = values;
  33410. lodash.valuesIn = valuesIn;
  33411. lodash.without = without;
  33412. lodash.words = words;
  33413. lodash.wrap = wrap;
  33414. lodash.xor = xor;
  33415. lodash.xorBy = xorBy;
  33416. lodash.xorWith = xorWith;
  33417. lodash.zip = zip;
  33418. lodash.zipObject = zipObject;
  33419. lodash.zipObjectDeep = zipObjectDeep;
  33420. lodash.zipWith = zipWith;
  33421. // Add aliases.
  33422. lodash.entries = toPairs;
  33423. lodash.entriesIn = toPairsIn;
  33424. lodash.extend = assignIn;
  33425. lodash.extendWith = assignInWith;
  33426. // Add methods to `lodash.prototype`.
  33427. mixin(lodash, lodash);
  33428. /*------------------------------------------------------------------------*/
  33429. // Add methods that return unwrapped values in chain sequences.
  33430. lodash.add = add;
  33431. lodash.attempt = attempt;
  33432. lodash.camelCase = camelCase;
  33433. lodash.capitalize = capitalize;
  33434. lodash.ceil = ceil;
  33435. lodash.clamp = clamp;
  33436. lodash.clone = clone;
  33437. lodash.cloneDeep = cloneDeep;
  33438. lodash.cloneDeepWith = cloneDeepWith;
  33439. lodash.cloneWith = cloneWith;
  33440. lodash.conformsTo = conformsTo;
  33441. lodash.deburr = deburr;
  33442. lodash.defaultTo = defaultTo;
  33443. lodash.divide = divide;
  33444. lodash.endsWith = endsWith;
  33445. lodash.eq = eq;
  33446. lodash.escape = escape;
  33447. lodash.escapeRegExp = escapeRegExp;
  33448. lodash.every = every;
  33449. lodash.find = find;
  33450. lodash.findIndex = findIndex;
  33451. lodash.findKey = findKey;
  33452. lodash.findLast = findLast;
  33453. lodash.findLastIndex = findLastIndex;
  33454. lodash.findLastKey = findLastKey;
  33455. lodash.floor = floor;
  33456. lodash.forEach = forEach;
  33457. lodash.forEachRight = forEachRight;
  33458. lodash.forIn = forIn;
  33459. lodash.forInRight = forInRight;
  33460. lodash.forOwn = forOwn;
  33461. lodash.forOwnRight = forOwnRight;
  33462. lodash.get = get;
  33463. lodash.gt = gt;
  33464. lodash.gte = gte;
  33465. lodash.has = has;
  33466. lodash.hasIn = hasIn;
  33467. lodash.head = head;
  33468. lodash.identity = identity;
  33469. lodash.includes = includes;
  33470. lodash.indexOf = indexOf;
  33471. lodash.inRange = inRange;
  33472. lodash.invoke = invoke;
  33473. lodash.isArguments = isArguments;
  33474. lodash.isArray = isArray;
  33475. lodash.isArrayBuffer = isArrayBuffer;
  33476. lodash.isArrayLike = isArrayLike;
  33477. lodash.isArrayLikeObject = isArrayLikeObject;
  33478. lodash.isBoolean = isBoolean;
  33479. lodash.isBuffer = isBuffer;
  33480. lodash.isDate = isDate;
  33481. lodash.isElement = isElement;
  33482. lodash.isEmpty = isEmpty;
  33483. lodash.isEqual = isEqual;
  33484. lodash.isEqualWith = isEqualWith;
  33485. lodash.isError = isError;
  33486. lodash.isFinite = isFinite;
  33487. lodash.isFunction = isFunction;
  33488. lodash.isInteger = isInteger;
  33489. lodash.isLength = isLength;
  33490. lodash.isMap = isMap;
  33491. lodash.isMatch = isMatch;
  33492. lodash.isMatchWith = isMatchWith;
  33493. lodash.isNaN = isNaN;
  33494. lodash.isNative = isNative;
  33495. lodash.isNil = isNil;
  33496. lodash.isNull = isNull;
  33497. lodash.isNumber = isNumber;
  33498. lodash.isObject = isObject;
  33499. lodash.isObjectLike = isObjectLike;
  33500. lodash.isPlainObject = isPlainObject;
  33501. lodash.isRegExp = isRegExp;
  33502. lodash.isSafeInteger = isSafeInteger;
  33503. lodash.isSet = isSet;
  33504. lodash.isString = isString;
  33505. lodash.isSymbol = isSymbol;
  33506. lodash.isTypedArray = isTypedArray;
  33507. lodash.isUndefined = isUndefined;
  33508. lodash.isWeakMap = isWeakMap;
  33509. lodash.isWeakSet = isWeakSet;
  33510. lodash.join = join;
  33511. lodash.kebabCase = kebabCase;
  33512. lodash.last = last;
  33513. lodash.lastIndexOf = lastIndexOf;
  33514. lodash.lowerCase = lowerCase;
  33515. lodash.lowerFirst = lowerFirst;
  33516. lodash.lt = lt;
  33517. lodash.lte = lte;
  33518. lodash.max = max;
  33519. lodash.maxBy = maxBy;
  33520. lodash.mean = mean;
  33521. lodash.meanBy = meanBy;
  33522. lodash.min = min;
  33523. lodash.minBy = minBy;
  33524. lodash.stubArray = stubArray;
  33525. lodash.stubFalse = stubFalse;
  33526. lodash.stubObject = stubObject;
  33527. lodash.stubString = stubString;
  33528. lodash.stubTrue = stubTrue;
  33529. lodash.multiply = multiply;
  33530. lodash.nth = nth;
  33531. lodash.noConflict = noConflict;
  33532. lodash.noop = noop;
  33533. lodash.now = now;
  33534. lodash.pad = pad;
  33535. lodash.padEnd = padEnd;
  33536. lodash.padStart = padStart;
  33537. lodash.parseInt = parseInt;
  33538. lodash.random = random;
  33539. lodash.reduce = reduce;
  33540. lodash.reduceRight = reduceRight;
  33541. lodash.repeat = repeat;
  33542. lodash.replace = replace;
  33543. lodash.result = result;
  33544. lodash.round = round;
  33545. lodash.runInContext = runInContext;
  33546. lodash.sample = sample;
  33547. lodash.size = size;
  33548. lodash.snakeCase = snakeCase;
  33549. lodash.some = some;
  33550. lodash.sortedIndex = sortedIndex;
  33551. lodash.sortedIndexBy = sortedIndexBy;
  33552. lodash.sortedIndexOf = sortedIndexOf;
  33553. lodash.sortedLastIndex = sortedLastIndex;
  33554. lodash.sortedLastIndexBy = sortedLastIndexBy;
  33555. lodash.sortedLastIndexOf = sortedLastIndexOf;
  33556. lodash.startCase = startCase;
  33557. lodash.startsWith = startsWith;
  33558. lodash.subtract = subtract;
  33559. lodash.sum = sum;
  33560. lodash.sumBy = sumBy;
  33561. lodash.template = template;
  33562. lodash.times = times;
  33563. lodash.toFinite = toFinite;
  33564. lodash.toInteger = toInteger;
  33565. lodash.toLength = toLength;
  33566. lodash.toLower = toLower;
  33567. lodash.toNumber = toNumber;
  33568. lodash.toSafeInteger = toSafeInteger;
  33569. lodash.toString = toString;
  33570. lodash.toUpper = toUpper;
  33571. lodash.trim = trim;
  33572. lodash.trimEnd = trimEnd;
  33573. lodash.trimStart = trimStart;
  33574. lodash.truncate = truncate;
  33575. lodash.unescape = unescape;
  33576. lodash.uniqueId = uniqueId;
  33577. lodash.upperCase = upperCase;
  33578. lodash.upperFirst = upperFirst;
  33579. // Add aliases.
  33580. lodash.each = forEach;
  33581. lodash.eachRight = forEachRight;
  33582. lodash.first = head;
  33583. mixin(lodash, (function() {
  33584. var source = {};
  33585. baseForOwn(lodash, function(func, methodName) {
  33586. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  33587. source[methodName] = func;
  33588. }
  33589. });
  33590. return source;
  33591. }()), { 'chain': false });
  33592. /*------------------------------------------------------------------------*/
  33593. /**
  33594. * The semantic version number.
  33595. *
  33596. * @static
  33597. * @memberOf _
  33598. * @type {string}
  33599. */
  33600. lodash.VERSION = VERSION;
  33601. // Assign default placeholders.
  33602. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  33603. lodash[methodName].placeholder = lodash;
  33604. });
  33605. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  33606. arrayEach(['drop', 'take'], function(methodName, index) {
  33607. LazyWrapper.prototype[methodName] = function(n) {
  33608. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  33609. var result = (this.__filtered__ && !index)
  33610. ? new LazyWrapper(this)
  33611. : this.clone();
  33612. if (result.__filtered__) {
  33613. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  33614. } else {
  33615. result.__views__.push({
  33616. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  33617. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  33618. });
  33619. }
  33620. return result;
  33621. };
  33622. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  33623. return this.reverse()[methodName](n).reverse();
  33624. };
  33625. });
  33626. // Add `LazyWrapper` methods that accept an `iteratee` value.
  33627. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  33628. var type = index + 1,
  33629. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  33630. LazyWrapper.prototype[methodName] = function(iteratee) {
  33631. var result = this.clone();
  33632. result.__iteratees__.push({
  33633. 'iteratee': getIteratee(iteratee, 3),
  33634. 'type': type
  33635. });
  33636. result.__filtered__ = result.__filtered__ || isFilter;
  33637. return result;
  33638. };
  33639. });
  33640. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  33641. arrayEach(['head', 'last'], function(methodName, index) {
  33642. var takeName = 'take' + (index ? 'Right' : '');
  33643. LazyWrapper.prototype[methodName] = function() {
  33644. return this[takeName](1).value()[0];
  33645. };
  33646. });
  33647. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  33648. arrayEach(['initial', 'tail'], function(methodName, index) {
  33649. var dropName = 'drop' + (index ? '' : 'Right');
  33650. LazyWrapper.prototype[methodName] = function() {
  33651. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  33652. };
  33653. });
  33654. LazyWrapper.prototype.compact = function() {
  33655. return this.filter(identity);
  33656. };
  33657. LazyWrapper.prototype.find = function(predicate) {
  33658. return this.filter(predicate).head();
  33659. };
  33660. LazyWrapper.prototype.findLast = function(predicate) {
  33661. return this.reverse().find(predicate);
  33662. };
  33663. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  33664. if (typeof path == 'function') {
  33665. return new LazyWrapper(this);
  33666. }
  33667. return this.map(function(value) {
  33668. return baseInvoke(value, path, args);
  33669. });
  33670. });
  33671. LazyWrapper.prototype.reject = function(predicate) {
  33672. return this.filter(negate(getIteratee(predicate)));
  33673. };
  33674. LazyWrapper.prototype.slice = function(start, end) {
  33675. start = toInteger(start);
  33676. var result = this;
  33677. if (result.__filtered__ && (start > 0 || end < 0)) {
  33678. return new LazyWrapper(result);
  33679. }
  33680. if (start < 0) {
  33681. result = result.takeRight(-start);
  33682. } else if (start) {
  33683. result = result.drop(start);
  33684. }
  33685. if (end !== undefined) {
  33686. end = toInteger(end);
  33687. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  33688. }
  33689. return result;
  33690. };
  33691. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  33692. return this.reverse().takeWhile(predicate).reverse();
  33693. };
  33694. LazyWrapper.prototype.toArray = function() {
  33695. return this.take(MAX_ARRAY_LENGTH);
  33696. };
  33697. // Add `LazyWrapper` methods to `lodash.prototype`.
  33698. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33699. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  33700. isTaker = /^(?:head|last)$/.test(methodName),
  33701. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  33702. retUnwrapped = isTaker || /^find/.test(methodName);
  33703. if (!lodashFunc) {
  33704. return;
  33705. }
  33706. lodash.prototype[methodName] = function() {
  33707. var value = this.__wrapped__,
  33708. args = isTaker ? [1] : arguments,
  33709. isLazy = value instanceof LazyWrapper,
  33710. iteratee = args[0],
  33711. useLazy = isLazy || isArray(value);
  33712. var interceptor = function(value) {
  33713. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  33714. return (isTaker && chainAll) ? result[0] : result;
  33715. };
  33716. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  33717. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  33718. isLazy = useLazy = false;
  33719. }
  33720. var chainAll = this.__chain__,
  33721. isHybrid = !!this.__actions__.length,
  33722. isUnwrapped = retUnwrapped && !chainAll,
  33723. onlyLazy = isLazy && !isHybrid;
  33724. if (!retUnwrapped && useLazy) {
  33725. value = onlyLazy ? value : new LazyWrapper(this);
  33726. var result = func.apply(value, args);
  33727. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  33728. return new LodashWrapper(result, chainAll);
  33729. }
  33730. if (isUnwrapped && onlyLazy) {
  33731. return func.apply(this, args);
  33732. }
  33733. result = this.thru(interceptor);
  33734. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  33735. };
  33736. });
  33737. // Add `Array` methods to `lodash.prototype`.
  33738. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  33739. var func = arrayProto[methodName],
  33740. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  33741. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  33742. lodash.prototype[methodName] = function() {
  33743. var args = arguments;
  33744. if (retUnwrapped && !this.__chain__) {
  33745. var value = this.value();
  33746. return func.apply(isArray(value) ? value : [], args);
  33747. }
  33748. return this[chainName](function(value) {
  33749. return func.apply(isArray(value) ? value : [], args);
  33750. });
  33751. };
  33752. });
  33753. // Map minified method names to their real names.
  33754. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33755. var lodashFunc = lodash[methodName];
  33756. if (lodashFunc) {
  33757. var key = lodashFunc.name + '';
  33758. if (!hasOwnProperty.call(realNames, key)) {
  33759. realNames[key] = [];
  33760. }
  33761. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  33762. }
  33763. });
  33764. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  33765. 'name': 'wrapper',
  33766. 'func': undefined
  33767. }];
  33768. // Add methods to `LazyWrapper`.
  33769. LazyWrapper.prototype.clone = lazyClone;
  33770. LazyWrapper.prototype.reverse = lazyReverse;
  33771. LazyWrapper.prototype.value = lazyValue;
  33772. // Add chain sequence methods to the `lodash` wrapper.
  33773. lodash.prototype.at = wrapperAt;
  33774. lodash.prototype.chain = wrapperChain;
  33775. lodash.prototype.commit = wrapperCommit;
  33776. lodash.prototype.next = wrapperNext;
  33777. lodash.prototype.plant = wrapperPlant;
  33778. lodash.prototype.reverse = wrapperReverse;
  33779. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  33780. // Add lazy aliases.
  33781. lodash.prototype.first = lodash.prototype.head;
  33782. if (symIterator) {
  33783. lodash.prototype[symIterator] = wrapperToIterator;
  33784. }
  33785. return lodash;
  33786. });
  33787. /*--------------------------------------------------------------------------*/
  33788. // Export lodash.
  33789. var _ = runInContext();
  33790. // Some AMD build optimizers, like r.js, check for condition patterns like:
  33791. if (true) {
  33792. // Expose Lodash on the global object to prevent errors when Lodash is
  33793. // loaded by a script tag in the presence of an AMD loader.
  33794. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  33795. // Use `_.noConflict` to remove Lodash from the global object.
  33796. root._ = _;
  33797. // Define as an anonymous module so, through path mapping, it can be
  33798. // referenced as the "underscore" module.
  33799. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  33800. return _;
  33801. }).call(exports, __webpack_require__, exports, module),
  33802. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  33803. }
  33804. // Check for `exports` after `define` in case a build optimizer adds it.
  33805. else {}
  33806. }.call(this));
  33807. /* 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)))
  33808. /***/ }),
  33809. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  33810. /*!***************************************************!*\
  33811. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  33812. \***************************************************/
  33813. /*! exports provided: default */
  33814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33815. "use strict";
  33816. __webpack_require__.r(__webpack_exports__);
  33817. /* WEBPACK VAR INJECTION */(function(global) {/**!
  33818. * @fileOverview Kickass library to create and place poppers near their reference elements.
  33819. * @version 1.16.1
  33820. * @license
  33821. * Copyright (c) 2016 Federico Zivolo and contributors
  33822. *
  33823. * Permission is hereby granted, free of charge, to any person obtaining a copy
  33824. * of this software and associated documentation files (the "Software"), to deal
  33825. * in the Software without restriction, including without limitation the rights
  33826. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  33827. * copies of the Software, and to permit persons to whom the Software is
  33828. * furnished to do so, subject to the following conditions:
  33829. *
  33830. * The above copyright notice and this permission notice shall be included in all
  33831. * copies or substantial portions of the Software.
  33832. *
  33833. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  33834. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  33835. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  33836. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  33837. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  33838. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  33839. * SOFTWARE.
  33840. */
  33841. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  33842. var timeoutDuration = function () {
  33843. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  33844. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  33845. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  33846. return 1;
  33847. }
  33848. }
  33849. return 0;
  33850. }();
  33851. function microtaskDebounce(fn) {
  33852. var called = false;
  33853. return function () {
  33854. if (called) {
  33855. return;
  33856. }
  33857. called = true;
  33858. window.Promise.resolve().then(function () {
  33859. called = false;
  33860. fn();
  33861. });
  33862. };
  33863. }
  33864. function taskDebounce(fn) {
  33865. var scheduled = false;
  33866. return function () {
  33867. if (!scheduled) {
  33868. scheduled = true;
  33869. setTimeout(function () {
  33870. scheduled = false;
  33871. fn();
  33872. }, timeoutDuration);
  33873. }
  33874. };
  33875. }
  33876. var supportsMicroTasks = isBrowser && window.Promise;
  33877. /**
  33878. * Create a debounced version of a method, that's asynchronously deferred
  33879. * but called in the minimum time possible.
  33880. *
  33881. * @method
  33882. * @memberof Popper.Utils
  33883. * @argument {Function} fn
  33884. * @returns {Function}
  33885. */
  33886. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  33887. /**
  33888. * Check if the given variable is a function
  33889. * @method
  33890. * @memberof Popper.Utils
  33891. * @argument {Any} functionToCheck - variable to check
  33892. * @returns {Boolean} answer to: is a function?
  33893. */
  33894. function isFunction(functionToCheck) {
  33895. var getType = {};
  33896. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  33897. }
  33898. /**
  33899. * Get CSS computed property of the given element
  33900. * @method
  33901. * @memberof Popper.Utils
  33902. * @argument {Eement} element
  33903. * @argument {String} property
  33904. */
  33905. function getStyleComputedProperty(element, property) {
  33906. if (element.nodeType !== 1) {
  33907. return [];
  33908. }
  33909. // NOTE: 1 DOM access here
  33910. var window = element.ownerDocument.defaultView;
  33911. var css = window.getComputedStyle(element, null);
  33912. return property ? css[property] : css;
  33913. }
  33914. /**
  33915. * Returns the parentNode or the host of the element
  33916. * @method
  33917. * @memberof Popper.Utils
  33918. * @argument {Element} element
  33919. * @returns {Element} parent
  33920. */
  33921. function getParentNode(element) {
  33922. if (element.nodeName === 'HTML') {
  33923. return element;
  33924. }
  33925. return element.parentNode || element.host;
  33926. }
  33927. /**
  33928. * Returns the scrolling parent of the given element
  33929. * @method
  33930. * @memberof Popper.Utils
  33931. * @argument {Element} element
  33932. * @returns {Element} scroll parent
  33933. */
  33934. function getScrollParent(element) {
  33935. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  33936. if (!element) {
  33937. return document.body;
  33938. }
  33939. switch (element.nodeName) {
  33940. case 'HTML':
  33941. case 'BODY':
  33942. return element.ownerDocument.body;
  33943. case '#document':
  33944. return element.body;
  33945. }
  33946. // Firefox want us to check `-x` and `-y` variations as well
  33947. var _getStyleComputedProp = getStyleComputedProperty(element),
  33948. overflow = _getStyleComputedProp.overflow,
  33949. overflowX = _getStyleComputedProp.overflowX,
  33950. overflowY = _getStyleComputedProp.overflowY;
  33951. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  33952. return element;
  33953. }
  33954. return getScrollParent(getParentNode(element));
  33955. }
  33956. /**
  33957. * Returns the reference node of the reference object, or the reference object itself.
  33958. * @method
  33959. * @memberof Popper.Utils
  33960. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  33961. * @returns {Element} parent
  33962. */
  33963. function getReferenceNode(reference) {
  33964. return reference && reference.referenceNode ? reference.referenceNode : reference;
  33965. }
  33966. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  33967. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  33968. /**
  33969. * Determines if the browser is Internet Explorer
  33970. * @method
  33971. * @memberof Popper.Utils
  33972. * @param {Number} version to check
  33973. * @returns {Boolean} isIE
  33974. */
  33975. function isIE(version) {
  33976. if (version === 11) {
  33977. return isIE11;
  33978. }
  33979. if (version === 10) {
  33980. return isIE10;
  33981. }
  33982. return isIE11 || isIE10;
  33983. }
  33984. /**
  33985. * Returns the offset parent of the given element
  33986. * @method
  33987. * @memberof Popper.Utils
  33988. * @argument {Element} element
  33989. * @returns {Element} offset parent
  33990. */
  33991. function getOffsetParent(element) {
  33992. if (!element) {
  33993. return document.documentElement;
  33994. }
  33995. var noOffsetParent = isIE(10) ? document.body : null;
  33996. // NOTE: 1 DOM access here
  33997. var offsetParent = element.offsetParent || null;
  33998. // Skip hidden elements which don't have an offsetParent
  33999. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  34000. offsetParent = (element = element.nextElementSibling).offsetParent;
  34001. }
  34002. var nodeName = offsetParent && offsetParent.nodeName;
  34003. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  34004. return element ? element.ownerDocument.documentElement : document.documentElement;
  34005. }
  34006. // .offsetParent will return the closest TH, TD or TABLE in case
  34007. // no offsetParent is present, I hate this job...
  34008. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  34009. return getOffsetParent(offsetParent);
  34010. }
  34011. return offsetParent;
  34012. }
  34013. function isOffsetContainer(element) {
  34014. var nodeName = element.nodeName;
  34015. if (nodeName === 'BODY') {
  34016. return false;
  34017. }
  34018. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  34019. }
  34020. /**
  34021. * Finds the root node (document, shadowDOM root) of the given element
  34022. * @method
  34023. * @memberof Popper.Utils
  34024. * @argument {Element} node
  34025. * @returns {Element} root node
  34026. */
  34027. function getRoot(node) {
  34028. if (node.parentNode !== null) {
  34029. return getRoot(node.parentNode);
  34030. }
  34031. return node;
  34032. }
  34033. /**
  34034. * Finds the offset parent common to the two provided nodes
  34035. * @method
  34036. * @memberof Popper.Utils
  34037. * @argument {Element} element1
  34038. * @argument {Element} element2
  34039. * @returns {Element} common offset parent
  34040. */
  34041. function findCommonOffsetParent(element1, element2) {
  34042. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34043. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  34044. return document.documentElement;
  34045. }
  34046. // Here we make sure to give as "start" the element that comes first in the DOM
  34047. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  34048. var start = order ? element1 : element2;
  34049. var end = order ? element2 : element1;
  34050. // Get common ancestor container
  34051. var range = document.createRange();
  34052. range.setStart(start, 0);
  34053. range.setEnd(end, 0);
  34054. var commonAncestorContainer = range.commonAncestorContainer;
  34055. // Both nodes are inside #document
  34056. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  34057. if (isOffsetContainer(commonAncestorContainer)) {
  34058. return commonAncestorContainer;
  34059. }
  34060. return getOffsetParent(commonAncestorContainer);
  34061. }
  34062. // one of the nodes is inside shadowDOM, find which one
  34063. var element1root = getRoot(element1);
  34064. if (element1root.host) {
  34065. return findCommonOffsetParent(element1root.host, element2);
  34066. } else {
  34067. return findCommonOffsetParent(element1, getRoot(element2).host);
  34068. }
  34069. }
  34070. /**
  34071. * Gets the scroll value of the given element in the given side (top and left)
  34072. * @method
  34073. * @memberof Popper.Utils
  34074. * @argument {Element} element
  34075. * @argument {String} side `top` or `left`
  34076. * @returns {number} amount of scrolled pixels
  34077. */
  34078. function getScroll(element) {
  34079. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  34080. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  34081. var nodeName = element.nodeName;
  34082. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34083. var html = element.ownerDocument.documentElement;
  34084. var scrollingElement = element.ownerDocument.scrollingElement || html;
  34085. return scrollingElement[upperSide];
  34086. }
  34087. return element[upperSide];
  34088. }
  34089. /*
  34090. * Sum or subtract the element scroll values (left and top) from a given rect object
  34091. * @method
  34092. * @memberof Popper.Utils
  34093. * @param {Object} rect - Rect object you want to change
  34094. * @param {HTMLElement} element - The element from the function reads the scroll values
  34095. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  34096. * @return {Object} rect - The modifier rect object
  34097. */
  34098. function includeScroll(rect, element) {
  34099. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34100. var scrollTop = getScroll(element, 'top');
  34101. var scrollLeft = getScroll(element, 'left');
  34102. var modifier = subtract ? -1 : 1;
  34103. rect.top += scrollTop * modifier;
  34104. rect.bottom += scrollTop * modifier;
  34105. rect.left += scrollLeft * modifier;
  34106. rect.right += scrollLeft * modifier;
  34107. return rect;
  34108. }
  34109. /*
  34110. * Helper to detect borders of a given element
  34111. * @method
  34112. * @memberof Popper.Utils
  34113. * @param {CSSStyleDeclaration} styles
  34114. * Result of `getStyleComputedProperty` on the given element
  34115. * @param {String} axis - `x` or `y`
  34116. * @return {number} borders - The borders size of the given axis
  34117. */
  34118. function getBordersSize(styles, axis) {
  34119. var sideA = axis === 'x' ? 'Left' : 'Top';
  34120. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  34121. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  34122. }
  34123. function getSize(axis, body, html, computedStyle) {
  34124. 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);
  34125. }
  34126. function getWindowSizes(document) {
  34127. var body = document.body;
  34128. var html = document.documentElement;
  34129. var computedStyle = isIE(10) && getComputedStyle(html);
  34130. return {
  34131. height: getSize('Height', body, html, computedStyle),
  34132. width: getSize('Width', body, html, computedStyle)
  34133. };
  34134. }
  34135. var classCallCheck = function (instance, Constructor) {
  34136. if (!(instance instanceof Constructor)) {
  34137. throw new TypeError("Cannot call a class as a function");
  34138. }
  34139. };
  34140. var createClass = function () {
  34141. function defineProperties(target, props) {
  34142. for (var i = 0; i < props.length; i++) {
  34143. var descriptor = props[i];
  34144. descriptor.enumerable = descriptor.enumerable || false;
  34145. descriptor.configurable = true;
  34146. if ("value" in descriptor) descriptor.writable = true;
  34147. Object.defineProperty(target, descriptor.key, descriptor);
  34148. }
  34149. }
  34150. return function (Constructor, protoProps, staticProps) {
  34151. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  34152. if (staticProps) defineProperties(Constructor, staticProps);
  34153. return Constructor;
  34154. };
  34155. }();
  34156. var defineProperty = function (obj, key, value) {
  34157. if (key in obj) {
  34158. Object.defineProperty(obj, key, {
  34159. value: value,
  34160. enumerable: true,
  34161. configurable: true,
  34162. writable: true
  34163. });
  34164. } else {
  34165. obj[key] = value;
  34166. }
  34167. return obj;
  34168. };
  34169. var _extends = Object.assign || function (target) {
  34170. for (var i = 1; i < arguments.length; i++) {
  34171. var source = arguments[i];
  34172. for (var key in source) {
  34173. if (Object.prototype.hasOwnProperty.call(source, key)) {
  34174. target[key] = source[key];
  34175. }
  34176. }
  34177. }
  34178. return target;
  34179. };
  34180. /**
  34181. * Given element offsets, generate an output similar to getBoundingClientRect
  34182. * @method
  34183. * @memberof Popper.Utils
  34184. * @argument {Object} offsets
  34185. * @returns {Object} ClientRect like output
  34186. */
  34187. function getClientRect(offsets) {
  34188. return _extends({}, offsets, {
  34189. right: offsets.left + offsets.width,
  34190. bottom: offsets.top + offsets.height
  34191. });
  34192. }
  34193. /**
  34194. * Get bounding client rect of given element
  34195. * @method
  34196. * @memberof Popper.Utils
  34197. * @param {HTMLElement} element
  34198. * @return {Object} client rect
  34199. */
  34200. function getBoundingClientRect(element) {
  34201. var rect = {};
  34202. // IE10 10 FIX: Please, don't ask, the element isn't
  34203. // considered in DOM in some circumstances...
  34204. // This isn't reproducible in IE10 compatibility mode of IE11
  34205. try {
  34206. if (isIE(10)) {
  34207. rect = element.getBoundingClientRect();
  34208. var scrollTop = getScroll(element, 'top');
  34209. var scrollLeft = getScroll(element, 'left');
  34210. rect.top += scrollTop;
  34211. rect.left += scrollLeft;
  34212. rect.bottom += scrollTop;
  34213. rect.right += scrollLeft;
  34214. } else {
  34215. rect = element.getBoundingClientRect();
  34216. }
  34217. } catch (e) {}
  34218. var result = {
  34219. left: rect.left,
  34220. top: rect.top,
  34221. width: rect.right - rect.left,
  34222. height: rect.bottom - rect.top
  34223. };
  34224. // subtract scrollbar size from sizes
  34225. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  34226. var width = sizes.width || element.clientWidth || result.width;
  34227. var height = sizes.height || element.clientHeight || result.height;
  34228. var horizScrollbar = element.offsetWidth - width;
  34229. var vertScrollbar = element.offsetHeight - height;
  34230. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  34231. // we make this check conditional for performance reasons
  34232. if (horizScrollbar || vertScrollbar) {
  34233. var styles = getStyleComputedProperty(element);
  34234. horizScrollbar -= getBordersSize(styles, 'x');
  34235. vertScrollbar -= getBordersSize(styles, 'y');
  34236. result.width -= horizScrollbar;
  34237. result.height -= vertScrollbar;
  34238. }
  34239. return getClientRect(result);
  34240. }
  34241. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  34242. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34243. var isIE10 = isIE(10);
  34244. var isHTML = parent.nodeName === 'HTML';
  34245. var childrenRect = getBoundingClientRect(children);
  34246. var parentRect = getBoundingClientRect(parent);
  34247. var scrollParent = getScrollParent(children);
  34248. var styles = getStyleComputedProperty(parent);
  34249. var borderTopWidth = parseFloat(styles.borderTopWidth);
  34250. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  34251. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  34252. if (fixedPosition && isHTML) {
  34253. parentRect.top = Math.max(parentRect.top, 0);
  34254. parentRect.left = Math.max(parentRect.left, 0);
  34255. }
  34256. var offsets = getClientRect({
  34257. top: childrenRect.top - parentRect.top - borderTopWidth,
  34258. left: childrenRect.left - parentRect.left - borderLeftWidth,
  34259. width: childrenRect.width,
  34260. height: childrenRect.height
  34261. });
  34262. offsets.marginTop = 0;
  34263. offsets.marginLeft = 0;
  34264. // Subtract margins of documentElement in case it's being used as parent
  34265. // we do this only on HTML because it's the only element that behaves
  34266. // differently when margins are applied to it. The margins are included in
  34267. // the box of the documentElement, in the other cases not.
  34268. if (!isIE10 && isHTML) {
  34269. var marginTop = parseFloat(styles.marginTop);
  34270. var marginLeft = parseFloat(styles.marginLeft);
  34271. offsets.top -= borderTopWidth - marginTop;
  34272. offsets.bottom -= borderTopWidth - marginTop;
  34273. offsets.left -= borderLeftWidth - marginLeft;
  34274. offsets.right -= borderLeftWidth - marginLeft;
  34275. // Attach marginTop and marginLeft because in some circumstances we may need them
  34276. offsets.marginTop = marginTop;
  34277. offsets.marginLeft = marginLeft;
  34278. }
  34279. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  34280. offsets = includeScroll(offsets, parent);
  34281. }
  34282. return offsets;
  34283. }
  34284. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  34285. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34286. var html = element.ownerDocument.documentElement;
  34287. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  34288. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  34289. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  34290. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  34291. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  34292. var offset = {
  34293. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  34294. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  34295. width: width,
  34296. height: height
  34297. };
  34298. return getClientRect(offset);
  34299. }
  34300. /**
  34301. * Check if the given element is fixed or is inside a fixed parent
  34302. * @method
  34303. * @memberof Popper.Utils
  34304. * @argument {Element} element
  34305. * @argument {Element} customContainer
  34306. * @returns {Boolean} answer to "isFixed?"
  34307. */
  34308. function isFixed(element) {
  34309. var nodeName = element.nodeName;
  34310. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34311. return false;
  34312. }
  34313. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  34314. return true;
  34315. }
  34316. var parentNode = getParentNode(element);
  34317. if (!parentNode) {
  34318. return false;
  34319. }
  34320. return isFixed(parentNode);
  34321. }
  34322. /**
  34323. * Finds the first parent of an element that has a transformed property defined
  34324. * @method
  34325. * @memberof Popper.Utils
  34326. * @argument {Element} element
  34327. * @returns {Element} first transformed parent or documentElement
  34328. */
  34329. function getFixedPositionOffsetParent(element) {
  34330. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34331. if (!element || !element.parentElement || isIE()) {
  34332. return document.documentElement;
  34333. }
  34334. var el = element.parentElement;
  34335. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  34336. el = el.parentElement;
  34337. }
  34338. return el || document.documentElement;
  34339. }
  34340. /**
  34341. * Computed the boundaries limits and return them
  34342. * @method
  34343. * @memberof Popper.Utils
  34344. * @param {HTMLElement} popper
  34345. * @param {HTMLElement} reference
  34346. * @param {number} padding
  34347. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  34348. * @param {Boolean} fixedPosition - Is in fixed position mode
  34349. * @returns {Object} Coordinates of the boundaries
  34350. */
  34351. function getBoundaries(popper, reference, padding, boundariesElement) {
  34352. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  34353. // NOTE: 1 DOM access here
  34354. var boundaries = { top: 0, left: 0 };
  34355. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34356. // Handle viewport case
  34357. if (boundariesElement === 'viewport') {
  34358. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  34359. } else {
  34360. // Handle other cases based on DOM element used as boundaries
  34361. var boundariesNode = void 0;
  34362. if (boundariesElement === 'scrollParent') {
  34363. boundariesNode = getScrollParent(getParentNode(reference));
  34364. if (boundariesNode.nodeName === 'BODY') {
  34365. boundariesNode = popper.ownerDocument.documentElement;
  34366. }
  34367. } else if (boundariesElement === 'window') {
  34368. boundariesNode = popper.ownerDocument.documentElement;
  34369. } else {
  34370. boundariesNode = boundariesElement;
  34371. }
  34372. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  34373. // In case of HTML, we need a different computation
  34374. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  34375. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  34376. height = _getWindowSizes.height,
  34377. width = _getWindowSizes.width;
  34378. boundaries.top += offsets.top - offsets.marginTop;
  34379. boundaries.bottom = height + offsets.top;
  34380. boundaries.left += offsets.left - offsets.marginLeft;
  34381. boundaries.right = width + offsets.left;
  34382. } else {
  34383. // for all the other DOM elements, this one is good
  34384. boundaries = offsets;
  34385. }
  34386. }
  34387. // Add paddings
  34388. padding = padding || 0;
  34389. var isPaddingNumber = typeof padding === 'number';
  34390. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  34391. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  34392. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  34393. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  34394. return boundaries;
  34395. }
  34396. function getArea(_ref) {
  34397. var width = _ref.width,
  34398. height = _ref.height;
  34399. return width * height;
  34400. }
  34401. /**
  34402. * Utility used to transform the `auto` placement to the placement with more
  34403. * available space.
  34404. * @method
  34405. * @memberof Popper.Utils
  34406. * @argument {Object} data - The data object generated by update method
  34407. * @argument {Object} options - Modifiers configuration and options
  34408. * @returns {Object} The data object, properly modified
  34409. */
  34410. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  34411. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  34412. if (placement.indexOf('auto') === -1) {
  34413. return placement;
  34414. }
  34415. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  34416. var rects = {
  34417. top: {
  34418. width: boundaries.width,
  34419. height: refRect.top - boundaries.top
  34420. },
  34421. right: {
  34422. width: boundaries.right - refRect.right,
  34423. height: boundaries.height
  34424. },
  34425. bottom: {
  34426. width: boundaries.width,
  34427. height: boundaries.bottom - refRect.bottom
  34428. },
  34429. left: {
  34430. width: refRect.left - boundaries.left,
  34431. height: boundaries.height
  34432. }
  34433. };
  34434. var sortedAreas = Object.keys(rects).map(function (key) {
  34435. return _extends({
  34436. key: key
  34437. }, rects[key], {
  34438. area: getArea(rects[key])
  34439. });
  34440. }).sort(function (a, b) {
  34441. return b.area - a.area;
  34442. });
  34443. var filteredAreas = sortedAreas.filter(function (_ref2) {
  34444. var width = _ref2.width,
  34445. height = _ref2.height;
  34446. return width >= popper.clientWidth && height >= popper.clientHeight;
  34447. });
  34448. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  34449. var variation = placement.split('-')[1];
  34450. return computedPlacement + (variation ? '-' + variation : '');
  34451. }
  34452. /**
  34453. * Get offsets to the reference element
  34454. * @method
  34455. * @memberof Popper.Utils
  34456. * @param {Object} state
  34457. * @param {Element} popper - the popper element
  34458. * @param {Element} reference - the reference element (the popper will be relative to this)
  34459. * @param {Element} fixedPosition - is in fixed position mode
  34460. * @returns {Object} An object containing the offsets which will be applied to the popper
  34461. */
  34462. function getReferenceOffsets(state, popper, reference) {
  34463. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  34464. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34465. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  34466. }
  34467. /**
  34468. * Get the outer sizes of the given element (offset size + margins)
  34469. * @method
  34470. * @memberof Popper.Utils
  34471. * @argument {Element} element
  34472. * @returns {Object} object containing width and height properties
  34473. */
  34474. function getOuterSizes(element) {
  34475. var window = element.ownerDocument.defaultView;
  34476. var styles = window.getComputedStyle(element);
  34477. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  34478. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  34479. var result = {
  34480. width: element.offsetWidth + y,
  34481. height: element.offsetHeight + x
  34482. };
  34483. return result;
  34484. }
  34485. /**
  34486. * Get the opposite placement of the given one
  34487. * @method
  34488. * @memberof Popper.Utils
  34489. * @argument {String} placement
  34490. * @returns {String} flipped placement
  34491. */
  34492. function getOppositePlacement(placement) {
  34493. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  34494. return placement.replace(/left|right|bottom|top/g, function (matched) {
  34495. return hash[matched];
  34496. });
  34497. }
  34498. /**
  34499. * Get offsets to the popper
  34500. * @method
  34501. * @memberof Popper.Utils
  34502. * @param {Object} position - CSS position the Popper will get applied
  34503. * @param {HTMLElement} popper - the popper element
  34504. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  34505. * @param {String} placement - one of the valid placement options
  34506. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  34507. */
  34508. function getPopperOffsets(popper, referenceOffsets, placement) {
  34509. placement = placement.split('-')[0];
  34510. // Get popper node sizes
  34511. var popperRect = getOuterSizes(popper);
  34512. // Add position, width and height to our offsets object
  34513. var popperOffsets = {
  34514. width: popperRect.width,
  34515. height: popperRect.height
  34516. };
  34517. // depending by the popper placement we have to compute its offsets slightly differently
  34518. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  34519. var mainSide = isHoriz ? 'top' : 'left';
  34520. var secondarySide = isHoriz ? 'left' : 'top';
  34521. var measurement = isHoriz ? 'height' : 'width';
  34522. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  34523. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  34524. if (placement === secondarySide) {
  34525. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  34526. } else {
  34527. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  34528. }
  34529. return popperOffsets;
  34530. }
  34531. /**
  34532. * Mimics the `find` method of Array
  34533. * @method
  34534. * @memberof Popper.Utils
  34535. * @argument {Array} arr
  34536. * @argument prop
  34537. * @argument value
  34538. * @returns index or -1
  34539. */
  34540. function find(arr, check) {
  34541. // use native find if supported
  34542. if (Array.prototype.find) {
  34543. return arr.find(check);
  34544. }
  34545. // use `filter` to obtain the same behavior of `find`
  34546. return arr.filter(check)[0];
  34547. }
  34548. /**
  34549. * Return the index of the matching object
  34550. * @method
  34551. * @memberof Popper.Utils
  34552. * @argument {Array} arr
  34553. * @argument prop
  34554. * @argument value
  34555. * @returns index or -1
  34556. */
  34557. function findIndex(arr, prop, value) {
  34558. // use native findIndex if supported
  34559. if (Array.prototype.findIndex) {
  34560. return arr.findIndex(function (cur) {
  34561. return cur[prop] === value;
  34562. });
  34563. }
  34564. // use `find` + `indexOf` if `findIndex` isn't supported
  34565. var match = find(arr, function (obj) {
  34566. return obj[prop] === value;
  34567. });
  34568. return arr.indexOf(match);
  34569. }
  34570. /**
  34571. * Loop trough the list of modifiers and run them in order,
  34572. * each of them will then edit the data object.
  34573. * @method
  34574. * @memberof Popper.Utils
  34575. * @param {dataObject} data
  34576. * @param {Array} modifiers
  34577. * @param {String} ends - Optional modifier name used as stopper
  34578. * @returns {dataObject}
  34579. */
  34580. function runModifiers(modifiers, data, ends) {
  34581. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  34582. modifiersToRun.forEach(function (modifier) {
  34583. if (modifier['function']) {
  34584. // eslint-disable-line dot-notation
  34585. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  34586. }
  34587. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  34588. if (modifier.enabled && isFunction(fn)) {
  34589. // Add properties to offsets to make them a complete clientRect object
  34590. // we do this before each modifier to make sure the previous one doesn't
  34591. // mess with these values
  34592. data.offsets.popper = getClientRect(data.offsets.popper);
  34593. data.offsets.reference = getClientRect(data.offsets.reference);
  34594. data = fn(data, modifier);
  34595. }
  34596. });
  34597. return data;
  34598. }
  34599. /**
  34600. * Updates the position of the popper, computing the new offsets and applying
  34601. * the new style.<br />
  34602. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  34603. * @method
  34604. * @memberof Popper
  34605. */
  34606. function update() {
  34607. // if popper is destroyed, don't perform any further update
  34608. if (this.state.isDestroyed) {
  34609. return;
  34610. }
  34611. var data = {
  34612. instance: this,
  34613. styles: {},
  34614. arrowStyles: {},
  34615. attributes: {},
  34616. flipped: false,
  34617. offsets: {}
  34618. };
  34619. // compute reference element offsets
  34620. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  34621. // compute auto placement, store placement inside the data object,
  34622. // modifiers will be able to edit `placement` if needed
  34623. // and refer to originalPlacement to know the original value
  34624. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  34625. // store the computed placement inside `originalPlacement`
  34626. data.originalPlacement = data.placement;
  34627. data.positionFixed = this.options.positionFixed;
  34628. // compute the popper offsets
  34629. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  34630. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  34631. // run the modifiers
  34632. data = runModifiers(this.modifiers, data);
  34633. // the first `update` will call `onCreate` callback
  34634. // the other ones will call `onUpdate` callback
  34635. if (!this.state.isCreated) {
  34636. this.state.isCreated = true;
  34637. this.options.onCreate(data);
  34638. } else {
  34639. this.options.onUpdate(data);
  34640. }
  34641. }
  34642. /**
  34643. * Helper used to know if the given modifier is enabled.
  34644. * @method
  34645. * @memberof Popper.Utils
  34646. * @returns {Boolean}
  34647. */
  34648. function isModifierEnabled(modifiers, modifierName) {
  34649. return modifiers.some(function (_ref) {
  34650. var name = _ref.name,
  34651. enabled = _ref.enabled;
  34652. return enabled && name === modifierName;
  34653. });
  34654. }
  34655. /**
  34656. * Get the prefixed supported property name
  34657. * @method
  34658. * @memberof Popper.Utils
  34659. * @argument {String} property (camelCase)
  34660. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  34661. */
  34662. function getSupportedPropertyName(property) {
  34663. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  34664. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  34665. for (var i = 0; i < prefixes.length; i++) {
  34666. var prefix = prefixes[i];
  34667. var toCheck = prefix ? '' + prefix + upperProp : property;
  34668. if (typeof document.body.style[toCheck] !== 'undefined') {
  34669. return toCheck;
  34670. }
  34671. }
  34672. return null;
  34673. }
  34674. /**
  34675. * Destroys the popper.
  34676. * @method
  34677. * @memberof Popper
  34678. */
  34679. function destroy() {
  34680. this.state.isDestroyed = true;
  34681. // touch DOM only if `applyStyle` modifier is enabled
  34682. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  34683. this.popper.removeAttribute('x-placement');
  34684. this.popper.style.position = '';
  34685. this.popper.style.top = '';
  34686. this.popper.style.left = '';
  34687. this.popper.style.right = '';
  34688. this.popper.style.bottom = '';
  34689. this.popper.style.willChange = '';
  34690. this.popper.style[getSupportedPropertyName('transform')] = '';
  34691. }
  34692. this.disableEventListeners();
  34693. // remove the popper if user explicitly asked for the deletion on destroy
  34694. // do not use `remove` because IE11 doesn't support it
  34695. if (this.options.removeOnDestroy) {
  34696. this.popper.parentNode.removeChild(this.popper);
  34697. }
  34698. return this;
  34699. }
  34700. /**
  34701. * Get the window associated with the element
  34702. * @argument {Element} element
  34703. * @returns {Window}
  34704. */
  34705. function getWindow(element) {
  34706. var ownerDocument = element.ownerDocument;
  34707. return ownerDocument ? ownerDocument.defaultView : window;
  34708. }
  34709. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  34710. var isBody = scrollParent.nodeName === 'BODY';
  34711. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  34712. target.addEventListener(event, callback, { passive: true });
  34713. if (!isBody) {
  34714. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  34715. }
  34716. scrollParents.push(target);
  34717. }
  34718. /**
  34719. * Setup needed event listeners used to update the popper position
  34720. * @method
  34721. * @memberof Popper.Utils
  34722. * @private
  34723. */
  34724. function setupEventListeners(reference, options, state, updateBound) {
  34725. // Resize event listener on window
  34726. state.updateBound = updateBound;
  34727. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  34728. // Scroll event listener on scroll parents
  34729. var scrollElement = getScrollParent(reference);
  34730. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  34731. state.scrollElement = scrollElement;
  34732. state.eventsEnabled = true;
  34733. return state;
  34734. }
  34735. /**
  34736. * It will add resize/scroll events and start recalculating
  34737. * position of the popper element when they are triggered.
  34738. * @method
  34739. * @memberof Popper
  34740. */
  34741. function enableEventListeners() {
  34742. if (!this.state.eventsEnabled) {
  34743. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  34744. }
  34745. }
  34746. /**
  34747. * Remove event listeners used to update the popper position
  34748. * @method
  34749. * @memberof Popper.Utils
  34750. * @private
  34751. */
  34752. function removeEventListeners(reference, state) {
  34753. // Remove resize event listener on window
  34754. getWindow(reference).removeEventListener('resize', state.updateBound);
  34755. // Remove scroll event listener on scroll parents
  34756. state.scrollParents.forEach(function (target) {
  34757. target.removeEventListener('scroll', state.updateBound);
  34758. });
  34759. // Reset state
  34760. state.updateBound = null;
  34761. state.scrollParents = [];
  34762. state.scrollElement = null;
  34763. state.eventsEnabled = false;
  34764. return state;
  34765. }
  34766. /**
  34767. * It will remove resize/scroll events and won't recalculate popper position
  34768. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  34769. * unless you call `update` method manually.
  34770. * @method
  34771. * @memberof Popper
  34772. */
  34773. function disableEventListeners() {
  34774. if (this.state.eventsEnabled) {
  34775. cancelAnimationFrame(this.scheduleUpdate);
  34776. this.state = removeEventListeners(this.reference, this.state);
  34777. }
  34778. }
  34779. /**
  34780. * Tells if a given input is a number
  34781. * @method
  34782. * @memberof Popper.Utils
  34783. * @param {*} input to check
  34784. * @return {Boolean}
  34785. */
  34786. function isNumeric(n) {
  34787. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  34788. }
  34789. /**
  34790. * Set the style to the given popper
  34791. * @method
  34792. * @memberof Popper.Utils
  34793. * @argument {Element} element - Element to apply the style to
  34794. * @argument {Object} styles
  34795. * Object with a list of properties and values which will be applied to the element
  34796. */
  34797. function setStyles(element, styles) {
  34798. Object.keys(styles).forEach(function (prop) {
  34799. var unit = '';
  34800. // add unit if the value is numeric and is one of the following
  34801. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  34802. unit = 'px';
  34803. }
  34804. element.style[prop] = styles[prop] + unit;
  34805. });
  34806. }
  34807. /**
  34808. * Set the attributes to the given popper
  34809. * @method
  34810. * @memberof Popper.Utils
  34811. * @argument {Element} element - Element to apply the attributes to
  34812. * @argument {Object} styles
  34813. * Object with a list of properties and values which will be applied to the element
  34814. */
  34815. function setAttributes(element, attributes) {
  34816. Object.keys(attributes).forEach(function (prop) {
  34817. var value = attributes[prop];
  34818. if (value !== false) {
  34819. element.setAttribute(prop, attributes[prop]);
  34820. } else {
  34821. element.removeAttribute(prop);
  34822. }
  34823. });
  34824. }
  34825. /**
  34826. * @function
  34827. * @memberof Modifiers
  34828. * @argument {Object} data - The data object generated by `update` method
  34829. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  34830. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  34831. * @argument {Object} options - Modifiers configuration and options
  34832. * @returns {Object} The same data object
  34833. */
  34834. function applyStyle(data) {
  34835. // any property present in `data.styles` will be applied to the popper,
  34836. // in this way we can make the 3rd party modifiers add custom styles to it
  34837. // Be aware, modifiers could override the properties defined in the previous
  34838. // lines of this modifier!
  34839. setStyles(data.instance.popper, data.styles);
  34840. // any property present in `data.attributes` will be applied to the popper,
  34841. // they will be set as HTML attributes of the element
  34842. setAttributes(data.instance.popper, data.attributes);
  34843. // if arrowElement is defined and arrowStyles has some properties
  34844. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  34845. setStyles(data.arrowElement, data.arrowStyles);
  34846. }
  34847. return data;
  34848. }
  34849. /**
  34850. * Set the x-placement attribute before everything else because it could be used
  34851. * to add margins to the popper margins needs to be calculated to get the
  34852. * correct popper offsets.
  34853. * @method
  34854. * @memberof Popper.modifiers
  34855. * @param {HTMLElement} reference - The reference element used to position the popper
  34856. * @param {HTMLElement} popper - The HTML element used as popper
  34857. * @param {Object} options - Popper.js options
  34858. */
  34859. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  34860. // compute reference element offsets
  34861. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  34862. // compute auto placement, store placement inside the data object,
  34863. // modifiers will be able to edit `placement` if needed
  34864. // and refer to originalPlacement to know the original value
  34865. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  34866. popper.setAttribute('x-placement', placement);
  34867. // Apply `position` to popper before anything else because
  34868. // without the position applied we can't guarantee correct computations
  34869. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  34870. return options;
  34871. }
  34872. /**
  34873. * @function
  34874. * @memberof Popper.Utils
  34875. * @argument {Object} data - The data object generated by `update` method
  34876. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  34877. * @returns {Object} The popper's position offsets rounded
  34878. *
  34879. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  34880. * good as it can be within reason.
  34881. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  34882. *
  34883. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  34884. * as well on High DPI screens).
  34885. *
  34886. * Firefox prefers no rounding for positioning and does not have blurriness on
  34887. * high DPI screens.
  34888. *
  34889. * Only horizontal placement and left/right values need to be considered.
  34890. */
  34891. function getRoundedOffsets(data, shouldRound) {
  34892. var _data$offsets = data.offsets,
  34893. popper = _data$offsets.popper,
  34894. reference = _data$offsets.reference;
  34895. var round = Math.round,
  34896. floor = Math.floor;
  34897. var noRound = function noRound(v) {
  34898. return v;
  34899. };
  34900. var referenceWidth = round(reference.width);
  34901. var popperWidth = round(popper.width);
  34902. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  34903. var isVariation = data.placement.indexOf('-') !== -1;
  34904. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  34905. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  34906. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  34907. var verticalToInteger = !shouldRound ? noRound : round;
  34908. return {
  34909. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  34910. top: verticalToInteger(popper.top),
  34911. bottom: verticalToInteger(popper.bottom),
  34912. right: horizontalToInteger(popper.right)
  34913. };
  34914. }
  34915. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  34916. /**
  34917. * @function
  34918. * @memberof Modifiers
  34919. * @argument {Object} data - The data object generated by `update` method
  34920. * @argument {Object} options - Modifiers configuration and options
  34921. * @returns {Object} The data object, properly modified
  34922. */
  34923. function computeStyle(data, options) {
  34924. var x = options.x,
  34925. y = options.y;
  34926. var popper = data.offsets.popper;
  34927. // Remove this legacy support in Popper.js v2
  34928. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  34929. return modifier.name === 'applyStyle';
  34930. }).gpuAcceleration;
  34931. if (legacyGpuAccelerationOption !== undefined) {
  34932. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  34933. }
  34934. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  34935. var offsetParent = getOffsetParent(data.instance.popper);
  34936. var offsetParentRect = getBoundingClientRect(offsetParent);
  34937. // Styles
  34938. var styles = {
  34939. position: popper.position
  34940. };
  34941. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  34942. var sideA = x === 'bottom' ? 'top' : 'bottom';
  34943. var sideB = y === 'right' ? 'left' : 'right';
  34944. // if gpuAcceleration is set to `true` and transform is supported,
  34945. // we use `translate3d` to apply the position to the popper we
  34946. // automatically use the supported prefixed version if needed
  34947. var prefixedProperty = getSupportedPropertyName('transform');
  34948. // now, let's make a step back and look at this code closely (wtf?)
  34949. // If the content of the popper grows once it's been positioned, it
  34950. // may happen that the popper gets misplaced because of the new content
  34951. // overflowing its reference element
  34952. // To avoid this problem, we provide two options (x and y), which allow
  34953. // the consumer to define the offset origin.
  34954. // If we position a popper on top of a reference element, we can set
  34955. // `x` to `top` to make the popper grow towards its top instead of
  34956. // its bottom.
  34957. var left = void 0,
  34958. top = void 0;
  34959. if (sideA === 'bottom') {
  34960. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  34961. // and not the bottom of the html element
  34962. if (offsetParent.nodeName === 'HTML') {
  34963. top = -offsetParent.clientHeight + offsets.bottom;
  34964. } else {
  34965. top = -offsetParentRect.height + offsets.bottom;
  34966. }
  34967. } else {
  34968. top = offsets.top;
  34969. }
  34970. if (sideB === 'right') {
  34971. if (offsetParent.nodeName === 'HTML') {
  34972. left = -offsetParent.clientWidth + offsets.right;
  34973. } else {
  34974. left = -offsetParentRect.width + offsets.right;
  34975. }
  34976. } else {
  34977. left = offsets.left;
  34978. }
  34979. if (gpuAcceleration && prefixedProperty) {
  34980. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  34981. styles[sideA] = 0;
  34982. styles[sideB] = 0;
  34983. styles.willChange = 'transform';
  34984. } else {
  34985. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  34986. var invertTop = sideA === 'bottom' ? -1 : 1;
  34987. var invertLeft = sideB === 'right' ? -1 : 1;
  34988. styles[sideA] = top * invertTop;
  34989. styles[sideB] = left * invertLeft;
  34990. styles.willChange = sideA + ', ' + sideB;
  34991. }
  34992. // Attributes
  34993. var attributes = {
  34994. 'x-placement': data.placement
  34995. };
  34996. // Update `data` attributes, styles and arrowStyles
  34997. data.attributes = _extends({}, attributes, data.attributes);
  34998. data.styles = _extends({}, styles, data.styles);
  34999. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  35000. return data;
  35001. }
  35002. /**
  35003. * Helper used to know if the given modifier depends from another one.<br />
  35004. * It checks if the needed modifier is listed and enabled.
  35005. * @method
  35006. * @memberof Popper.Utils
  35007. * @param {Array} modifiers - list of modifiers
  35008. * @param {String} requestingName - name of requesting modifier
  35009. * @param {String} requestedName - name of requested modifier
  35010. * @returns {Boolean}
  35011. */
  35012. function isModifierRequired(modifiers, requestingName, requestedName) {
  35013. var requesting = find(modifiers, function (_ref) {
  35014. var name = _ref.name;
  35015. return name === requestingName;
  35016. });
  35017. var isRequired = !!requesting && modifiers.some(function (modifier) {
  35018. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  35019. });
  35020. if (!isRequired) {
  35021. var _requesting = '`' + requestingName + '`';
  35022. var requested = '`' + requestedName + '`';
  35023. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  35024. }
  35025. return isRequired;
  35026. }
  35027. /**
  35028. * @function
  35029. * @memberof Modifiers
  35030. * @argument {Object} data - The data object generated by update method
  35031. * @argument {Object} options - Modifiers configuration and options
  35032. * @returns {Object} The data object, properly modified
  35033. */
  35034. function arrow(data, options) {
  35035. var _data$offsets$arrow;
  35036. // arrow depends on keepTogether in order to work
  35037. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  35038. return data;
  35039. }
  35040. var arrowElement = options.element;
  35041. // if arrowElement is a string, suppose it's a CSS selector
  35042. if (typeof arrowElement === 'string') {
  35043. arrowElement = data.instance.popper.querySelector(arrowElement);
  35044. // if arrowElement is not found, don't run the modifier
  35045. if (!arrowElement) {
  35046. return data;
  35047. }
  35048. } else {
  35049. // if the arrowElement isn't a query selector we must check that the
  35050. // provided DOM node is child of its popper node
  35051. if (!data.instance.popper.contains(arrowElement)) {
  35052. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  35053. return data;
  35054. }
  35055. }
  35056. var placement = data.placement.split('-')[0];
  35057. var _data$offsets = data.offsets,
  35058. popper = _data$offsets.popper,
  35059. reference = _data$offsets.reference;
  35060. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  35061. var len = isVertical ? 'height' : 'width';
  35062. var sideCapitalized = isVertical ? 'Top' : 'Left';
  35063. var side = sideCapitalized.toLowerCase();
  35064. var altSide = isVertical ? 'left' : 'top';
  35065. var opSide = isVertical ? 'bottom' : 'right';
  35066. var arrowElementSize = getOuterSizes(arrowElement)[len];
  35067. //
  35068. // extends keepTogether behavior making sure the popper and its
  35069. // reference have enough pixels in conjunction
  35070. //
  35071. // top/left side
  35072. if (reference[opSide] - arrowElementSize < popper[side]) {
  35073. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  35074. }
  35075. // bottom/right side
  35076. if (reference[side] + arrowElementSize > popper[opSide]) {
  35077. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  35078. }
  35079. data.offsets.popper = getClientRect(data.offsets.popper);
  35080. // compute center of the popper
  35081. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  35082. // Compute the sideValue using the updated popper offsets
  35083. // take popper margin in account because we don't have this info available
  35084. var css = getStyleComputedProperty(data.instance.popper);
  35085. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  35086. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  35087. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  35088. // prevent arrowElement from being placed not contiguously to its popper
  35089. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  35090. data.arrowElement = arrowElement;
  35091. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  35092. return data;
  35093. }
  35094. /**
  35095. * Get the opposite placement variation of the given one
  35096. * @method
  35097. * @memberof Popper.Utils
  35098. * @argument {String} placement variation
  35099. * @returns {String} flipped placement variation
  35100. */
  35101. function getOppositeVariation(variation) {
  35102. if (variation === 'end') {
  35103. return 'start';
  35104. } else if (variation === 'start') {
  35105. return 'end';
  35106. }
  35107. return variation;
  35108. }
  35109. /**
  35110. * List of accepted placements to use as values of the `placement` option.<br />
  35111. * Valid placements are:
  35112. * - `auto`
  35113. * - `top`
  35114. * - `right`
  35115. * - `bottom`
  35116. * - `left`
  35117. *
  35118. * Each placement can have a variation from this list:
  35119. * - `-start`
  35120. * - `-end`
  35121. *
  35122. * Variations are interpreted easily if you think of them as the left to right
  35123. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  35124. * is right.<br />
  35125. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  35126. *
  35127. * Some valid examples are:
  35128. * - `top-end` (on top of reference, right aligned)
  35129. * - `right-start` (on right of reference, top aligned)
  35130. * - `bottom` (on bottom, centered)
  35131. * - `auto-end` (on the side with more space available, alignment depends by placement)
  35132. *
  35133. * @static
  35134. * @type {Array}
  35135. * @enum {String}
  35136. * @readonly
  35137. * @method placements
  35138. * @memberof Popper
  35139. */
  35140. 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'];
  35141. // Get rid of `auto` `auto-start` and `auto-end`
  35142. var validPlacements = placements.slice(3);
  35143. /**
  35144. * Given an initial placement, returns all the subsequent placements
  35145. * clockwise (or counter-clockwise).
  35146. *
  35147. * @method
  35148. * @memberof Popper.Utils
  35149. * @argument {String} placement - A valid placement (it accepts variations)
  35150. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  35151. * @returns {Array} placements including their variations
  35152. */
  35153. function clockwise(placement) {
  35154. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  35155. var index = validPlacements.indexOf(placement);
  35156. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  35157. return counter ? arr.reverse() : arr;
  35158. }
  35159. var BEHAVIORS = {
  35160. FLIP: 'flip',
  35161. CLOCKWISE: 'clockwise',
  35162. COUNTERCLOCKWISE: 'counterclockwise'
  35163. };
  35164. /**
  35165. * @function
  35166. * @memberof Modifiers
  35167. * @argument {Object} data - The data object generated by update method
  35168. * @argument {Object} options - Modifiers configuration and options
  35169. * @returns {Object} The data object, properly modified
  35170. */
  35171. function flip(data, options) {
  35172. // if `inner` modifier is enabled, we can't use the `flip` modifier
  35173. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  35174. return data;
  35175. }
  35176. if (data.flipped && data.placement === data.originalPlacement) {
  35177. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  35178. return data;
  35179. }
  35180. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  35181. var placement = data.placement.split('-')[0];
  35182. var placementOpposite = getOppositePlacement(placement);
  35183. var variation = data.placement.split('-')[1] || '';
  35184. var flipOrder = [];
  35185. switch (options.behavior) {
  35186. case BEHAVIORS.FLIP:
  35187. flipOrder = [placement, placementOpposite];
  35188. break;
  35189. case BEHAVIORS.CLOCKWISE:
  35190. flipOrder = clockwise(placement);
  35191. break;
  35192. case BEHAVIORS.COUNTERCLOCKWISE:
  35193. flipOrder = clockwise(placement, true);
  35194. break;
  35195. default:
  35196. flipOrder = options.behavior;
  35197. }
  35198. flipOrder.forEach(function (step, index) {
  35199. if (placement !== step || flipOrder.length === index + 1) {
  35200. return data;
  35201. }
  35202. placement = data.placement.split('-')[0];
  35203. placementOpposite = getOppositePlacement(placement);
  35204. var popperOffsets = data.offsets.popper;
  35205. var refOffsets = data.offsets.reference;
  35206. // using floor because the reference offsets may contain decimals we are not going to consider here
  35207. var floor = Math.floor;
  35208. 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);
  35209. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  35210. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  35211. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  35212. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  35213. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  35214. // flip the variation if required
  35215. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35216. // flips variation if reference element overflows boundaries
  35217. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  35218. // flips variation if popper content overflows boundaries
  35219. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  35220. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  35221. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  35222. // this boolean to detect any flip loop
  35223. data.flipped = true;
  35224. if (overlapsRef || overflowsBoundaries) {
  35225. placement = flipOrder[index + 1];
  35226. }
  35227. if (flippedVariation) {
  35228. variation = getOppositeVariation(variation);
  35229. }
  35230. data.placement = placement + (variation ? '-' + variation : '');
  35231. // this object contains `position`, we want to preserve it along with
  35232. // any additional property we may add in the future
  35233. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  35234. data = runModifiers(data.instance.modifiers, data, 'flip');
  35235. }
  35236. });
  35237. return data;
  35238. }
  35239. /**
  35240. * @function
  35241. * @memberof Modifiers
  35242. * @argument {Object} data - The data object generated by update method
  35243. * @argument {Object} options - Modifiers configuration and options
  35244. * @returns {Object} The data object, properly modified
  35245. */
  35246. function keepTogether(data) {
  35247. var _data$offsets = data.offsets,
  35248. popper = _data$offsets.popper,
  35249. reference = _data$offsets.reference;
  35250. var placement = data.placement.split('-')[0];
  35251. var floor = Math.floor;
  35252. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35253. var side = isVertical ? 'right' : 'bottom';
  35254. var opSide = isVertical ? 'left' : 'top';
  35255. var measurement = isVertical ? 'width' : 'height';
  35256. if (popper[side] < floor(reference[opSide])) {
  35257. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  35258. }
  35259. if (popper[opSide] > floor(reference[side])) {
  35260. data.offsets.popper[opSide] = floor(reference[side]);
  35261. }
  35262. return data;
  35263. }
  35264. /**
  35265. * Converts a string containing value + unit into a px value number
  35266. * @function
  35267. * @memberof {modifiers~offset}
  35268. * @private
  35269. * @argument {String} str - Value + unit string
  35270. * @argument {String} measurement - `height` or `width`
  35271. * @argument {Object} popperOffsets
  35272. * @argument {Object} referenceOffsets
  35273. * @returns {Number|String}
  35274. * Value in pixels, or original string if no values were extracted
  35275. */
  35276. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  35277. // separate value from unit
  35278. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  35279. var value = +split[1];
  35280. var unit = split[2];
  35281. // If it's not a number it's an operator, I guess
  35282. if (!value) {
  35283. return str;
  35284. }
  35285. if (unit.indexOf('%') === 0) {
  35286. var element = void 0;
  35287. switch (unit) {
  35288. case '%p':
  35289. element = popperOffsets;
  35290. break;
  35291. case '%':
  35292. case '%r':
  35293. default:
  35294. element = referenceOffsets;
  35295. }
  35296. var rect = getClientRect(element);
  35297. return rect[measurement] / 100 * value;
  35298. } else if (unit === 'vh' || unit === 'vw') {
  35299. // if is a vh or vw, we calculate the size based on the viewport
  35300. var size = void 0;
  35301. if (unit === 'vh') {
  35302. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  35303. } else {
  35304. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  35305. }
  35306. return size / 100 * value;
  35307. } else {
  35308. // if is an explicit pixel unit, we get rid of the unit and keep the value
  35309. // if is an implicit unit, it's px, and we return just the value
  35310. return value;
  35311. }
  35312. }
  35313. /**
  35314. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  35315. * @function
  35316. * @memberof {modifiers~offset}
  35317. * @private
  35318. * @argument {String} offset
  35319. * @argument {Object} popperOffsets
  35320. * @argument {Object} referenceOffsets
  35321. * @argument {String} basePlacement
  35322. * @returns {Array} a two cells array with x and y offsets in numbers
  35323. */
  35324. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  35325. var offsets = [0, 0];
  35326. // Use height if placement is left or right and index is 0 otherwise use width
  35327. // in this way the first offset will use an axis and the second one
  35328. // will use the other one
  35329. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  35330. // Split the offset string to obtain a list of values and operands
  35331. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  35332. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  35333. return frag.trim();
  35334. });
  35335. // Detect if the offset string contains a pair of values or a single one
  35336. // they could be separated by comma or space
  35337. var divider = fragments.indexOf(find(fragments, function (frag) {
  35338. return frag.search(/,|\s/) !== -1;
  35339. }));
  35340. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  35341. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  35342. }
  35343. // If divider is found, we divide the list of values and operands to divide
  35344. // them by ofset X and Y.
  35345. var splitRegex = /\s*,\s*|\s+/;
  35346. 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];
  35347. // Convert the values with units to absolute pixels to allow our computations
  35348. ops = ops.map(function (op, index) {
  35349. // Most of the units rely on the orientation of the popper
  35350. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  35351. var mergeWithPrevious = false;
  35352. return op
  35353. // This aggregates any `+` or `-` sign that aren't considered operators
  35354. // e.g.: 10 + +5 => [10, +, +5]
  35355. .reduce(function (a, b) {
  35356. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  35357. a[a.length - 1] = b;
  35358. mergeWithPrevious = true;
  35359. return a;
  35360. } else if (mergeWithPrevious) {
  35361. a[a.length - 1] += b;
  35362. mergeWithPrevious = false;
  35363. return a;
  35364. } else {
  35365. return a.concat(b);
  35366. }
  35367. }, [])
  35368. // Here we convert the string values into number values (in px)
  35369. .map(function (str) {
  35370. return toValue(str, measurement, popperOffsets, referenceOffsets);
  35371. });
  35372. });
  35373. // Loop trough the offsets arrays and execute the operations
  35374. ops.forEach(function (op, index) {
  35375. op.forEach(function (frag, index2) {
  35376. if (isNumeric(frag)) {
  35377. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  35378. }
  35379. });
  35380. });
  35381. return offsets;
  35382. }
  35383. /**
  35384. * @function
  35385. * @memberof Modifiers
  35386. * @argument {Object} data - The data object generated by update method
  35387. * @argument {Object} options - Modifiers configuration and options
  35388. * @argument {Number|String} options.offset=0
  35389. * The offset value as described in the modifier description
  35390. * @returns {Object} The data object, properly modified
  35391. */
  35392. function offset(data, _ref) {
  35393. var offset = _ref.offset;
  35394. var placement = data.placement,
  35395. _data$offsets = data.offsets,
  35396. popper = _data$offsets.popper,
  35397. reference = _data$offsets.reference;
  35398. var basePlacement = placement.split('-')[0];
  35399. var offsets = void 0;
  35400. if (isNumeric(+offset)) {
  35401. offsets = [+offset, 0];
  35402. } else {
  35403. offsets = parseOffset(offset, popper, reference, basePlacement);
  35404. }
  35405. if (basePlacement === 'left') {
  35406. popper.top += offsets[0];
  35407. popper.left -= offsets[1];
  35408. } else if (basePlacement === 'right') {
  35409. popper.top += offsets[0];
  35410. popper.left += offsets[1];
  35411. } else if (basePlacement === 'top') {
  35412. popper.left += offsets[0];
  35413. popper.top -= offsets[1];
  35414. } else if (basePlacement === 'bottom') {
  35415. popper.left += offsets[0];
  35416. popper.top += offsets[1];
  35417. }
  35418. data.popper = popper;
  35419. return data;
  35420. }
  35421. /**
  35422. * @function
  35423. * @memberof Modifiers
  35424. * @argument {Object} data - The data object generated by `update` method
  35425. * @argument {Object} options - Modifiers configuration and options
  35426. * @returns {Object} The data object, properly modified
  35427. */
  35428. function preventOverflow(data, options) {
  35429. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  35430. // If offsetParent is the reference element, we really want to
  35431. // go one step up and use the next offsetParent as reference to
  35432. // avoid to make this modifier completely useless and look like broken
  35433. if (data.instance.reference === boundariesElement) {
  35434. boundariesElement = getOffsetParent(boundariesElement);
  35435. }
  35436. // NOTE: DOM access here
  35437. // resets the popper's position so that the document size can be calculated excluding
  35438. // the size of the popper element itself
  35439. var transformProp = getSupportedPropertyName('transform');
  35440. var popperStyles = data.instance.popper.style; // assignment to help minification
  35441. var top = popperStyles.top,
  35442. left = popperStyles.left,
  35443. transform = popperStyles[transformProp];
  35444. popperStyles.top = '';
  35445. popperStyles.left = '';
  35446. popperStyles[transformProp] = '';
  35447. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  35448. // NOTE: DOM access here
  35449. // restores the original style properties after the offsets have been computed
  35450. popperStyles.top = top;
  35451. popperStyles.left = left;
  35452. popperStyles[transformProp] = transform;
  35453. options.boundaries = boundaries;
  35454. var order = options.priority;
  35455. var popper = data.offsets.popper;
  35456. var check = {
  35457. primary: function primary(placement) {
  35458. var value = popper[placement];
  35459. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  35460. value = Math.max(popper[placement], boundaries[placement]);
  35461. }
  35462. return defineProperty({}, placement, value);
  35463. },
  35464. secondary: function secondary(placement) {
  35465. var mainSide = placement === 'right' ? 'left' : 'top';
  35466. var value = popper[mainSide];
  35467. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  35468. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  35469. }
  35470. return defineProperty({}, mainSide, value);
  35471. }
  35472. };
  35473. order.forEach(function (placement) {
  35474. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  35475. popper = _extends({}, popper, check[side](placement));
  35476. });
  35477. data.offsets.popper = popper;
  35478. return data;
  35479. }
  35480. /**
  35481. * @function
  35482. * @memberof Modifiers
  35483. * @argument {Object} data - The data object generated by `update` method
  35484. * @argument {Object} options - Modifiers configuration and options
  35485. * @returns {Object} The data object, properly modified
  35486. */
  35487. function shift(data) {
  35488. var placement = data.placement;
  35489. var basePlacement = placement.split('-')[0];
  35490. var shiftvariation = placement.split('-')[1];
  35491. // if shift shiftvariation is specified, run the modifier
  35492. if (shiftvariation) {
  35493. var _data$offsets = data.offsets,
  35494. reference = _data$offsets.reference,
  35495. popper = _data$offsets.popper;
  35496. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  35497. var side = isVertical ? 'left' : 'top';
  35498. var measurement = isVertical ? 'width' : 'height';
  35499. var shiftOffsets = {
  35500. start: defineProperty({}, side, reference[side]),
  35501. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  35502. };
  35503. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  35504. }
  35505. return data;
  35506. }
  35507. /**
  35508. * @function
  35509. * @memberof Modifiers
  35510. * @argument {Object} data - The data object generated by update method
  35511. * @argument {Object} options - Modifiers configuration and options
  35512. * @returns {Object} The data object, properly modified
  35513. */
  35514. function hide(data) {
  35515. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  35516. return data;
  35517. }
  35518. var refRect = data.offsets.reference;
  35519. var bound = find(data.instance.modifiers, function (modifier) {
  35520. return modifier.name === 'preventOverflow';
  35521. }).boundaries;
  35522. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  35523. // Avoid unnecessary DOM access if visibility hasn't changed
  35524. if (data.hide === true) {
  35525. return data;
  35526. }
  35527. data.hide = true;
  35528. data.attributes['x-out-of-boundaries'] = '';
  35529. } else {
  35530. // Avoid unnecessary DOM access if visibility hasn't changed
  35531. if (data.hide === false) {
  35532. return data;
  35533. }
  35534. data.hide = false;
  35535. data.attributes['x-out-of-boundaries'] = false;
  35536. }
  35537. return data;
  35538. }
  35539. /**
  35540. * @function
  35541. * @memberof Modifiers
  35542. * @argument {Object} data - The data object generated by `update` method
  35543. * @argument {Object} options - Modifiers configuration and options
  35544. * @returns {Object} The data object, properly modified
  35545. */
  35546. function inner(data) {
  35547. var placement = data.placement;
  35548. var basePlacement = placement.split('-')[0];
  35549. var _data$offsets = data.offsets,
  35550. popper = _data$offsets.popper,
  35551. reference = _data$offsets.reference;
  35552. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  35553. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  35554. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  35555. data.placement = getOppositePlacement(placement);
  35556. data.offsets.popper = getClientRect(popper);
  35557. return data;
  35558. }
  35559. /**
  35560. * Modifier function, each modifier can have a function of this type assigned
  35561. * to its `fn` property.<br />
  35562. * These functions will be called on each update, this means that you must
  35563. * make sure they are performant enough to avoid performance bottlenecks.
  35564. *
  35565. * @function ModifierFn
  35566. * @argument {dataObject} data - The data object generated by `update` method
  35567. * @argument {Object} options - Modifiers configuration and options
  35568. * @returns {dataObject} The data object, properly modified
  35569. */
  35570. /**
  35571. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  35572. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  35573. * needed by the library.
  35574. *
  35575. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  35576. * All the other properties are configurations that could be tweaked.
  35577. * @namespace modifiers
  35578. */
  35579. var modifiers = {
  35580. /**
  35581. * Modifier used to shift the popper on the start or end of its reference
  35582. * element.<br />
  35583. * It will read the variation of the `placement` property.<br />
  35584. * It can be one either `-end` or `-start`.
  35585. * @memberof modifiers
  35586. * @inner
  35587. */
  35588. shift: {
  35589. /** @prop {number} order=100 - Index used to define the order of execution */
  35590. order: 100,
  35591. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35592. enabled: true,
  35593. /** @prop {ModifierFn} */
  35594. fn: shift
  35595. },
  35596. /**
  35597. * The `offset` modifier can shift your popper on both its axis.
  35598. *
  35599. * It accepts the following units:
  35600. * - `px` or unit-less, interpreted as pixels
  35601. * - `%` or `%r`, percentage relative to the length of the reference element
  35602. * - `%p`, percentage relative to the length of the popper element
  35603. * - `vw`, CSS viewport width unit
  35604. * - `vh`, CSS viewport height unit
  35605. *
  35606. * For length is intended the main axis relative to the placement of the popper.<br />
  35607. * This means that if the placement is `top` or `bottom`, the length will be the
  35608. * `width`. In case of `left` or `right`, it will be the `height`.
  35609. *
  35610. * You can provide a single value (as `Number` or `String`), or a pair of values
  35611. * as `String` divided by a comma or one (or more) white spaces.<br />
  35612. * The latter is a deprecated method because it leads to confusion and will be
  35613. * removed in v2.<br />
  35614. * Additionally, it accepts additions and subtractions between different units.
  35615. * Note that multiplications and divisions aren't supported.
  35616. *
  35617. * Valid examples are:
  35618. * ```
  35619. * 10
  35620. * '10%'
  35621. * '10, 10'
  35622. * '10%, 10'
  35623. * '10 + 10%'
  35624. * '10 - 5vh + 3%'
  35625. * '-10px + 5vh, 5px - 6%'
  35626. * ```
  35627. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  35628. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  35629. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  35630. *
  35631. * @memberof modifiers
  35632. * @inner
  35633. */
  35634. offset: {
  35635. /** @prop {number} order=200 - Index used to define the order of execution */
  35636. order: 200,
  35637. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35638. enabled: true,
  35639. /** @prop {ModifierFn} */
  35640. fn: offset,
  35641. /** @prop {Number|String} offset=0
  35642. * The offset value as described in the modifier description
  35643. */
  35644. offset: 0
  35645. },
  35646. /**
  35647. * Modifier used to prevent the popper from being positioned outside the boundary.
  35648. *
  35649. * A scenario exists where the reference itself is not within the boundaries.<br />
  35650. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  35651. * In this case we need to decide whether the popper should either:
  35652. *
  35653. * - detach from the reference and remain "trapped" in the boundaries, or
  35654. * - if it should ignore the boundary and "escape with its reference"
  35655. *
  35656. * When `escapeWithReference` is set to`true` and reference is completely
  35657. * outside its boundaries, the popper will overflow (or completely leave)
  35658. * the boundaries in order to remain attached to the edge of the reference.
  35659. *
  35660. * @memberof modifiers
  35661. * @inner
  35662. */
  35663. preventOverflow: {
  35664. /** @prop {number} order=300 - Index used to define the order of execution */
  35665. order: 300,
  35666. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35667. enabled: true,
  35668. /** @prop {ModifierFn} */
  35669. fn: preventOverflow,
  35670. /**
  35671. * @prop {Array} [priority=['left','right','top','bottom']]
  35672. * Popper will try to prevent overflow following these priorities by default,
  35673. * then, it could overflow on the left and on top of the `boundariesElement`
  35674. */
  35675. priority: ['left', 'right', 'top', 'bottom'],
  35676. /**
  35677. * @prop {number} padding=5
  35678. * Amount of pixel used to define a minimum distance between the boundaries
  35679. * and the popper. This makes sure the popper always has a little padding
  35680. * between the edges of its container
  35681. */
  35682. padding: 5,
  35683. /**
  35684. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  35685. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  35686. * `viewport` or any DOM element.
  35687. */
  35688. boundariesElement: 'scrollParent'
  35689. },
  35690. /**
  35691. * Modifier used to make sure the reference and its popper stay near each other
  35692. * without leaving any gap between the two. Especially useful when the arrow is
  35693. * enabled and you want to ensure that it points to its reference element.
  35694. * It cares only about the first axis. You can still have poppers with margin
  35695. * between the popper and its reference element.
  35696. * @memberof modifiers
  35697. * @inner
  35698. */
  35699. keepTogether: {
  35700. /** @prop {number} order=400 - Index used to define the order of execution */
  35701. order: 400,
  35702. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35703. enabled: true,
  35704. /** @prop {ModifierFn} */
  35705. fn: keepTogether
  35706. },
  35707. /**
  35708. * This modifier is used to move the `arrowElement` of the popper to make
  35709. * sure it is positioned between the reference element and its popper element.
  35710. * It will read the outer size of the `arrowElement` node to detect how many
  35711. * pixels of conjunction are needed.
  35712. *
  35713. * It has no effect if no `arrowElement` is provided.
  35714. * @memberof modifiers
  35715. * @inner
  35716. */
  35717. arrow: {
  35718. /** @prop {number} order=500 - Index used to define the order of execution */
  35719. order: 500,
  35720. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35721. enabled: true,
  35722. /** @prop {ModifierFn} */
  35723. fn: arrow,
  35724. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  35725. element: '[x-arrow]'
  35726. },
  35727. /**
  35728. * Modifier used to flip the popper's placement when it starts to overlap its
  35729. * reference element.
  35730. *
  35731. * Requires the `preventOverflow` modifier before it in order to work.
  35732. *
  35733. * **NOTE:** this modifier will interrupt the current update cycle and will
  35734. * restart it if it detects the need to flip the placement.
  35735. * @memberof modifiers
  35736. * @inner
  35737. */
  35738. flip: {
  35739. /** @prop {number} order=600 - Index used to define the order of execution */
  35740. order: 600,
  35741. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35742. enabled: true,
  35743. /** @prop {ModifierFn} */
  35744. fn: flip,
  35745. /**
  35746. * @prop {String|Array} behavior='flip'
  35747. * The behavior used to change the popper's placement. It can be one of
  35748. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  35749. * placements (with optional variations)
  35750. */
  35751. behavior: 'flip',
  35752. /**
  35753. * @prop {number} padding=5
  35754. * The popper will flip if it hits the edges of the `boundariesElement`
  35755. */
  35756. padding: 5,
  35757. /**
  35758. * @prop {String|HTMLElement} boundariesElement='viewport'
  35759. * The element which will define the boundaries of the popper position.
  35760. * The popper will never be placed outside of the defined boundaries
  35761. * (except if `keepTogether` is enabled)
  35762. */
  35763. boundariesElement: 'viewport',
  35764. /**
  35765. * @prop {Boolean} flipVariations=false
  35766. * The popper will switch placement variation between `-start` and `-end` when
  35767. * the reference element overlaps its boundaries.
  35768. *
  35769. * The original placement should have a set variation.
  35770. */
  35771. flipVariations: false,
  35772. /**
  35773. * @prop {Boolean} flipVariationsByContent=false
  35774. * The popper will switch placement variation between `-start` and `-end` when
  35775. * the popper element overlaps its reference boundaries.
  35776. *
  35777. * The original placement should have a set variation.
  35778. */
  35779. flipVariationsByContent: false
  35780. },
  35781. /**
  35782. * Modifier used to make the popper flow toward the inner of the reference element.
  35783. * By default, when this modifier is disabled, the popper will be placed outside
  35784. * the reference element.
  35785. * @memberof modifiers
  35786. * @inner
  35787. */
  35788. inner: {
  35789. /** @prop {number} order=700 - Index used to define the order of execution */
  35790. order: 700,
  35791. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  35792. enabled: false,
  35793. /** @prop {ModifierFn} */
  35794. fn: inner
  35795. },
  35796. /**
  35797. * Modifier used to hide the popper when its reference element is outside of the
  35798. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  35799. * be used to hide with a CSS selector the popper when its reference is
  35800. * out of boundaries.
  35801. *
  35802. * Requires the `preventOverflow` modifier before it in order to work.
  35803. * @memberof modifiers
  35804. * @inner
  35805. */
  35806. hide: {
  35807. /** @prop {number} order=800 - Index used to define the order of execution */
  35808. order: 800,
  35809. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35810. enabled: true,
  35811. /** @prop {ModifierFn} */
  35812. fn: hide
  35813. },
  35814. /**
  35815. * Computes the style that will be applied to the popper element to gets
  35816. * properly positioned.
  35817. *
  35818. * Note that this modifier will not touch the DOM, it just prepares the styles
  35819. * so that `applyStyle` modifier can apply it. This separation is useful
  35820. * in case you need to replace `applyStyle` with a custom implementation.
  35821. *
  35822. * This modifier has `850` as `order` value to maintain backward compatibility
  35823. * with previous versions of Popper.js. Expect the modifiers ordering method
  35824. * to change in future major versions of the library.
  35825. *
  35826. * @memberof modifiers
  35827. * @inner
  35828. */
  35829. computeStyle: {
  35830. /** @prop {number} order=850 - Index used to define the order of execution */
  35831. order: 850,
  35832. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35833. enabled: true,
  35834. /** @prop {ModifierFn} */
  35835. fn: computeStyle,
  35836. /**
  35837. * @prop {Boolean} gpuAcceleration=true
  35838. * If true, it uses the CSS 3D transformation to position the popper.
  35839. * Otherwise, it will use the `top` and `left` properties
  35840. */
  35841. gpuAcceleration: true,
  35842. /**
  35843. * @prop {string} [x='bottom']
  35844. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  35845. * Change this if your popper should grow in a direction different from `bottom`
  35846. */
  35847. x: 'bottom',
  35848. /**
  35849. * @prop {string} [x='left']
  35850. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  35851. * Change this if your popper should grow in a direction different from `right`
  35852. */
  35853. y: 'right'
  35854. },
  35855. /**
  35856. * Applies the computed styles to the popper element.
  35857. *
  35858. * All the DOM manipulations are limited to this modifier. This is useful in case
  35859. * you want to integrate Popper.js inside a framework or view library and you
  35860. * want to delegate all the DOM manipulations to it.
  35861. *
  35862. * Note that if you disable this modifier, you must make sure the popper element
  35863. * has its position set to `absolute` before Popper.js can do its work!
  35864. *
  35865. * Just disable this modifier and define your own to achieve the desired effect.
  35866. *
  35867. * @memberof modifiers
  35868. * @inner
  35869. */
  35870. applyStyle: {
  35871. /** @prop {number} order=900 - Index used to define the order of execution */
  35872. order: 900,
  35873. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35874. enabled: true,
  35875. /** @prop {ModifierFn} */
  35876. fn: applyStyle,
  35877. /** @prop {Function} */
  35878. onLoad: applyStyleOnLoad,
  35879. /**
  35880. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  35881. * @prop {Boolean} gpuAcceleration=true
  35882. * If true, it uses the CSS 3D transformation to position the popper.
  35883. * Otherwise, it will use the `top` and `left` properties
  35884. */
  35885. gpuAcceleration: undefined
  35886. }
  35887. };
  35888. /**
  35889. * The `dataObject` is an object containing all the information used by Popper.js.
  35890. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  35891. * @name dataObject
  35892. * @property {Object} data.instance The Popper.js instance
  35893. * @property {String} data.placement Placement applied to popper
  35894. * @property {String} data.originalPlacement Placement originally defined on init
  35895. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  35896. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  35897. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  35898. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35899. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35900. * @property {Object} data.boundaries Offsets of the popper boundaries
  35901. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  35902. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  35903. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  35904. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  35905. */
  35906. /**
  35907. * Default options provided to Popper.js constructor.<br />
  35908. * These can be overridden using the `options` argument of Popper.js.<br />
  35909. * To override an option, simply pass an object with the same
  35910. * structure of the `options` object, as the 3rd argument. For example:
  35911. * ```
  35912. * new Popper(ref, pop, {
  35913. * modifiers: {
  35914. * preventOverflow: { enabled: false }
  35915. * }
  35916. * })
  35917. * ```
  35918. * @type {Object}
  35919. * @static
  35920. * @memberof Popper
  35921. */
  35922. var Defaults = {
  35923. /**
  35924. * Popper's placement.
  35925. * @prop {Popper.placements} placement='bottom'
  35926. */
  35927. placement: 'bottom',
  35928. /**
  35929. * Set this to true if you want popper to position it self in 'fixed' mode
  35930. * @prop {Boolean} positionFixed=false
  35931. */
  35932. positionFixed: false,
  35933. /**
  35934. * Whether events (resize, scroll) are initially enabled.
  35935. * @prop {Boolean} eventsEnabled=true
  35936. */
  35937. eventsEnabled: true,
  35938. /**
  35939. * Set to true if you want to automatically remove the popper when
  35940. * you call the `destroy` method.
  35941. * @prop {Boolean} removeOnDestroy=false
  35942. */
  35943. removeOnDestroy: false,
  35944. /**
  35945. * Callback called when the popper is created.<br />
  35946. * By default, it is set to no-op.<br />
  35947. * Access Popper.js instance with `data.instance`.
  35948. * @prop {onCreate}
  35949. */
  35950. onCreate: function onCreate() {},
  35951. /**
  35952. * Callback called when the popper is updated. This callback is not called
  35953. * on the initialization/creation of the popper, but only on subsequent
  35954. * updates.<br />
  35955. * By default, it is set to no-op.<br />
  35956. * Access Popper.js instance with `data.instance`.
  35957. * @prop {onUpdate}
  35958. */
  35959. onUpdate: function onUpdate() {},
  35960. /**
  35961. * List of modifiers used to modify the offsets before they are applied to the popper.
  35962. * They provide most of the functionalities of Popper.js.
  35963. * @prop {modifiers}
  35964. */
  35965. modifiers: modifiers
  35966. };
  35967. /**
  35968. * @callback onCreate
  35969. * @param {dataObject} data
  35970. */
  35971. /**
  35972. * @callback onUpdate
  35973. * @param {dataObject} data
  35974. */
  35975. // Utils
  35976. // Methods
  35977. var Popper = function () {
  35978. /**
  35979. * Creates a new Popper.js instance.
  35980. * @class Popper
  35981. * @param {Element|referenceObject} reference - The reference element used to position the popper
  35982. * @param {Element} popper - The HTML / XML element used as the popper
  35983. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  35984. * @return {Object} instance - The generated Popper.js instance
  35985. */
  35986. function Popper(reference, popper) {
  35987. var _this = this;
  35988. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  35989. classCallCheck(this, Popper);
  35990. this.scheduleUpdate = function () {
  35991. return requestAnimationFrame(_this.update);
  35992. };
  35993. // make update() debounced, so that it only runs at most once-per-tick
  35994. this.update = debounce(this.update.bind(this));
  35995. // with {} we create a new object with the options inside it
  35996. this.options = _extends({}, Popper.Defaults, options);
  35997. // init state
  35998. this.state = {
  35999. isDestroyed: false,
  36000. isCreated: false,
  36001. scrollParents: []
  36002. };
  36003. // get reference and popper elements (allow jQuery wrappers)
  36004. this.reference = reference && reference.jquery ? reference[0] : reference;
  36005. this.popper = popper && popper.jquery ? popper[0] : popper;
  36006. // Deep merge modifiers options
  36007. this.options.modifiers = {};
  36008. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  36009. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  36010. });
  36011. // Refactoring modifiers' list (Object => Array)
  36012. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  36013. return _extends({
  36014. name: name
  36015. }, _this.options.modifiers[name]);
  36016. })
  36017. // sort the modifiers by order
  36018. .sort(function (a, b) {
  36019. return a.order - b.order;
  36020. });
  36021. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  36022. // such code is executed in the same order of its modifier
  36023. // they could add new properties to their options configuration
  36024. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  36025. this.modifiers.forEach(function (modifierOptions) {
  36026. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  36027. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  36028. }
  36029. });
  36030. // fire the first update to position the popper in the right place
  36031. this.update();
  36032. var eventsEnabled = this.options.eventsEnabled;
  36033. if (eventsEnabled) {
  36034. // setup event listeners, they will take care of update the position in specific situations
  36035. this.enableEventListeners();
  36036. }
  36037. this.state.eventsEnabled = eventsEnabled;
  36038. }
  36039. // We can't use class properties because they don't get listed in the
  36040. // class prototype and break stuff like Sinon stubs
  36041. createClass(Popper, [{
  36042. key: 'update',
  36043. value: function update$$1() {
  36044. return update.call(this);
  36045. }
  36046. }, {
  36047. key: 'destroy',
  36048. value: function destroy$$1() {
  36049. return destroy.call(this);
  36050. }
  36051. }, {
  36052. key: 'enableEventListeners',
  36053. value: function enableEventListeners$$1() {
  36054. return enableEventListeners.call(this);
  36055. }
  36056. }, {
  36057. key: 'disableEventListeners',
  36058. value: function disableEventListeners$$1() {
  36059. return disableEventListeners.call(this);
  36060. }
  36061. /**
  36062. * Schedules an update. It will run on the next UI update available.
  36063. * @method scheduleUpdate
  36064. * @memberof Popper
  36065. */
  36066. /**
  36067. * Collection of utilities useful when writing custom modifiers.
  36068. * Starting from version 1.7, this method is available only if you
  36069. * include `popper-utils.js` before `popper.js`.
  36070. *
  36071. * **DEPRECATION**: This way to access PopperUtils is deprecated
  36072. * and will be removed in v2! Use the PopperUtils module directly instead.
  36073. * Due to the high instability of the methods contained in Utils, we can't
  36074. * guarantee them to follow semver. Use them at your own risk!
  36075. * @static
  36076. * @private
  36077. * @type {Object}
  36078. * @deprecated since version 1.8
  36079. * @member Utils
  36080. * @memberof Popper
  36081. */
  36082. }]);
  36083. return Popper;
  36084. }();
  36085. /**
  36086. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  36087. * and lets you use it as replacement of a real DOM node.<br />
  36088. * You can use this method to position a popper relatively to a set of coordinates
  36089. * in case you don't have a DOM node to use as reference.
  36090. *
  36091. * ```
  36092. * new Popper(referenceObject, popperNode);
  36093. * ```
  36094. *
  36095. * NB: This feature isn't supported in Internet Explorer 10.
  36096. * @name referenceObject
  36097. * @property {Function} data.getBoundingClientRect
  36098. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  36099. * @property {number} data.clientWidth
  36100. * An ES6 getter that will return the width of the virtual reference element.
  36101. * @property {number} data.clientHeight
  36102. * An ES6 getter that will return the height of the virtual reference element.
  36103. */
  36104. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  36105. Popper.placements = placements;
  36106. Popper.Defaults = Defaults;
  36107. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  36108. //# sourceMappingURL=popper.js.map
  36109. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  36110. /***/ }),
  36111. /***/ "./node_modules/process/browser.js":
  36112. /*!*****************************************!*\
  36113. !*** ./node_modules/process/browser.js ***!
  36114. \*****************************************/
  36115. /*! no static exports found */
  36116. /***/ (function(module, exports) {
  36117. // shim for using process in browser
  36118. var process = module.exports = {};
  36119. // cached from whatever global is present so that test runners that stub it
  36120. // don't break things. But we need to wrap it in a try catch in case it is
  36121. // wrapped in strict mode code which doesn't define any globals. It's inside a
  36122. // function because try/catches deoptimize in certain engines.
  36123. var cachedSetTimeout;
  36124. var cachedClearTimeout;
  36125. function defaultSetTimout() {
  36126. throw new Error('setTimeout has not been defined');
  36127. }
  36128. function defaultClearTimeout () {
  36129. throw new Error('clearTimeout has not been defined');
  36130. }
  36131. (function () {
  36132. try {
  36133. if (typeof setTimeout === 'function') {
  36134. cachedSetTimeout = setTimeout;
  36135. } else {
  36136. cachedSetTimeout = defaultSetTimout;
  36137. }
  36138. } catch (e) {
  36139. cachedSetTimeout = defaultSetTimout;
  36140. }
  36141. try {
  36142. if (typeof clearTimeout === 'function') {
  36143. cachedClearTimeout = clearTimeout;
  36144. } else {
  36145. cachedClearTimeout = defaultClearTimeout;
  36146. }
  36147. } catch (e) {
  36148. cachedClearTimeout = defaultClearTimeout;
  36149. }
  36150. } ())
  36151. function runTimeout(fun) {
  36152. if (cachedSetTimeout === setTimeout) {
  36153. //normal enviroments in sane situations
  36154. return setTimeout(fun, 0);
  36155. }
  36156. // if setTimeout wasn't available but was latter defined
  36157. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  36158. cachedSetTimeout = setTimeout;
  36159. return setTimeout(fun, 0);
  36160. }
  36161. try {
  36162. // when when somebody has screwed with setTimeout but no I.E. maddness
  36163. return cachedSetTimeout(fun, 0);
  36164. } catch(e){
  36165. try {
  36166. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36167. return cachedSetTimeout.call(null, fun, 0);
  36168. } catch(e){
  36169. // 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
  36170. return cachedSetTimeout.call(this, fun, 0);
  36171. }
  36172. }
  36173. }
  36174. function runClearTimeout(marker) {
  36175. if (cachedClearTimeout === clearTimeout) {
  36176. //normal enviroments in sane situations
  36177. return clearTimeout(marker);
  36178. }
  36179. // if clearTimeout wasn't available but was latter defined
  36180. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  36181. cachedClearTimeout = clearTimeout;
  36182. return clearTimeout(marker);
  36183. }
  36184. try {
  36185. // when when somebody has screwed with setTimeout but no I.E. maddness
  36186. return cachedClearTimeout(marker);
  36187. } catch (e){
  36188. try {
  36189. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36190. return cachedClearTimeout.call(null, marker);
  36191. } catch (e){
  36192. // 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.
  36193. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  36194. return cachedClearTimeout.call(this, marker);
  36195. }
  36196. }
  36197. }
  36198. var queue = [];
  36199. var draining = false;
  36200. var currentQueue;
  36201. var queueIndex = -1;
  36202. function cleanUpNextTick() {
  36203. if (!draining || !currentQueue) {
  36204. return;
  36205. }
  36206. draining = false;
  36207. if (currentQueue.length) {
  36208. queue = currentQueue.concat(queue);
  36209. } else {
  36210. queueIndex = -1;
  36211. }
  36212. if (queue.length) {
  36213. drainQueue();
  36214. }
  36215. }
  36216. function drainQueue() {
  36217. if (draining) {
  36218. return;
  36219. }
  36220. var timeout = runTimeout(cleanUpNextTick);
  36221. draining = true;
  36222. var len = queue.length;
  36223. while(len) {
  36224. currentQueue = queue;
  36225. queue = [];
  36226. while (++queueIndex < len) {
  36227. if (currentQueue) {
  36228. currentQueue[queueIndex].run();
  36229. }
  36230. }
  36231. queueIndex = -1;
  36232. len = queue.length;
  36233. }
  36234. currentQueue = null;
  36235. draining = false;
  36236. runClearTimeout(timeout);
  36237. }
  36238. process.nextTick = function (fun) {
  36239. var args = new Array(arguments.length - 1);
  36240. if (arguments.length > 1) {
  36241. for (var i = 1; i < arguments.length; i++) {
  36242. args[i - 1] = arguments[i];
  36243. }
  36244. }
  36245. queue.push(new Item(fun, args));
  36246. if (queue.length === 1 && !draining) {
  36247. runTimeout(drainQueue);
  36248. }
  36249. };
  36250. // v8 likes predictible objects
  36251. function Item(fun, array) {
  36252. this.fun = fun;
  36253. this.array = array;
  36254. }
  36255. Item.prototype.run = function () {
  36256. this.fun.apply(null, this.array);
  36257. };
  36258. process.title = 'browser';
  36259. process.browser = true;
  36260. process.env = {};
  36261. process.argv = [];
  36262. process.version = ''; // empty string to avoid regexp issues
  36263. process.versions = {};
  36264. function noop() {}
  36265. process.on = noop;
  36266. process.addListener = noop;
  36267. process.once = noop;
  36268. process.off = noop;
  36269. process.removeListener = noop;
  36270. process.removeAllListeners = noop;
  36271. process.emit = noop;
  36272. process.prependListener = noop;
  36273. process.prependOnceListener = noop;
  36274. process.listeners = function (name) { return [] }
  36275. process.binding = function (name) {
  36276. throw new Error('process.binding is not supported');
  36277. };
  36278. process.cwd = function () { return '/' };
  36279. process.chdir = function (dir) {
  36280. throw new Error('process.chdir is not supported');
  36281. };
  36282. process.umask = function() { return 0; };
  36283. /***/ }),
  36284. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  36285. /*!***************************************************!*\
  36286. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  36287. \***************************************************/
  36288. /*! no static exports found */
  36289. /***/ (function(module, exports, __webpack_require__) {
  36290. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  36291. * Pusher JavaScript Library v5.0.3
  36292. * https://pusher.com/
  36293. *
  36294. * Copyright 2017, Pusher
  36295. * Released under the MIT licence.
  36296. */
  36297. (function webpackUniversalModuleDefinition(root, factory) {
  36298. if(true)
  36299. module.exports = factory();
  36300. else {}
  36301. })(window, function() {
  36302. return /******/ (function(modules) { // webpackBootstrap
  36303. /******/ // The module cache
  36304. /******/ var installedModules = {};
  36305. /******/
  36306. /******/ // The require function
  36307. /******/ function __webpack_require__(moduleId) {
  36308. /******/
  36309. /******/ // Check if module is in cache
  36310. /******/ if(installedModules[moduleId]) {
  36311. /******/ return installedModules[moduleId].exports;
  36312. /******/ }
  36313. /******/ // Create a new module (and put it into the cache)
  36314. /******/ var module = installedModules[moduleId] = {
  36315. /******/ i: moduleId,
  36316. /******/ l: false,
  36317. /******/ exports: {}
  36318. /******/ };
  36319. /******/
  36320. /******/ // Execute the module function
  36321. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  36322. /******/
  36323. /******/ // Flag the module as loaded
  36324. /******/ module.l = true;
  36325. /******/
  36326. /******/ // Return the exports of the module
  36327. /******/ return module.exports;
  36328. /******/ }
  36329. /******/
  36330. /******/
  36331. /******/ // expose the modules object (__webpack_modules__)
  36332. /******/ __webpack_require__.m = modules;
  36333. /******/
  36334. /******/ // expose the module cache
  36335. /******/ __webpack_require__.c = installedModules;
  36336. /******/
  36337. /******/ // define getter function for harmony exports
  36338. /******/ __webpack_require__.d = function(exports, name, getter) {
  36339. /******/ if(!__webpack_require__.o(exports, name)) {
  36340. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  36341. /******/ }
  36342. /******/ };
  36343. /******/
  36344. /******/ // define __esModule on exports
  36345. /******/ __webpack_require__.r = function(exports) {
  36346. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  36347. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  36348. /******/ }
  36349. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  36350. /******/ };
  36351. /******/
  36352. /******/ // create a fake namespace object
  36353. /******/ // mode & 1: value is a module id, require it
  36354. /******/ // mode & 2: merge all properties of value into the ns
  36355. /******/ // mode & 4: return value when already ns object
  36356. /******/ // mode & 8|1: behave like require
  36357. /******/ __webpack_require__.t = function(value, mode) {
  36358. /******/ if(mode & 1) value = __webpack_require__(value);
  36359. /******/ if(mode & 8) return value;
  36360. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  36361. /******/ var ns = Object.create(null);
  36362. /******/ __webpack_require__.r(ns);
  36363. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  36364. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  36365. /******/ return ns;
  36366. /******/ };
  36367. /******/
  36368. /******/ // getDefaultExport function for compatibility with non-harmony modules
  36369. /******/ __webpack_require__.n = function(module) {
  36370. /******/ var getter = module && module.__esModule ?
  36371. /******/ function getDefault() { return module['default']; } :
  36372. /******/ function getModuleExports() { return module; };
  36373. /******/ __webpack_require__.d(getter, 'a', getter);
  36374. /******/ return getter;
  36375. /******/ };
  36376. /******/
  36377. /******/ // Object.prototype.hasOwnProperty.call
  36378. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  36379. /******/
  36380. /******/ // __webpack_public_path__
  36381. /******/ __webpack_require__.p = "";
  36382. /******/
  36383. /******/
  36384. /******/ // Load entry module and return exports
  36385. /******/ return __webpack_require__(__webpack_require__.s = 2);
  36386. /******/ })
  36387. /************************************************************************/
  36388. /******/ ([
  36389. /* 0 */
  36390. /***/ (function(module, exports, __webpack_require__) {
  36391. (function(nacl) {
  36392. 'use strict';
  36393. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  36394. // Public domain.
  36395. //
  36396. // Implementation derived from TweetNaCl version 20140427.
  36397. // See for details: http://tweetnacl.cr.yp.to/
  36398. var gf = function(init) {
  36399. var i, r = new Float64Array(16);
  36400. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  36401. return r;
  36402. };
  36403. // Pluggable, initialized in high-level API below.
  36404. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  36405. var _0 = new Uint8Array(16);
  36406. var _9 = new Uint8Array(32); _9[0] = 9;
  36407. var gf0 = gf(),
  36408. gf1 = gf([1]),
  36409. _121665 = gf([0xdb41, 1]),
  36410. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  36411. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  36412. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  36413. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  36414. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  36415. function ts64(x, i, h, l) {
  36416. x[i] = (h >> 24) & 0xff;
  36417. x[i+1] = (h >> 16) & 0xff;
  36418. x[i+2] = (h >> 8) & 0xff;
  36419. x[i+3] = h & 0xff;
  36420. x[i+4] = (l >> 24) & 0xff;
  36421. x[i+5] = (l >> 16) & 0xff;
  36422. x[i+6] = (l >> 8) & 0xff;
  36423. x[i+7] = l & 0xff;
  36424. }
  36425. function vn(x, xi, y, yi, n) {
  36426. var i,d = 0;
  36427. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  36428. return (1 & ((d - 1) >>> 8)) - 1;
  36429. }
  36430. function crypto_verify_16(x, xi, y, yi) {
  36431. return vn(x,xi,y,yi,16);
  36432. }
  36433. function crypto_verify_32(x, xi, y, yi) {
  36434. return vn(x,xi,y,yi,32);
  36435. }
  36436. function core_salsa20(o, p, k, c) {
  36437. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36438. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36439. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36440. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36441. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36442. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36443. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36444. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36445. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36446. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36447. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36448. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36449. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36450. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36451. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36452. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36453. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36454. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36455. x15 = j15, u;
  36456. for (var i = 0; i < 20; i += 2) {
  36457. u = x0 + x12 | 0;
  36458. x4 ^= u<<7 | u>>>(32-7);
  36459. u = x4 + x0 | 0;
  36460. x8 ^= u<<9 | u>>>(32-9);
  36461. u = x8 + x4 | 0;
  36462. x12 ^= u<<13 | u>>>(32-13);
  36463. u = x12 + x8 | 0;
  36464. x0 ^= u<<18 | u>>>(32-18);
  36465. u = x5 + x1 | 0;
  36466. x9 ^= u<<7 | u>>>(32-7);
  36467. u = x9 + x5 | 0;
  36468. x13 ^= u<<9 | u>>>(32-9);
  36469. u = x13 + x9 | 0;
  36470. x1 ^= u<<13 | u>>>(32-13);
  36471. u = x1 + x13 | 0;
  36472. x5 ^= u<<18 | u>>>(32-18);
  36473. u = x10 + x6 | 0;
  36474. x14 ^= u<<7 | u>>>(32-7);
  36475. u = x14 + x10 | 0;
  36476. x2 ^= u<<9 | u>>>(32-9);
  36477. u = x2 + x14 | 0;
  36478. x6 ^= u<<13 | u>>>(32-13);
  36479. u = x6 + x2 | 0;
  36480. x10 ^= u<<18 | u>>>(32-18);
  36481. u = x15 + x11 | 0;
  36482. x3 ^= u<<7 | u>>>(32-7);
  36483. u = x3 + x15 | 0;
  36484. x7 ^= u<<9 | u>>>(32-9);
  36485. u = x7 + x3 | 0;
  36486. x11 ^= u<<13 | u>>>(32-13);
  36487. u = x11 + x7 | 0;
  36488. x15 ^= u<<18 | u>>>(32-18);
  36489. u = x0 + x3 | 0;
  36490. x1 ^= u<<7 | u>>>(32-7);
  36491. u = x1 + x0 | 0;
  36492. x2 ^= u<<9 | u>>>(32-9);
  36493. u = x2 + x1 | 0;
  36494. x3 ^= u<<13 | u>>>(32-13);
  36495. u = x3 + x2 | 0;
  36496. x0 ^= u<<18 | u>>>(32-18);
  36497. u = x5 + x4 | 0;
  36498. x6 ^= u<<7 | u>>>(32-7);
  36499. u = x6 + x5 | 0;
  36500. x7 ^= u<<9 | u>>>(32-9);
  36501. u = x7 + x6 | 0;
  36502. x4 ^= u<<13 | u>>>(32-13);
  36503. u = x4 + x7 | 0;
  36504. x5 ^= u<<18 | u>>>(32-18);
  36505. u = x10 + x9 | 0;
  36506. x11 ^= u<<7 | u>>>(32-7);
  36507. u = x11 + x10 | 0;
  36508. x8 ^= u<<9 | u>>>(32-9);
  36509. u = x8 + x11 | 0;
  36510. x9 ^= u<<13 | u>>>(32-13);
  36511. u = x9 + x8 | 0;
  36512. x10 ^= u<<18 | u>>>(32-18);
  36513. u = x15 + x14 | 0;
  36514. x12 ^= u<<7 | u>>>(32-7);
  36515. u = x12 + x15 | 0;
  36516. x13 ^= u<<9 | u>>>(32-9);
  36517. u = x13 + x12 | 0;
  36518. x14 ^= u<<13 | u>>>(32-13);
  36519. u = x14 + x13 | 0;
  36520. x15 ^= u<<18 | u>>>(32-18);
  36521. }
  36522. x0 = x0 + j0 | 0;
  36523. x1 = x1 + j1 | 0;
  36524. x2 = x2 + j2 | 0;
  36525. x3 = x3 + j3 | 0;
  36526. x4 = x4 + j4 | 0;
  36527. x5 = x5 + j5 | 0;
  36528. x6 = x6 + j6 | 0;
  36529. x7 = x7 + j7 | 0;
  36530. x8 = x8 + j8 | 0;
  36531. x9 = x9 + j9 | 0;
  36532. x10 = x10 + j10 | 0;
  36533. x11 = x11 + j11 | 0;
  36534. x12 = x12 + j12 | 0;
  36535. x13 = x13 + j13 | 0;
  36536. x14 = x14 + j14 | 0;
  36537. x15 = x15 + j15 | 0;
  36538. o[ 0] = x0 >>> 0 & 0xff;
  36539. o[ 1] = x0 >>> 8 & 0xff;
  36540. o[ 2] = x0 >>> 16 & 0xff;
  36541. o[ 3] = x0 >>> 24 & 0xff;
  36542. o[ 4] = x1 >>> 0 & 0xff;
  36543. o[ 5] = x1 >>> 8 & 0xff;
  36544. o[ 6] = x1 >>> 16 & 0xff;
  36545. o[ 7] = x1 >>> 24 & 0xff;
  36546. o[ 8] = x2 >>> 0 & 0xff;
  36547. o[ 9] = x2 >>> 8 & 0xff;
  36548. o[10] = x2 >>> 16 & 0xff;
  36549. o[11] = x2 >>> 24 & 0xff;
  36550. o[12] = x3 >>> 0 & 0xff;
  36551. o[13] = x3 >>> 8 & 0xff;
  36552. o[14] = x3 >>> 16 & 0xff;
  36553. o[15] = x3 >>> 24 & 0xff;
  36554. o[16] = x4 >>> 0 & 0xff;
  36555. o[17] = x4 >>> 8 & 0xff;
  36556. o[18] = x4 >>> 16 & 0xff;
  36557. o[19] = x4 >>> 24 & 0xff;
  36558. o[20] = x5 >>> 0 & 0xff;
  36559. o[21] = x5 >>> 8 & 0xff;
  36560. o[22] = x5 >>> 16 & 0xff;
  36561. o[23] = x5 >>> 24 & 0xff;
  36562. o[24] = x6 >>> 0 & 0xff;
  36563. o[25] = x6 >>> 8 & 0xff;
  36564. o[26] = x6 >>> 16 & 0xff;
  36565. o[27] = x6 >>> 24 & 0xff;
  36566. o[28] = x7 >>> 0 & 0xff;
  36567. o[29] = x7 >>> 8 & 0xff;
  36568. o[30] = x7 >>> 16 & 0xff;
  36569. o[31] = x7 >>> 24 & 0xff;
  36570. o[32] = x8 >>> 0 & 0xff;
  36571. o[33] = x8 >>> 8 & 0xff;
  36572. o[34] = x8 >>> 16 & 0xff;
  36573. o[35] = x8 >>> 24 & 0xff;
  36574. o[36] = x9 >>> 0 & 0xff;
  36575. o[37] = x9 >>> 8 & 0xff;
  36576. o[38] = x9 >>> 16 & 0xff;
  36577. o[39] = x9 >>> 24 & 0xff;
  36578. o[40] = x10 >>> 0 & 0xff;
  36579. o[41] = x10 >>> 8 & 0xff;
  36580. o[42] = x10 >>> 16 & 0xff;
  36581. o[43] = x10 >>> 24 & 0xff;
  36582. o[44] = x11 >>> 0 & 0xff;
  36583. o[45] = x11 >>> 8 & 0xff;
  36584. o[46] = x11 >>> 16 & 0xff;
  36585. o[47] = x11 >>> 24 & 0xff;
  36586. o[48] = x12 >>> 0 & 0xff;
  36587. o[49] = x12 >>> 8 & 0xff;
  36588. o[50] = x12 >>> 16 & 0xff;
  36589. o[51] = x12 >>> 24 & 0xff;
  36590. o[52] = x13 >>> 0 & 0xff;
  36591. o[53] = x13 >>> 8 & 0xff;
  36592. o[54] = x13 >>> 16 & 0xff;
  36593. o[55] = x13 >>> 24 & 0xff;
  36594. o[56] = x14 >>> 0 & 0xff;
  36595. o[57] = x14 >>> 8 & 0xff;
  36596. o[58] = x14 >>> 16 & 0xff;
  36597. o[59] = x14 >>> 24 & 0xff;
  36598. o[60] = x15 >>> 0 & 0xff;
  36599. o[61] = x15 >>> 8 & 0xff;
  36600. o[62] = x15 >>> 16 & 0xff;
  36601. o[63] = x15 >>> 24 & 0xff;
  36602. }
  36603. function core_hsalsa20(o,p,k,c) {
  36604. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36605. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36606. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36607. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36608. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36609. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36610. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36611. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36612. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36613. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36614. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36615. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36616. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36617. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36618. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36619. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36620. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36621. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36622. x15 = j15, u;
  36623. for (var i = 0; i < 20; i += 2) {
  36624. u = x0 + x12 | 0;
  36625. x4 ^= u<<7 | u>>>(32-7);
  36626. u = x4 + x0 | 0;
  36627. x8 ^= u<<9 | u>>>(32-9);
  36628. u = x8 + x4 | 0;
  36629. x12 ^= u<<13 | u>>>(32-13);
  36630. u = x12 + x8 | 0;
  36631. x0 ^= u<<18 | u>>>(32-18);
  36632. u = x5 + x1 | 0;
  36633. x9 ^= u<<7 | u>>>(32-7);
  36634. u = x9 + x5 | 0;
  36635. x13 ^= u<<9 | u>>>(32-9);
  36636. u = x13 + x9 | 0;
  36637. x1 ^= u<<13 | u>>>(32-13);
  36638. u = x1 + x13 | 0;
  36639. x5 ^= u<<18 | u>>>(32-18);
  36640. u = x10 + x6 | 0;
  36641. x14 ^= u<<7 | u>>>(32-7);
  36642. u = x14 + x10 | 0;
  36643. x2 ^= u<<9 | u>>>(32-9);
  36644. u = x2 + x14 | 0;
  36645. x6 ^= u<<13 | u>>>(32-13);
  36646. u = x6 + x2 | 0;
  36647. x10 ^= u<<18 | u>>>(32-18);
  36648. u = x15 + x11 | 0;
  36649. x3 ^= u<<7 | u>>>(32-7);
  36650. u = x3 + x15 | 0;
  36651. x7 ^= u<<9 | u>>>(32-9);
  36652. u = x7 + x3 | 0;
  36653. x11 ^= u<<13 | u>>>(32-13);
  36654. u = x11 + x7 | 0;
  36655. x15 ^= u<<18 | u>>>(32-18);
  36656. u = x0 + x3 | 0;
  36657. x1 ^= u<<7 | u>>>(32-7);
  36658. u = x1 + x0 | 0;
  36659. x2 ^= u<<9 | u>>>(32-9);
  36660. u = x2 + x1 | 0;
  36661. x3 ^= u<<13 | u>>>(32-13);
  36662. u = x3 + x2 | 0;
  36663. x0 ^= u<<18 | u>>>(32-18);
  36664. u = x5 + x4 | 0;
  36665. x6 ^= u<<7 | u>>>(32-7);
  36666. u = x6 + x5 | 0;
  36667. x7 ^= u<<9 | u>>>(32-9);
  36668. u = x7 + x6 | 0;
  36669. x4 ^= u<<13 | u>>>(32-13);
  36670. u = x4 + x7 | 0;
  36671. x5 ^= u<<18 | u>>>(32-18);
  36672. u = x10 + x9 | 0;
  36673. x11 ^= u<<7 | u>>>(32-7);
  36674. u = x11 + x10 | 0;
  36675. x8 ^= u<<9 | u>>>(32-9);
  36676. u = x8 + x11 | 0;
  36677. x9 ^= u<<13 | u>>>(32-13);
  36678. u = x9 + x8 | 0;
  36679. x10 ^= u<<18 | u>>>(32-18);
  36680. u = x15 + x14 | 0;
  36681. x12 ^= u<<7 | u>>>(32-7);
  36682. u = x12 + x15 | 0;
  36683. x13 ^= u<<9 | u>>>(32-9);
  36684. u = x13 + x12 | 0;
  36685. x14 ^= u<<13 | u>>>(32-13);
  36686. u = x14 + x13 | 0;
  36687. x15 ^= u<<18 | u>>>(32-18);
  36688. }
  36689. o[ 0] = x0 >>> 0 & 0xff;
  36690. o[ 1] = x0 >>> 8 & 0xff;
  36691. o[ 2] = x0 >>> 16 & 0xff;
  36692. o[ 3] = x0 >>> 24 & 0xff;
  36693. o[ 4] = x5 >>> 0 & 0xff;
  36694. o[ 5] = x5 >>> 8 & 0xff;
  36695. o[ 6] = x5 >>> 16 & 0xff;
  36696. o[ 7] = x5 >>> 24 & 0xff;
  36697. o[ 8] = x10 >>> 0 & 0xff;
  36698. o[ 9] = x10 >>> 8 & 0xff;
  36699. o[10] = x10 >>> 16 & 0xff;
  36700. o[11] = x10 >>> 24 & 0xff;
  36701. o[12] = x15 >>> 0 & 0xff;
  36702. o[13] = x15 >>> 8 & 0xff;
  36703. o[14] = x15 >>> 16 & 0xff;
  36704. o[15] = x15 >>> 24 & 0xff;
  36705. o[16] = x6 >>> 0 & 0xff;
  36706. o[17] = x6 >>> 8 & 0xff;
  36707. o[18] = x6 >>> 16 & 0xff;
  36708. o[19] = x6 >>> 24 & 0xff;
  36709. o[20] = x7 >>> 0 & 0xff;
  36710. o[21] = x7 >>> 8 & 0xff;
  36711. o[22] = x7 >>> 16 & 0xff;
  36712. o[23] = x7 >>> 24 & 0xff;
  36713. o[24] = x8 >>> 0 & 0xff;
  36714. o[25] = x8 >>> 8 & 0xff;
  36715. o[26] = x8 >>> 16 & 0xff;
  36716. o[27] = x8 >>> 24 & 0xff;
  36717. o[28] = x9 >>> 0 & 0xff;
  36718. o[29] = x9 >>> 8 & 0xff;
  36719. o[30] = x9 >>> 16 & 0xff;
  36720. o[31] = x9 >>> 24 & 0xff;
  36721. }
  36722. function crypto_core_salsa20(out,inp,k,c) {
  36723. core_salsa20(out,inp,k,c);
  36724. }
  36725. function crypto_core_hsalsa20(out,inp,k,c) {
  36726. core_hsalsa20(out,inp,k,c);
  36727. }
  36728. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  36729. // "expand 32-byte k"
  36730. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  36731. var z = new Uint8Array(16), x = new Uint8Array(64);
  36732. var u, i;
  36733. for (i = 0; i < 16; i++) z[i] = 0;
  36734. for (i = 0; i < 8; i++) z[i] = n[i];
  36735. while (b >= 64) {
  36736. crypto_core_salsa20(x,z,k,sigma);
  36737. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36738. u = 1;
  36739. for (i = 8; i < 16; i++) {
  36740. u = u + (z[i] & 0xff) | 0;
  36741. z[i] = u & 0xff;
  36742. u >>>= 8;
  36743. }
  36744. b -= 64;
  36745. cpos += 64;
  36746. mpos += 64;
  36747. }
  36748. if (b > 0) {
  36749. crypto_core_salsa20(x,z,k,sigma);
  36750. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36751. }
  36752. return 0;
  36753. }
  36754. function crypto_stream_salsa20(c,cpos,b,n,k) {
  36755. var z = new Uint8Array(16), x = new Uint8Array(64);
  36756. var u, i;
  36757. for (i = 0; i < 16; i++) z[i] = 0;
  36758. for (i = 0; i < 8; i++) z[i] = n[i];
  36759. while (b >= 64) {
  36760. crypto_core_salsa20(x,z,k,sigma);
  36761. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  36762. u = 1;
  36763. for (i = 8; i < 16; i++) {
  36764. u = u + (z[i] & 0xff) | 0;
  36765. z[i] = u & 0xff;
  36766. u >>>= 8;
  36767. }
  36768. b -= 64;
  36769. cpos += 64;
  36770. }
  36771. if (b > 0) {
  36772. crypto_core_salsa20(x,z,k,sigma);
  36773. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  36774. }
  36775. return 0;
  36776. }
  36777. function crypto_stream(c,cpos,d,n,k) {
  36778. var s = new Uint8Array(32);
  36779. crypto_core_hsalsa20(s,n,k,sigma);
  36780. var sn = new Uint8Array(8);
  36781. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36782. return crypto_stream_salsa20(c,cpos,d,sn,s);
  36783. }
  36784. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  36785. var s = new Uint8Array(32);
  36786. crypto_core_hsalsa20(s,n,k,sigma);
  36787. var sn = new Uint8Array(8);
  36788. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36789. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  36790. }
  36791. /*
  36792. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  36793. * https://github.com/floodyberry/poly1305-donna
  36794. */
  36795. var poly1305 = function(key) {
  36796. this.buffer = new Uint8Array(16);
  36797. this.r = new Uint16Array(10);
  36798. this.h = new Uint16Array(10);
  36799. this.pad = new Uint16Array(8);
  36800. this.leftover = 0;
  36801. this.fin = 0;
  36802. var t0, t1, t2, t3, t4, t5, t6, t7;
  36803. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  36804. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36805. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  36806. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36807. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  36808. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  36809. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36810. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  36811. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36812. this.r[9] = ((t7 >>> 5)) & 0x007f;
  36813. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  36814. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  36815. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  36816. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  36817. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  36818. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  36819. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  36820. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  36821. };
  36822. poly1305.prototype.blocks = function(m, mpos, bytes) {
  36823. var hibit = this.fin ? 0 : (1 << 11);
  36824. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  36825. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  36826. var h0 = this.h[0],
  36827. h1 = this.h[1],
  36828. h2 = this.h[2],
  36829. h3 = this.h[3],
  36830. h4 = this.h[4],
  36831. h5 = this.h[5],
  36832. h6 = this.h[6],
  36833. h7 = this.h[7],
  36834. h8 = this.h[8],
  36835. h9 = this.h[9];
  36836. var r0 = this.r[0],
  36837. r1 = this.r[1],
  36838. r2 = this.r[2],
  36839. r3 = this.r[3],
  36840. r4 = this.r[4],
  36841. r5 = this.r[5],
  36842. r6 = this.r[6],
  36843. r7 = this.r[7],
  36844. r8 = this.r[8],
  36845. r9 = this.r[9];
  36846. while (bytes >= 16) {
  36847. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  36848. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36849. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  36850. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36851. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  36852. h5 += ((t4 >>> 1)) & 0x1fff;
  36853. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36854. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  36855. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36856. h9 += ((t7 >>> 5)) | hibit;
  36857. c = 0;
  36858. d0 = c;
  36859. d0 += h0 * r0;
  36860. d0 += h1 * (5 * r9);
  36861. d0 += h2 * (5 * r8);
  36862. d0 += h3 * (5 * r7);
  36863. d0 += h4 * (5 * r6);
  36864. c = (d0 >>> 13); d0 &= 0x1fff;
  36865. d0 += h5 * (5 * r5);
  36866. d0 += h6 * (5 * r4);
  36867. d0 += h7 * (5 * r3);
  36868. d0 += h8 * (5 * r2);
  36869. d0 += h9 * (5 * r1);
  36870. c += (d0 >>> 13); d0 &= 0x1fff;
  36871. d1 = c;
  36872. d1 += h0 * r1;
  36873. d1 += h1 * r0;
  36874. d1 += h2 * (5 * r9);
  36875. d1 += h3 * (5 * r8);
  36876. d1 += h4 * (5 * r7);
  36877. c = (d1 >>> 13); d1 &= 0x1fff;
  36878. d1 += h5 * (5 * r6);
  36879. d1 += h6 * (5 * r5);
  36880. d1 += h7 * (5 * r4);
  36881. d1 += h8 * (5 * r3);
  36882. d1 += h9 * (5 * r2);
  36883. c += (d1 >>> 13); d1 &= 0x1fff;
  36884. d2 = c;
  36885. d2 += h0 * r2;
  36886. d2 += h1 * r1;
  36887. d2 += h2 * r0;
  36888. d2 += h3 * (5 * r9);
  36889. d2 += h4 * (5 * r8);
  36890. c = (d2 >>> 13); d2 &= 0x1fff;
  36891. d2 += h5 * (5 * r7);
  36892. d2 += h6 * (5 * r6);
  36893. d2 += h7 * (5 * r5);
  36894. d2 += h8 * (5 * r4);
  36895. d2 += h9 * (5 * r3);
  36896. c += (d2 >>> 13); d2 &= 0x1fff;
  36897. d3 = c;
  36898. d3 += h0 * r3;
  36899. d3 += h1 * r2;
  36900. d3 += h2 * r1;
  36901. d3 += h3 * r0;
  36902. d3 += h4 * (5 * r9);
  36903. c = (d3 >>> 13); d3 &= 0x1fff;
  36904. d3 += h5 * (5 * r8);
  36905. d3 += h6 * (5 * r7);
  36906. d3 += h7 * (5 * r6);
  36907. d3 += h8 * (5 * r5);
  36908. d3 += h9 * (5 * r4);
  36909. c += (d3 >>> 13); d3 &= 0x1fff;
  36910. d4 = c;
  36911. d4 += h0 * r4;
  36912. d4 += h1 * r3;
  36913. d4 += h2 * r2;
  36914. d4 += h3 * r1;
  36915. d4 += h4 * r0;
  36916. c = (d4 >>> 13); d4 &= 0x1fff;
  36917. d4 += h5 * (5 * r9);
  36918. d4 += h6 * (5 * r8);
  36919. d4 += h7 * (5 * r7);
  36920. d4 += h8 * (5 * r6);
  36921. d4 += h9 * (5 * r5);
  36922. c += (d4 >>> 13); d4 &= 0x1fff;
  36923. d5 = c;
  36924. d5 += h0 * r5;
  36925. d5 += h1 * r4;
  36926. d5 += h2 * r3;
  36927. d5 += h3 * r2;
  36928. d5 += h4 * r1;
  36929. c = (d5 >>> 13); d5 &= 0x1fff;
  36930. d5 += h5 * r0;
  36931. d5 += h6 * (5 * r9);
  36932. d5 += h7 * (5 * r8);
  36933. d5 += h8 * (5 * r7);
  36934. d5 += h9 * (5 * r6);
  36935. c += (d5 >>> 13); d5 &= 0x1fff;
  36936. d6 = c;
  36937. d6 += h0 * r6;
  36938. d6 += h1 * r5;
  36939. d6 += h2 * r4;
  36940. d6 += h3 * r3;
  36941. d6 += h4 * r2;
  36942. c = (d6 >>> 13); d6 &= 0x1fff;
  36943. d6 += h5 * r1;
  36944. d6 += h6 * r0;
  36945. d6 += h7 * (5 * r9);
  36946. d6 += h8 * (5 * r8);
  36947. d6 += h9 * (5 * r7);
  36948. c += (d6 >>> 13); d6 &= 0x1fff;
  36949. d7 = c;
  36950. d7 += h0 * r7;
  36951. d7 += h1 * r6;
  36952. d7 += h2 * r5;
  36953. d7 += h3 * r4;
  36954. d7 += h4 * r3;
  36955. c = (d7 >>> 13); d7 &= 0x1fff;
  36956. d7 += h5 * r2;
  36957. d7 += h6 * r1;
  36958. d7 += h7 * r0;
  36959. d7 += h8 * (5 * r9);
  36960. d7 += h9 * (5 * r8);
  36961. c += (d7 >>> 13); d7 &= 0x1fff;
  36962. d8 = c;
  36963. d8 += h0 * r8;
  36964. d8 += h1 * r7;
  36965. d8 += h2 * r6;
  36966. d8 += h3 * r5;
  36967. d8 += h4 * r4;
  36968. c = (d8 >>> 13); d8 &= 0x1fff;
  36969. d8 += h5 * r3;
  36970. d8 += h6 * r2;
  36971. d8 += h7 * r1;
  36972. d8 += h8 * r0;
  36973. d8 += h9 * (5 * r9);
  36974. c += (d8 >>> 13); d8 &= 0x1fff;
  36975. d9 = c;
  36976. d9 += h0 * r9;
  36977. d9 += h1 * r8;
  36978. d9 += h2 * r7;
  36979. d9 += h3 * r6;
  36980. d9 += h4 * r5;
  36981. c = (d9 >>> 13); d9 &= 0x1fff;
  36982. d9 += h5 * r4;
  36983. d9 += h6 * r3;
  36984. d9 += h7 * r2;
  36985. d9 += h8 * r1;
  36986. d9 += h9 * r0;
  36987. c += (d9 >>> 13); d9 &= 0x1fff;
  36988. c = (((c << 2) + c)) | 0;
  36989. c = (c + d0) | 0;
  36990. d0 = c & 0x1fff;
  36991. c = (c >>> 13);
  36992. d1 += c;
  36993. h0 = d0;
  36994. h1 = d1;
  36995. h2 = d2;
  36996. h3 = d3;
  36997. h4 = d4;
  36998. h5 = d5;
  36999. h6 = d6;
  37000. h7 = d7;
  37001. h8 = d8;
  37002. h9 = d9;
  37003. mpos += 16;
  37004. bytes -= 16;
  37005. }
  37006. this.h[0] = h0;
  37007. this.h[1] = h1;
  37008. this.h[2] = h2;
  37009. this.h[3] = h3;
  37010. this.h[4] = h4;
  37011. this.h[5] = h5;
  37012. this.h[6] = h6;
  37013. this.h[7] = h7;
  37014. this.h[8] = h8;
  37015. this.h[9] = h9;
  37016. };
  37017. poly1305.prototype.finish = function(mac, macpos) {
  37018. var g = new Uint16Array(10);
  37019. var c, mask, f, i;
  37020. if (this.leftover) {
  37021. i = this.leftover;
  37022. this.buffer[i++] = 1;
  37023. for (; i < 16; i++) this.buffer[i] = 0;
  37024. this.fin = 1;
  37025. this.blocks(this.buffer, 0, 16);
  37026. }
  37027. c = this.h[1] >>> 13;
  37028. this.h[1] &= 0x1fff;
  37029. for (i = 2; i < 10; i++) {
  37030. this.h[i] += c;
  37031. c = this.h[i] >>> 13;
  37032. this.h[i] &= 0x1fff;
  37033. }
  37034. this.h[0] += (c * 5);
  37035. c = this.h[0] >>> 13;
  37036. this.h[0] &= 0x1fff;
  37037. this.h[1] += c;
  37038. c = this.h[1] >>> 13;
  37039. this.h[1] &= 0x1fff;
  37040. this.h[2] += c;
  37041. g[0] = this.h[0] + 5;
  37042. c = g[0] >>> 13;
  37043. g[0] &= 0x1fff;
  37044. for (i = 1; i < 10; i++) {
  37045. g[i] = this.h[i] + c;
  37046. c = g[i] >>> 13;
  37047. g[i] &= 0x1fff;
  37048. }
  37049. g[9] -= (1 << 13);
  37050. mask = (c ^ 1) - 1;
  37051. for (i = 0; i < 10; i++) g[i] &= mask;
  37052. mask = ~mask;
  37053. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  37054. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  37055. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  37056. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  37057. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  37058. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  37059. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  37060. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  37061. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  37062. f = this.h[0] + this.pad[0];
  37063. this.h[0] = f & 0xffff;
  37064. for (i = 1; i < 8; i++) {
  37065. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  37066. this.h[i] = f & 0xffff;
  37067. }
  37068. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  37069. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  37070. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  37071. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  37072. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  37073. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  37074. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  37075. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  37076. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  37077. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  37078. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  37079. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  37080. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  37081. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  37082. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  37083. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  37084. };
  37085. poly1305.prototype.update = function(m, mpos, bytes) {
  37086. var i, want;
  37087. if (this.leftover) {
  37088. want = (16 - this.leftover);
  37089. if (want > bytes)
  37090. want = bytes;
  37091. for (i = 0; i < want; i++)
  37092. this.buffer[this.leftover + i] = m[mpos+i];
  37093. bytes -= want;
  37094. mpos += want;
  37095. this.leftover += want;
  37096. if (this.leftover < 16)
  37097. return;
  37098. this.blocks(this.buffer, 0, 16);
  37099. this.leftover = 0;
  37100. }
  37101. if (bytes >= 16) {
  37102. want = bytes - (bytes % 16);
  37103. this.blocks(m, mpos, want);
  37104. mpos += want;
  37105. bytes -= want;
  37106. }
  37107. if (bytes) {
  37108. for (i = 0; i < bytes; i++)
  37109. this.buffer[this.leftover + i] = m[mpos+i];
  37110. this.leftover += bytes;
  37111. }
  37112. };
  37113. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  37114. var s = new poly1305(k);
  37115. s.update(m, mpos, n);
  37116. s.finish(out, outpos);
  37117. return 0;
  37118. }
  37119. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  37120. var x = new Uint8Array(16);
  37121. crypto_onetimeauth(x,0,m,mpos,n,k);
  37122. return crypto_verify_16(h,hpos,x,0);
  37123. }
  37124. function crypto_secretbox(c,m,d,n,k) {
  37125. var i;
  37126. if (d < 32) return -1;
  37127. crypto_stream_xor(c,0,m,0,d,n,k);
  37128. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  37129. for (i = 0; i < 16; i++) c[i] = 0;
  37130. return 0;
  37131. }
  37132. function crypto_secretbox_open(m,c,d,n,k) {
  37133. var i;
  37134. var x = new Uint8Array(32);
  37135. if (d < 32) return -1;
  37136. crypto_stream(x,0,32,n,k);
  37137. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  37138. crypto_stream_xor(m,0,c,0,d,n,k);
  37139. for (i = 0; i < 32; i++) m[i] = 0;
  37140. return 0;
  37141. }
  37142. function set25519(r, a) {
  37143. var i;
  37144. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  37145. }
  37146. function car25519(o) {
  37147. var i, v, c = 1;
  37148. for (i = 0; i < 16; i++) {
  37149. v = o[i] + c + 65535;
  37150. c = Math.floor(v / 65536);
  37151. o[i] = v - c * 65536;
  37152. }
  37153. o[0] += c-1 + 37 * (c-1);
  37154. }
  37155. function sel25519(p, q, b) {
  37156. var t, c = ~(b-1);
  37157. for (var i = 0; i < 16; i++) {
  37158. t = c & (p[i] ^ q[i]);
  37159. p[i] ^= t;
  37160. q[i] ^= t;
  37161. }
  37162. }
  37163. function pack25519(o, n) {
  37164. var i, j, b;
  37165. var m = gf(), t = gf();
  37166. for (i = 0; i < 16; i++) t[i] = n[i];
  37167. car25519(t);
  37168. car25519(t);
  37169. car25519(t);
  37170. for (j = 0; j < 2; j++) {
  37171. m[0] = t[0] - 0xffed;
  37172. for (i = 1; i < 15; i++) {
  37173. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  37174. m[i-1] &= 0xffff;
  37175. }
  37176. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  37177. b = (m[15]>>16) & 1;
  37178. m[14] &= 0xffff;
  37179. sel25519(t, m, 1-b);
  37180. }
  37181. for (i = 0; i < 16; i++) {
  37182. o[2*i] = t[i] & 0xff;
  37183. o[2*i+1] = t[i]>>8;
  37184. }
  37185. }
  37186. function neq25519(a, b) {
  37187. var c = new Uint8Array(32), d = new Uint8Array(32);
  37188. pack25519(c, a);
  37189. pack25519(d, b);
  37190. return crypto_verify_32(c, 0, d, 0);
  37191. }
  37192. function par25519(a) {
  37193. var d = new Uint8Array(32);
  37194. pack25519(d, a);
  37195. return d[0] & 1;
  37196. }
  37197. function unpack25519(o, n) {
  37198. var i;
  37199. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  37200. o[15] &= 0x7fff;
  37201. }
  37202. function A(o, a, b) {
  37203. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  37204. }
  37205. function Z(o, a, b) {
  37206. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  37207. }
  37208. function M(o, a, b) {
  37209. var v, c,
  37210. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  37211. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  37212. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  37213. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  37214. b0 = b[0],
  37215. b1 = b[1],
  37216. b2 = b[2],
  37217. b3 = b[3],
  37218. b4 = b[4],
  37219. b5 = b[5],
  37220. b6 = b[6],
  37221. b7 = b[7],
  37222. b8 = b[8],
  37223. b9 = b[9],
  37224. b10 = b[10],
  37225. b11 = b[11],
  37226. b12 = b[12],
  37227. b13 = b[13],
  37228. b14 = b[14],
  37229. b15 = b[15];
  37230. v = a[0];
  37231. t0 += v * b0;
  37232. t1 += v * b1;
  37233. t2 += v * b2;
  37234. t3 += v * b3;
  37235. t4 += v * b4;
  37236. t5 += v * b5;
  37237. t6 += v * b6;
  37238. t7 += v * b7;
  37239. t8 += v * b8;
  37240. t9 += v * b9;
  37241. t10 += v * b10;
  37242. t11 += v * b11;
  37243. t12 += v * b12;
  37244. t13 += v * b13;
  37245. t14 += v * b14;
  37246. t15 += v * b15;
  37247. v = a[1];
  37248. t1 += v * b0;
  37249. t2 += v * b1;
  37250. t3 += v * b2;
  37251. t4 += v * b3;
  37252. t5 += v * b4;
  37253. t6 += v * b5;
  37254. t7 += v * b6;
  37255. t8 += v * b7;
  37256. t9 += v * b8;
  37257. t10 += v * b9;
  37258. t11 += v * b10;
  37259. t12 += v * b11;
  37260. t13 += v * b12;
  37261. t14 += v * b13;
  37262. t15 += v * b14;
  37263. t16 += v * b15;
  37264. v = a[2];
  37265. t2 += v * b0;
  37266. t3 += v * b1;
  37267. t4 += v * b2;
  37268. t5 += v * b3;
  37269. t6 += v * b4;
  37270. t7 += v * b5;
  37271. t8 += v * b6;
  37272. t9 += v * b7;
  37273. t10 += v * b8;
  37274. t11 += v * b9;
  37275. t12 += v * b10;
  37276. t13 += v * b11;
  37277. t14 += v * b12;
  37278. t15 += v * b13;
  37279. t16 += v * b14;
  37280. t17 += v * b15;
  37281. v = a[3];
  37282. t3 += v * b0;
  37283. t4 += v * b1;
  37284. t5 += v * b2;
  37285. t6 += v * b3;
  37286. t7 += v * b4;
  37287. t8 += v * b5;
  37288. t9 += v * b6;
  37289. t10 += v * b7;
  37290. t11 += v * b8;
  37291. t12 += v * b9;
  37292. t13 += v * b10;
  37293. t14 += v * b11;
  37294. t15 += v * b12;
  37295. t16 += v * b13;
  37296. t17 += v * b14;
  37297. t18 += v * b15;
  37298. v = a[4];
  37299. t4 += v * b0;
  37300. t5 += v * b1;
  37301. t6 += v * b2;
  37302. t7 += v * b3;
  37303. t8 += v * b4;
  37304. t9 += v * b5;
  37305. t10 += v * b6;
  37306. t11 += v * b7;
  37307. t12 += v * b8;
  37308. t13 += v * b9;
  37309. t14 += v * b10;
  37310. t15 += v * b11;
  37311. t16 += v * b12;
  37312. t17 += v * b13;
  37313. t18 += v * b14;
  37314. t19 += v * b15;
  37315. v = a[5];
  37316. t5 += v * b0;
  37317. t6 += v * b1;
  37318. t7 += v * b2;
  37319. t8 += v * b3;
  37320. t9 += v * b4;
  37321. t10 += v * b5;
  37322. t11 += v * b6;
  37323. t12 += v * b7;
  37324. t13 += v * b8;
  37325. t14 += v * b9;
  37326. t15 += v * b10;
  37327. t16 += v * b11;
  37328. t17 += v * b12;
  37329. t18 += v * b13;
  37330. t19 += v * b14;
  37331. t20 += v * b15;
  37332. v = a[6];
  37333. t6 += v * b0;
  37334. t7 += v * b1;
  37335. t8 += v * b2;
  37336. t9 += v * b3;
  37337. t10 += v * b4;
  37338. t11 += v * b5;
  37339. t12 += v * b6;
  37340. t13 += v * b7;
  37341. t14 += v * b8;
  37342. t15 += v * b9;
  37343. t16 += v * b10;
  37344. t17 += v * b11;
  37345. t18 += v * b12;
  37346. t19 += v * b13;
  37347. t20 += v * b14;
  37348. t21 += v * b15;
  37349. v = a[7];
  37350. t7 += v * b0;
  37351. t8 += v * b1;
  37352. t9 += v * b2;
  37353. t10 += v * b3;
  37354. t11 += v * b4;
  37355. t12 += v * b5;
  37356. t13 += v * b6;
  37357. t14 += v * b7;
  37358. t15 += v * b8;
  37359. t16 += v * b9;
  37360. t17 += v * b10;
  37361. t18 += v * b11;
  37362. t19 += v * b12;
  37363. t20 += v * b13;
  37364. t21 += v * b14;
  37365. t22 += v * b15;
  37366. v = a[8];
  37367. t8 += v * b0;
  37368. t9 += v * b1;
  37369. t10 += v * b2;
  37370. t11 += v * b3;
  37371. t12 += v * b4;
  37372. t13 += v * b5;
  37373. t14 += v * b6;
  37374. t15 += v * b7;
  37375. t16 += v * b8;
  37376. t17 += v * b9;
  37377. t18 += v * b10;
  37378. t19 += v * b11;
  37379. t20 += v * b12;
  37380. t21 += v * b13;
  37381. t22 += v * b14;
  37382. t23 += v * b15;
  37383. v = a[9];
  37384. t9 += v * b0;
  37385. t10 += v * b1;
  37386. t11 += v * b2;
  37387. t12 += v * b3;
  37388. t13 += v * b4;
  37389. t14 += v * b5;
  37390. t15 += v * b6;
  37391. t16 += v * b7;
  37392. t17 += v * b8;
  37393. t18 += v * b9;
  37394. t19 += v * b10;
  37395. t20 += v * b11;
  37396. t21 += v * b12;
  37397. t22 += v * b13;
  37398. t23 += v * b14;
  37399. t24 += v * b15;
  37400. v = a[10];
  37401. t10 += v * b0;
  37402. t11 += v * b1;
  37403. t12 += v * b2;
  37404. t13 += v * b3;
  37405. t14 += v * b4;
  37406. t15 += v * b5;
  37407. t16 += v * b6;
  37408. t17 += v * b7;
  37409. t18 += v * b8;
  37410. t19 += v * b9;
  37411. t20 += v * b10;
  37412. t21 += v * b11;
  37413. t22 += v * b12;
  37414. t23 += v * b13;
  37415. t24 += v * b14;
  37416. t25 += v * b15;
  37417. v = a[11];
  37418. t11 += v * b0;
  37419. t12 += v * b1;
  37420. t13 += v * b2;
  37421. t14 += v * b3;
  37422. t15 += v * b4;
  37423. t16 += v * b5;
  37424. t17 += v * b6;
  37425. t18 += v * b7;
  37426. t19 += v * b8;
  37427. t20 += v * b9;
  37428. t21 += v * b10;
  37429. t22 += v * b11;
  37430. t23 += v * b12;
  37431. t24 += v * b13;
  37432. t25 += v * b14;
  37433. t26 += v * b15;
  37434. v = a[12];
  37435. t12 += v * b0;
  37436. t13 += v * b1;
  37437. t14 += v * b2;
  37438. t15 += v * b3;
  37439. t16 += v * b4;
  37440. t17 += v * b5;
  37441. t18 += v * b6;
  37442. t19 += v * b7;
  37443. t20 += v * b8;
  37444. t21 += v * b9;
  37445. t22 += v * b10;
  37446. t23 += v * b11;
  37447. t24 += v * b12;
  37448. t25 += v * b13;
  37449. t26 += v * b14;
  37450. t27 += v * b15;
  37451. v = a[13];
  37452. t13 += v * b0;
  37453. t14 += v * b1;
  37454. t15 += v * b2;
  37455. t16 += v * b3;
  37456. t17 += v * b4;
  37457. t18 += v * b5;
  37458. t19 += v * b6;
  37459. t20 += v * b7;
  37460. t21 += v * b8;
  37461. t22 += v * b9;
  37462. t23 += v * b10;
  37463. t24 += v * b11;
  37464. t25 += v * b12;
  37465. t26 += v * b13;
  37466. t27 += v * b14;
  37467. t28 += v * b15;
  37468. v = a[14];
  37469. t14 += v * b0;
  37470. t15 += v * b1;
  37471. t16 += v * b2;
  37472. t17 += v * b3;
  37473. t18 += v * b4;
  37474. t19 += v * b5;
  37475. t20 += v * b6;
  37476. t21 += v * b7;
  37477. t22 += v * b8;
  37478. t23 += v * b9;
  37479. t24 += v * b10;
  37480. t25 += v * b11;
  37481. t26 += v * b12;
  37482. t27 += v * b13;
  37483. t28 += v * b14;
  37484. t29 += v * b15;
  37485. v = a[15];
  37486. t15 += v * b0;
  37487. t16 += v * b1;
  37488. t17 += v * b2;
  37489. t18 += v * b3;
  37490. t19 += v * b4;
  37491. t20 += v * b5;
  37492. t21 += v * b6;
  37493. t22 += v * b7;
  37494. t23 += v * b8;
  37495. t24 += v * b9;
  37496. t25 += v * b10;
  37497. t26 += v * b11;
  37498. t27 += v * b12;
  37499. t28 += v * b13;
  37500. t29 += v * b14;
  37501. t30 += v * b15;
  37502. t0 += 38 * t16;
  37503. t1 += 38 * t17;
  37504. t2 += 38 * t18;
  37505. t3 += 38 * t19;
  37506. t4 += 38 * t20;
  37507. t5 += 38 * t21;
  37508. t6 += 38 * t22;
  37509. t7 += 38 * t23;
  37510. t8 += 38 * t24;
  37511. t9 += 38 * t25;
  37512. t10 += 38 * t26;
  37513. t11 += 38 * t27;
  37514. t12 += 38 * t28;
  37515. t13 += 38 * t29;
  37516. t14 += 38 * t30;
  37517. // t15 left as is
  37518. // first car
  37519. c = 1;
  37520. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37521. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37522. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37523. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37524. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37525. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37526. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37527. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37528. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37529. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37530. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37531. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37532. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37533. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37534. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37535. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37536. t0 += c-1 + 37 * (c-1);
  37537. // second car
  37538. c = 1;
  37539. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37540. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37541. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37542. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37543. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37544. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37545. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37546. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37547. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37548. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37549. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37550. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37551. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37552. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37553. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37554. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37555. t0 += c-1 + 37 * (c-1);
  37556. o[ 0] = t0;
  37557. o[ 1] = t1;
  37558. o[ 2] = t2;
  37559. o[ 3] = t3;
  37560. o[ 4] = t4;
  37561. o[ 5] = t5;
  37562. o[ 6] = t6;
  37563. o[ 7] = t7;
  37564. o[ 8] = t8;
  37565. o[ 9] = t9;
  37566. o[10] = t10;
  37567. o[11] = t11;
  37568. o[12] = t12;
  37569. o[13] = t13;
  37570. o[14] = t14;
  37571. o[15] = t15;
  37572. }
  37573. function S(o, a) {
  37574. M(o, a, a);
  37575. }
  37576. function inv25519(o, i) {
  37577. var c = gf();
  37578. var a;
  37579. for (a = 0; a < 16; a++) c[a] = i[a];
  37580. for (a = 253; a >= 0; a--) {
  37581. S(c, c);
  37582. if(a !== 2 && a !== 4) M(c, c, i);
  37583. }
  37584. for (a = 0; a < 16; a++) o[a] = c[a];
  37585. }
  37586. function pow2523(o, i) {
  37587. var c = gf();
  37588. var a;
  37589. for (a = 0; a < 16; a++) c[a] = i[a];
  37590. for (a = 250; a >= 0; a--) {
  37591. S(c, c);
  37592. if(a !== 1) M(c, c, i);
  37593. }
  37594. for (a = 0; a < 16; a++) o[a] = c[a];
  37595. }
  37596. function crypto_scalarmult(q, n, p) {
  37597. var z = new Uint8Array(32);
  37598. var x = new Float64Array(80), r, i;
  37599. var a = gf(), b = gf(), c = gf(),
  37600. d = gf(), e = gf(), f = gf();
  37601. for (i = 0; i < 31; i++) z[i] = n[i];
  37602. z[31]=(n[31]&127)|64;
  37603. z[0]&=248;
  37604. unpack25519(x,p);
  37605. for (i = 0; i < 16; i++) {
  37606. b[i]=x[i];
  37607. d[i]=a[i]=c[i]=0;
  37608. }
  37609. a[0]=d[0]=1;
  37610. for (i=254; i>=0; --i) {
  37611. r=(z[i>>>3]>>>(i&7))&1;
  37612. sel25519(a,b,r);
  37613. sel25519(c,d,r);
  37614. A(e,a,c);
  37615. Z(a,a,c);
  37616. A(c,b,d);
  37617. Z(b,b,d);
  37618. S(d,e);
  37619. S(f,a);
  37620. M(a,c,a);
  37621. M(c,b,e);
  37622. A(e,a,c);
  37623. Z(a,a,c);
  37624. S(b,a);
  37625. Z(c,d,f);
  37626. M(a,c,_121665);
  37627. A(a,a,d);
  37628. M(c,c,a);
  37629. M(a,d,f);
  37630. M(d,b,x);
  37631. S(b,e);
  37632. sel25519(a,b,r);
  37633. sel25519(c,d,r);
  37634. }
  37635. for (i = 0; i < 16; i++) {
  37636. x[i+16]=a[i];
  37637. x[i+32]=c[i];
  37638. x[i+48]=b[i];
  37639. x[i+64]=d[i];
  37640. }
  37641. var x32 = x.subarray(32);
  37642. var x16 = x.subarray(16);
  37643. inv25519(x32,x32);
  37644. M(x16,x16,x32);
  37645. pack25519(q,x16);
  37646. return 0;
  37647. }
  37648. function crypto_scalarmult_base(q, n) {
  37649. return crypto_scalarmult(q, n, _9);
  37650. }
  37651. function crypto_box_keypair(y, x) {
  37652. randombytes(x, 32);
  37653. return crypto_scalarmult_base(y, x);
  37654. }
  37655. function crypto_box_beforenm(k, y, x) {
  37656. var s = new Uint8Array(32);
  37657. crypto_scalarmult(s, x, y);
  37658. return crypto_core_hsalsa20(k, _0, s, sigma);
  37659. }
  37660. var crypto_box_afternm = crypto_secretbox;
  37661. var crypto_box_open_afternm = crypto_secretbox_open;
  37662. function crypto_box(c, m, d, n, y, x) {
  37663. var k = new Uint8Array(32);
  37664. crypto_box_beforenm(k, y, x);
  37665. return crypto_box_afternm(c, m, d, n, k);
  37666. }
  37667. function crypto_box_open(m, c, d, n, y, x) {
  37668. var k = new Uint8Array(32);
  37669. crypto_box_beforenm(k, y, x);
  37670. return crypto_box_open_afternm(m, c, d, n, k);
  37671. }
  37672. var K = [
  37673. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  37674. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  37675. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  37676. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  37677. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  37678. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  37679. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  37680. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  37681. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  37682. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  37683. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  37684. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  37685. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  37686. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  37687. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  37688. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  37689. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  37690. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  37691. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  37692. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  37693. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  37694. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  37695. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  37696. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  37697. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  37698. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  37699. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  37700. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  37701. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  37702. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  37703. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  37704. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  37705. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  37706. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  37707. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  37708. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  37709. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  37710. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  37711. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  37712. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  37713. ];
  37714. function crypto_hashblocks_hl(hh, hl, m, n) {
  37715. var wh = new Int32Array(16), wl = new Int32Array(16),
  37716. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  37717. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  37718. th, tl, i, j, h, l, a, b, c, d;
  37719. var ah0 = hh[0],
  37720. ah1 = hh[1],
  37721. ah2 = hh[2],
  37722. ah3 = hh[3],
  37723. ah4 = hh[4],
  37724. ah5 = hh[5],
  37725. ah6 = hh[6],
  37726. ah7 = hh[7],
  37727. al0 = hl[0],
  37728. al1 = hl[1],
  37729. al2 = hl[2],
  37730. al3 = hl[3],
  37731. al4 = hl[4],
  37732. al5 = hl[5],
  37733. al6 = hl[6],
  37734. al7 = hl[7];
  37735. var pos = 0;
  37736. while (n >= 128) {
  37737. for (i = 0; i < 16; i++) {
  37738. j = 8 * i + pos;
  37739. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  37740. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  37741. }
  37742. for (i = 0; i < 80; i++) {
  37743. bh0 = ah0;
  37744. bh1 = ah1;
  37745. bh2 = ah2;
  37746. bh3 = ah3;
  37747. bh4 = ah4;
  37748. bh5 = ah5;
  37749. bh6 = ah6;
  37750. bh7 = ah7;
  37751. bl0 = al0;
  37752. bl1 = al1;
  37753. bl2 = al2;
  37754. bl3 = al3;
  37755. bl4 = al4;
  37756. bl5 = al5;
  37757. bl6 = al6;
  37758. bl7 = al7;
  37759. // add
  37760. h = ah7;
  37761. l = al7;
  37762. a = l & 0xffff; b = l >>> 16;
  37763. c = h & 0xffff; d = h >>> 16;
  37764. // Sigma1
  37765. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  37766. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  37767. a += l & 0xffff; b += l >>> 16;
  37768. c += h & 0xffff; d += h >>> 16;
  37769. // Ch
  37770. h = (ah4 & ah5) ^ (~ah4 & ah6);
  37771. l = (al4 & al5) ^ (~al4 & al6);
  37772. a += l & 0xffff; b += l >>> 16;
  37773. c += h & 0xffff; d += h >>> 16;
  37774. // K
  37775. h = K[i*2];
  37776. l = K[i*2+1];
  37777. a += l & 0xffff; b += l >>> 16;
  37778. c += h & 0xffff; d += h >>> 16;
  37779. // w
  37780. h = wh[i%16];
  37781. l = wl[i%16];
  37782. a += l & 0xffff; b += l >>> 16;
  37783. c += h & 0xffff; d += h >>> 16;
  37784. b += a >>> 16;
  37785. c += b >>> 16;
  37786. d += c >>> 16;
  37787. th = c & 0xffff | d << 16;
  37788. tl = a & 0xffff | b << 16;
  37789. // add
  37790. h = th;
  37791. l = tl;
  37792. a = l & 0xffff; b = l >>> 16;
  37793. c = h & 0xffff; d = h >>> 16;
  37794. // Sigma0
  37795. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  37796. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  37797. a += l & 0xffff; b += l >>> 16;
  37798. c += h & 0xffff; d += h >>> 16;
  37799. // Maj
  37800. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  37801. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  37802. a += l & 0xffff; b += l >>> 16;
  37803. c += h & 0xffff; d += h >>> 16;
  37804. b += a >>> 16;
  37805. c += b >>> 16;
  37806. d += c >>> 16;
  37807. bh7 = (c & 0xffff) | (d << 16);
  37808. bl7 = (a & 0xffff) | (b << 16);
  37809. // add
  37810. h = bh3;
  37811. l = bl3;
  37812. a = l & 0xffff; b = l >>> 16;
  37813. c = h & 0xffff; d = h >>> 16;
  37814. h = th;
  37815. l = tl;
  37816. a += l & 0xffff; b += l >>> 16;
  37817. c += h & 0xffff; d += h >>> 16;
  37818. b += a >>> 16;
  37819. c += b >>> 16;
  37820. d += c >>> 16;
  37821. bh3 = (c & 0xffff) | (d << 16);
  37822. bl3 = (a & 0xffff) | (b << 16);
  37823. ah1 = bh0;
  37824. ah2 = bh1;
  37825. ah3 = bh2;
  37826. ah4 = bh3;
  37827. ah5 = bh4;
  37828. ah6 = bh5;
  37829. ah7 = bh6;
  37830. ah0 = bh7;
  37831. al1 = bl0;
  37832. al2 = bl1;
  37833. al3 = bl2;
  37834. al4 = bl3;
  37835. al5 = bl4;
  37836. al6 = bl5;
  37837. al7 = bl6;
  37838. al0 = bl7;
  37839. if (i%16 === 15) {
  37840. for (j = 0; j < 16; j++) {
  37841. // add
  37842. h = wh[j];
  37843. l = wl[j];
  37844. a = l & 0xffff; b = l >>> 16;
  37845. c = h & 0xffff; d = h >>> 16;
  37846. h = wh[(j+9)%16];
  37847. l = wl[(j+9)%16];
  37848. a += l & 0xffff; b += l >>> 16;
  37849. c += h & 0xffff; d += h >>> 16;
  37850. // sigma0
  37851. th = wh[(j+1)%16];
  37852. tl = wl[(j+1)%16];
  37853. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  37854. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  37855. a += l & 0xffff; b += l >>> 16;
  37856. c += h & 0xffff; d += h >>> 16;
  37857. // sigma1
  37858. th = wh[(j+14)%16];
  37859. tl = wl[(j+14)%16];
  37860. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  37861. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  37862. a += l & 0xffff; b += l >>> 16;
  37863. c += h & 0xffff; d += h >>> 16;
  37864. b += a >>> 16;
  37865. c += b >>> 16;
  37866. d += c >>> 16;
  37867. wh[j] = (c & 0xffff) | (d << 16);
  37868. wl[j] = (a & 0xffff) | (b << 16);
  37869. }
  37870. }
  37871. }
  37872. // add
  37873. h = ah0;
  37874. l = al0;
  37875. a = l & 0xffff; b = l >>> 16;
  37876. c = h & 0xffff; d = h >>> 16;
  37877. h = hh[0];
  37878. l = hl[0];
  37879. a += l & 0xffff; b += l >>> 16;
  37880. c += h & 0xffff; d += h >>> 16;
  37881. b += a >>> 16;
  37882. c += b >>> 16;
  37883. d += c >>> 16;
  37884. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  37885. hl[0] = al0 = (a & 0xffff) | (b << 16);
  37886. h = ah1;
  37887. l = al1;
  37888. a = l & 0xffff; b = l >>> 16;
  37889. c = h & 0xffff; d = h >>> 16;
  37890. h = hh[1];
  37891. l = hl[1];
  37892. a += l & 0xffff; b += l >>> 16;
  37893. c += h & 0xffff; d += h >>> 16;
  37894. b += a >>> 16;
  37895. c += b >>> 16;
  37896. d += c >>> 16;
  37897. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  37898. hl[1] = al1 = (a & 0xffff) | (b << 16);
  37899. h = ah2;
  37900. l = al2;
  37901. a = l & 0xffff; b = l >>> 16;
  37902. c = h & 0xffff; d = h >>> 16;
  37903. h = hh[2];
  37904. l = hl[2];
  37905. a += l & 0xffff; b += l >>> 16;
  37906. c += h & 0xffff; d += h >>> 16;
  37907. b += a >>> 16;
  37908. c += b >>> 16;
  37909. d += c >>> 16;
  37910. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  37911. hl[2] = al2 = (a & 0xffff) | (b << 16);
  37912. h = ah3;
  37913. l = al3;
  37914. a = l & 0xffff; b = l >>> 16;
  37915. c = h & 0xffff; d = h >>> 16;
  37916. h = hh[3];
  37917. l = hl[3];
  37918. a += l & 0xffff; b += l >>> 16;
  37919. c += h & 0xffff; d += h >>> 16;
  37920. b += a >>> 16;
  37921. c += b >>> 16;
  37922. d += c >>> 16;
  37923. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  37924. hl[3] = al3 = (a & 0xffff) | (b << 16);
  37925. h = ah4;
  37926. l = al4;
  37927. a = l & 0xffff; b = l >>> 16;
  37928. c = h & 0xffff; d = h >>> 16;
  37929. h = hh[4];
  37930. l = hl[4];
  37931. a += l & 0xffff; b += l >>> 16;
  37932. c += h & 0xffff; d += h >>> 16;
  37933. b += a >>> 16;
  37934. c += b >>> 16;
  37935. d += c >>> 16;
  37936. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  37937. hl[4] = al4 = (a & 0xffff) | (b << 16);
  37938. h = ah5;
  37939. l = al5;
  37940. a = l & 0xffff; b = l >>> 16;
  37941. c = h & 0xffff; d = h >>> 16;
  37942. h = hh[5];
  37943. l = hl[5];
  37944. a += l & 0xffff; b += l >>> 16;
  37945. c += h & 0xffff; d += h >>> 16;
  37946. b += a >>> 16;
  37947. c += b >>> 16;
  37948. d += c >>> 16;
  37949. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  37950. hl[5] = al5 = (a & 0xffff) | (b << 16);
  37951. h = ah6;
  37952. l = al6;
  37953. a = l & 0xffff; b = l >>> 16;
  37954. c = h & 0xffff; d = h >>> 16;
  37955. h = hh[6];
  37956. l = hl[6];
  37957. a += l & 0xffff; b += l >>> 16;
  37958. c += h & 0xffff; d += h >>> 16;
  37959. b += a >>> 16;
  37960. c += b >>> 16;
  37961. d += c >>> 16;
  37962. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  37963. hl[6] = al6 = (a & 0xffff) | (b << 16);
  37964. h = ah7;
  37965. l = al7;
  37966. a = l & 0xffff; b = l >>> 16;
  37967. c = h & 0xffff; d = h >>> 16;
  37968. h = hh[7];
  37969. l = hl[7];
  37970. a += l & 0xffff; b += l >>> 16;
  37971. c += h & 0xffff; d += h >>> 16;
  37972. b += a >>> 16;
  37973. c += b >>> 16;
  37974. d += c >>> 16;
  37975. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  37976. hl[7] = al7 = (a & 0xffff) | (b << 16);
  37977. pos += 128;
  37978. n -= 128;
  37979. }
  37980. return n;
  37981. }
  37982. function crypto_hash(out, m, n) {
  37983. var hh = new Int32Array(8),
  37984. hl = new Int32Array(8),
  37985. x = new Uint8Array(256),
  37986. i, b = n;
  37987. hh[0] = 0x6a09e667;
  37988. hh[1] = 0xbb67ae85;
  37989. hh[2] = 0x3c6ef372;
  37990. hh[3] = 0xa54ff53a;
  37991. hh[4] = 0x510e527f;
  37992. hh[5] = 0x9b05688c;
  37993. hh[6] = 0x1f83d9ab;
  37994. hh[7] = 0x5be0cd19;
  37995. hl[0] = 0xf3bcc908;
  37996. hl[1] = 0x84caa73b;
  37997. hl[2] = 0xfe94f82b;
  37998. hl[3] = 0x5f1d36f1;
  37999. hl[4] = 0xade682d1;
  38000. hl[5] = 0x2b3e6c1f;
  38001. hl[6] = 0xfb41bd6b;
  38002. hl[7] = 0x137e2179;
  38003. crypto_hashblocks_hl(hh, hl, m, n);
  38004. n %= 128;
  38005. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  38006. x[n] = 128;
  38007. n = 256-128*(n<112?1:0);
  38008. x[n-9] = 0;
  38009. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  38010. crypto_hashblocks_hl(hh, hl, x, n);
  38011. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  38012. return 0;
  38013. }
  38014. function add(p, q) {
  38015. var a = gf(), b = gf(), c = gf(),
  38016. d = gf(), e = gf(), f = gf(),
  38017. g = gf(), h = gf(), t = gf();
  38018. Z(a, p[1], p[0]);
  38019. Z(t, q[1], q[0]);
  38020. M(a, a, t);
  38021. A(b, p[0], p[1]);
  38022. A(t, q[0], q[1]);
  38023. M(b, b, t);
  38024. M(c, p[3], q[3]);
  38025. M(c, c, D2);
  38026. M(d, p[2], q[2]);
  38027. A(d, d, d);
  38028. Z(e, b, a);
  38029. Z(f, d, c);
  38030. A(g, d, c);
  38031. A(h, b, a);
  38032. M(p[0], e, f);
  38033. M(p[1], h, g);
  38034. M(p[2], g, f);
  38035. M(p[3], e, h);
  38036. }
  38037. function cswap(p, q, b) {
  38038. var i;
  38039. for (i = 0; i < 4; i++) {
  38040. sel25519(p[i], q[i], b);
  38041. }
  38042. }
  38043. function pack(r, p) {
  38044. var tx = gf(), ty = gf(), zi = gf();
  38045. inv25519(zi, p[2]);
  38046. M(tx, p[0], zi);
  38047. M(ty, p[1], zi);
  38048. pack25519(r, ty);
  38049. r[31] ^= par25519(tx) << 7;
  38050. }
  38051. function scalarmult(p, q, s) {
  38052. var b, i;
  38053. set25519(p[0], gf0);
  38054. set25519(p[1], gf1);
  38055. set25519(p[2], gf1);
  38056. set25519(p[3], gf0);
  38057. for (i = 255; i >= 0; --i) {
  38058. b = (s[(i/8)|0] >> (i&7)) & 1;
  38059. cswap(p, q, b);
  38060. add(q, p);
  38061. add(p, p);
  38062. cswap(p, q, b);
  38063. }
  38064. }
  38065. function scalarbase(p, s) {
  38066. var q = [gf(), gf(), gf(), gf()];
  38067. set25519(q[0], X);
  38068. set25519(q[1], Y);
  38069. set25519(q[2], gf1);
  38070. M(q[3], X, Y);
  38071. scalarmult(p, q, s);
  38072. }
  38073. function crypto_sign_keypair(pk, sk, seeded) {
  38074. var d = new Uint8Array(64);
  38075. var p = [gf(), gf(), gf(), gf()];
  38076. var i;
  38077. if (!seeded) randombytes(sk, 32);
  38078. crypto_hash(d, sk, 32);
  38079. d[0] &= 248;
  38080. d[31] &= 127;
  38081. d[31] |= 64;
  38082. scalarbase(p, d);
  38083. pack(pk, p);
  38084. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  38085. return 0;
  38086. }
  38087. 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]);
  38088. function modL(r, x) {
  38089. var carry, i, j, k;
  38090. for (i = 63; i >= 32; --i) {
  38091. carry = 0;
  38092. for (j = i - 32, k = i - 12; j < k; ++j) {
  38093. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  38094. carry = (x[j] + 128) >> 8;
  38095. x[j] -= carry * 256;
  38096. }
  38097. x[j] += carry;
  38098. x[i] = 0;
  38099. }
  38100. carry = 0;
  38101. for (j = 0; j < 32; j++) {
  38102. x[j] += carry - (x[31] >> 4) * L[j];
  38103. carry = x[j] >> 8;
  38104. x[j] &= 255;
  38105. }
  38106. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  38107. for (i = 0; i < 32; i++) {
  38108. x[i+1] += x[i] >> 8;
  38109. r[i] = x[i] & 255;
  38110. }
  38111. }
  38112. function reduce(r) {
  38113. var x = new Float64Array(64), i;
  38114. for (i = 0; i < 64; i++) x[i] = r[i];
  38115. for (i = 0; i < 64; i++) r[i] = 0;
  38116. modL(r, x);
  38117. }
  38118. // Note: difference from C - smlen returned, not passed as argument.
  38119. function crypto_sign(sm, m, n, sk) {
  38120. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  38121. var i, j, x = new Float64Array(64);
  38122. var p = [gf(), gf(), gf(), gf()];
  38123. crypto_hash(d, sk, 32);
  38124. d[0] &= 248;
  38125. d[31] &= 127;
  38126. d[31] |= 64;
  38127. var smlen = n + 64;
  38128. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  38129. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  38130. crypto_hash(r, sm.subarray(32), n+32);
  38131. reduce(r);
  38132. scalarbase(p, r);
  38133. pack(sm, p);
  38134. for (i = 32; i < 64; i++) sm[i] = sk[i];
  38135. crypto_hash(h, sm, n + 64);
  38136. reduce(h);
  38137. for (i = 0; i < 64; i++) x[i] = 0;
  38138. for (i = 0; i < 32; i++) x[i] = r[i];
  38139. for (i = 0; i < 32; i++) {
  38140. for (j = 0; j < 32; j++) {
  38141. x[i+j] += h[i] * d[j];
  38142. }
  38143. }
  38144. modL(sm.subarray(32), x);
  38145. return smlen;
  38146. }
  38147. function unpackneg(r, p) {
  38148. var t = gf(), chk = gf(), num = gf(),
  38149. den = gf(), den2 = gf(), den4 = gf(),
  38150. den6 = gf();
  38151. set25519(r[2], gf1);
  38152. unpack25519(r[1], p);
  38153. S(num, r[1]);
  38154. M(den, num, D);
  38155. Z(num, num, r[2]);
  38156. A(den, r[2], den);
  38157. S(den2, den);
  38158. S(den4, den2);
  38159. M(den6, den4, den2);
  38160. M(t, den6, num);
  38161. M(t, t, den);
  38162. pow2523(t, t);
  38163. M(t, t, num);
  38164. M(t, t, den);
  38165. M(t, t, den);
  38166. M(r[0], t, den);
  38167. S(chk, r[0]);
  38168. M(chk, chk, den);
  38169. if (neq25519(chk, num)) M(r[0], r[0], I);
  38170. S(chk, r[0]);
  38171. M(chk, chk, den);
  38172. if (neq25519(chk, num)) return -1;
  38173. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  38174. M(r[3], r[0], r[1]);
  38175. return 0;
  38176. }
  38177. function crypto_sign_open(m, sm, n, pk) {
  38178. var i, mlen;
  38179. var t = new Uint8Array(32), h = new Uint8Array(64);
  38180. var p = [gf(), gf(), gf(), gf()],
  38181. q = [gf(), gf(), gf(), gf()];
  38182. mlen = -1;
  38183. if (n < 64) return -1;
  38184. if (unpackneg(q, pk)) return -1;
  38185. for (i = 0; i < n; i++) m[i] = sm[i];
  38186. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  38187. crypto_hash(h, m, n);
  38188. reduce(h);
  38189. scalarmult(p, q, h);
  38190. scalarbase(q, sm.subarray(32));
  38191. add(p, q);
  38192. pack(t, p);
  38193. n -= 64;
  38194. if (crypto_verify_32(sm, 0, t, 0)) {
  38195. for (i = 0; i < n; i++) m[i] = 0;
  38196. return -1;
  38197. }
  38198. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  38199. mlen = n;
  38200. return mlen;
  38201. }
  38202. var crypto_secretbox_KEYBYTES = 32,
  38203. crypto_secretbox_NONCEBYTES = 24,
  38204. crypto_secretbox_ZEROBYTES = 32,
  38205. crypto_secretbox_BOXZEROBYTES = 16,
  38206. crypto_scalarmult_BYTES = 32,
  38207. crypto_scalarmult_SCALARBYTES = 32,
  38208. crypto_box_PUBLICKEYBYTES = 32,
  38209. crypto_box_SECRETKEYBYTES = 32,
  38210. crypto_box_BEFORENMBYTES = 32,
  38211. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  38212. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  38213. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  38214. crypto_sign_BYTES = 64,
  38215. crypto_sign_PUBLICKEYBYTES = 32,
  38216. crypto_sign_SECRETKEYBYTES = 64,
  38217. crypto_sign_SEEDBYTES = 32,
  38218. crypto_hash_BYTES = 64;
  38219. nacl.lowlevel = {
  38220. crypto_core_hsalsa20: crypto_core_hsalsa20,
  38221. crypto_stream_xor: crypto_stream_xor,
  38222. crypto_stream: crypto_stream,
  38223. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  38224. crypto_stream_salsa20: crypto_stream_salsa20,
  38225. crypto_onetimeauth: crypto_onetimeauth,
  38226. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  38227. crypto_verify_16: crypto_verify_16,
  38228. crypto_verify_32: crypto_verify_32,
  38229. crypto_secretbox: crypto_secretbox,
  38230. crypto_secretbox_open: crypto_secretbox_open,
  38231. crypto_scalarmult: crypto_scalarmult,
  38232. crypto_scalarmult_base: crypto_scalarmult_base,
  38233. crypto_box_beforenm: crypto_box_beforenm,
  38234. crypto_box_afternm: crypto_box_afternm,
  38235. crypto_box: crypto_box,
  38236. crypto_box_open: crypto_box_open,
  38237. crypto_box_keypair: crypto_box_keypair,
  38238. crypto_hash: crypto_hash,
  38239. crypto_sign: crypto_sign,
  38240. crypto_sign_keypair: crypto_sign_keypair,
  38241. crypto_sign_open: crypto_sign_open,
  38242. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  38243. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  38244. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  38245. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  38246. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  38247. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  38248. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  38249. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  38250. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  38251. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  38252. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  38253. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  38254. crypto_sign_BYTES: crypto_sign_BYTES,
  38255. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  38256. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  38257. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  38258. crypto_hash_BYTES: crypto_hash_BYTES
  38259. };
  38260. /* High-level API */
  38261. function checkLengths(k, n) {
  38262. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  38263. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  38264. }
  38265. function checkBoxLengths(pk, sk) {
  38266. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  38267. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  38268. }
  38269. function checkArrayTypes() {
  38270. for (var i = 0; i < arguments.length; i++) {
  38271. if (!(arguments[i] instanceof Uint8Array))
  38272. throw new TypeError('unexpected type, use Uint8Array');
  38273. }
  38274. }
  38275. function cleanup(arr) {
  38276. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  38277. }
  38278. nacl.randomBytes = function(n) {
  38279. var b = new Uint8Array(n);
  38280. randombytes(b, n);
  38281. return b;
  38282. };
  38283. nacl.secretbox = function(msg, nonce, key) {
  38284. checkArrayTypes(msg, nonce, key);
  38285. checkLengths(key, nonce);
  38286. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  38287. var c = new Uint8Array(m.length);
  38288. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  38289. crypto_secretbox(c, m, m.length, nonce, key);
  38290. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  38291. };
  38292. nacl.secretbox.open = function(box, nonce, key) {
  38293. checkArrayTypes(box, nonce, key);
  38294. checkLengths(key, nonce);
  38295. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  38296. var m = new Uint8Array(c.length);
  38297. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  38298. if (c.length < 32) return null;
  38299. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  38300. return m.subarray(crypto_secretbox_ZEROBYTES);
  38301. };
  38302. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  38303. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  38304. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  38305. nacl.scalarMult = function(n, p) {
  38306. checkArrayTypes(n, p);
  38307. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38308. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  38309. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38310. crypto_scalarmult(q, n, p);
  38311. return q;
  38312. };
  38313. nacl.scalarMult.base = function(n) {
  38314. checkArrayTypes(n);
  38315. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38316. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38317. crypto_scalarmult_base(q, n);
  38318. return q;
  38319. };
  38320. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  38321. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  38322. nacl.box = function(msg, nonce, publicKey, secretKey) {
  38323. var k = nacl.box.before(publicKey, secretKey);
  38324. return nacl.secretbox(msg, nonce, k);
  38325. };
  38326. nacl.box.before = function(publicKey, secretKey) {
  38327. checkArrayTypes(publicKey, secretKey);
  38328. checkBoxLengths(publicKey, secretKey);
  38329. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  38330. crypto_box_beforenm(k, publicKey, secretKey);
  38331. return k;
  38332. };
  38333. nacl.box.after = nacl.secretbox;
  38334. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  38335. var k = nacl.box.before(publicKey, secretKey);
  38336. return nacl.secretbox.open(msg, nonce, k);
  38337. };
  38338. nacl.box.open.after = nacl.secretbox.open;
  38339. nacl.box.keyPair = function() {
  38340. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38341. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  38342. crypto_box_keypair(pk, sk);
  38343. return {publicKey: pk, secretKey: sk};
  38344. };
  38345. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  38346. checkArrayTypes(secretKey);
  38347. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  38348. throw new Error('bad secret key size');
  38349. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38350. crypto_scalarmult_base(pk, secretKey);
  38351. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38352. };
  38353. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  38354. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  38355. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  38356. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  38357. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  38358. nacl.sign = function(msg, secretKey) {
  38359. checkArrayTypes(msg, secretKey);
  38360. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38361. throw new Error('bad secret key size');
  38362. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  38363. crypto_sign(signedMsg, msg, msg.length, secretKey);
  38364. return signedMsg;
  38365. };
  38366. nacl.sign.open = function(signedMsg, publicKey) {
  38367. checkArrayTypes(signedMsg, publicKey);
  38368. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38369. throw new Error('bad public key size');
  38370. var tmp = new Uint8Array(signedMsg.length);
  38371. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  38372. if (mlen < 0) return null;
  38373. var m = new Uint8Array(mlen);
  38374. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  38375. return m;
  38376. };
  38377. nacl.sign.detached = function(msg, secretKey) {
  38378. var signedMsg = nacl.sign(msg, secretKey);
  38379. var sig = new Uint8Array(crypto_sign_BYTES);
  38380. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  38381. return sig;
  38382. };
  38383. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  38384. checkArrayTypes(msg, sig, publicKey);
  38385. if (sig.length !== crypto_sign_BYTES)
  38386. throw new Error('bad signature size');
  38387. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38388. throw new Error('bad public key size');
  38389. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  38390. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  38391. var i;
  38392. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  38393. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  38394. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  38395. };
  38396. nacl.sign.keyPair = function() {
  38397. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38398. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38399. crypto_sign_keypair(pk, sk);
  38400. return {publicKey: pk, secretKey: sk};
  38401. };
  38402. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  38403. checkArrayTypes(secretKey);
  38404. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38405. throw new Error('bad secret key size');
  38406. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38407. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  38408. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38409. };
  38410. nacl.sign.keyPair.fromSeed = function(seed) {
  38411. checkArrayTypes(seed);
  38412. if (seed.length !== crypto_sign_SEEDBYTES)
  38413. throw new Error('bad seed size');
  38414. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38415. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38416. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  38417. crypto_sign_keypair(pk, sk, true);
  38418. return {publicKey: pk, secretKey: sk};
  38419. };
  38420. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  38421. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  38422. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  38423. nacl.sign.signatureLength = crypto_sign_BYTES;
  38424. nacl.hash = function(msg) {
  38425. checkArrayTypes(msg);
  38426. var h = new Uint8Array(crypto_hash_BYTES);
  38427. crypto_hash(h, msg, msg.length);
  38428. return h;
  38429. };
  38430. nacl.hash.hashLength = crypto_hash_BYTES;
  38431. nacl.verify = function(x, y) {
  38432. checkArrayTypes(x, y);
  38433. // Zero length arguments are considered not equal.
  38434. if (x.length === 0 || y.length === 0) return false;
  38435. if (x.length !== y.length) return false;
  38436. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  38437. };
  38438. nacl.setPRNG = function(fn) {
  38439. randombytes = fn;
  38440. };
  38441. (function() {
  38442. // Initialize PRNG if environment provides CSPRNG.
  38443. // If not, methods calling randombytes will throw.
  38444. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  38445. if (crypto && crypto.getRandomValues) {
  38446. // Browsers.
  38447. var QUOTA = 65536;
  38448. nacl.setPRNG(function(x, n) {
  38449. var i, v = new Uint8Array(n);
  38450. for (i = 0; i < n; i += QUOTA) {
  38451. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  38452. }
  38453. for (i = 0; i < n; i++) x[i] = v[i];
  38454. cleanup(v);
  38455. });
  38456. } else if (true) {
  38457. // Node.js.
  38458. crypto = __webpack_require__(3);
  38459. if (crypto && crypto.randomBytes) {
  38460. nacl.setPRNG(function(x, n) {
  38461. var i, v = crypto.randomBytes(n);
  38462. for (i = 0; i < n; i++) x[i] = v[i];
  38463. cleanup(v);
  38464. });
  38465. }
  38466. }
  38467. })();
  38468. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  38469. /***/ }),
  38470. /* 1 */
  38471. /***/ (function(module, exports, __webpack_require__) {
  38472. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  38473. // Public domain.
  38474. (function(root, f) {
  38475. 'use strict';
  38476. if ( true && module.exports) module.exports = f();
  38477. else if (root.nacl) root.nacl.util = f();
  38478. else {
  38479. root.nacl = {};
  38480. root.nacl.util = f();
  38481. }
  38482. }(this, function() {
  38483. 'use strict';
  38484. var util = {};
  38485. function validateBase64(s) {
  38486. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  38487. throw new TypeError('invalid encoding');
  38488. }
  38489. }
  38490. util.decodeUTF8 = function(s) {
  38491. if (typeof s !== 'string') throw new TypeError('expected string');
  38492. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  38493. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38494. return b;
  38495. };
  38496. util.encodeUTF8 = function(arr) {
  38497. var i, s = [];
  38498. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  38499. return decodeURIComponent(escape(s.join('')));
  38500. };
  38501. if (typeof atob === 'undefined') {
  38502. // Node.js
  38503. if (typeof Buffer.from !== 'undefined') {
  38504. // Node v6 and later
  38505. util.encodeBase64 = function (arr) { // v6 and later
  38506. return Buffer.from(arr).toString('base64');
  38507. };
  38508. util.decodeBase64 = function (s) {
  38509. validateBase64(s);
  38510. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  38511. };
  38512. } else {
  38513. // Node earlier than v6
  38514. util.encodeBase64 = function (arr) { // v6 and later
  38515. return (new Buffer(arr)).toString('base64');
  38516. };
  38517. util.decodeBase64 = function(s) {
  38518. validateBase64(s);
  38519. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  38520. };
  38521. }
  38522. } else {
  38523. // Browsers
  38524. util.encodeBase64 = function(arr) {
  38525. var i, s = [], len = arr.length;
  38526. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  38527. return btoa(s.join(''));
  38528. };
  38529. util.decodeBase64 = function(s) {
  38530. validateBase64(s);
  38531. var i, d = atob(s), b = new Uint8Array(d.length);
  38532. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38533. return b;
  38534. };
  38535. }
  38536. return util;
  38537. }));
  38538. /***/ }),
  38539. /* 2 */
  38540. /***/ (function(module, exports, __webpack_require__) {
  38541. // required so we don't have to do require('pusher').default etc.
  38542. module.exports = __webpack_require__(4).default;
  38543. /***/ }),
  38544. /* 3 */
  38545. /***/ (function(module, exports) {
  38546. /* (ignored) */
  38547. /***/ }),
  38548. /* 4 */
  38549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38550. "use strict";
  38551. __webpack_require__.r(__webpack_exports__);
  38552. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  38553. var ScriptReceiverFactory = (function () {
  38554. function ScriptReceiverFactory(prefix, name) {
  38555. this.lastId = 0;
  38556. this.prefix = prefix;
  38557. this.name = name;
  38558. }
  38559. ScriptReceiverFactory.prototype.create = function (callback) {
  38560. this.lastId++;
  38561. var number = this.lastId;
  38562. var id = this.prefix + number;
  38563. var name = this.name + "[" + number + "]";
  38564. var called = false;
  38565. var callbackWrapper = function () {
  38566. if (!called) {
  38567. callback.apply(null, arguments);
  38568. called = true;
  38569. }
  38570. };
  38571. this[number] = callbackWrapper;
  38572. return { number: number, id: id, name: name, callback: callbackWrapper };
  38573. };
  38574. ScriptReceiverFactory.prototype.remove = function (receiver) {
  38575. delete this[receiver.number];
  38576. };
  38577. return ScriptReceiverFactory;
  38578. }());
  38579. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  38580. // CONCATENATED MODULE: ./src/core/defaults.ts
  38581. var Defaults = {
  38582. VERSION: "5.0.3",
  38583. PROTOCOL: 7,
  38584. host: 'ws.pusherapp.com',
  38585. ws_port: 80,
  38586. wss_port: 443,
  38587. ws_path: '',
  38588. sockjs_host: 'sockjs.pusher.com',
  38589. sockjs_http_port: 80,
  38590. sockjs_https_port: 443,
  38591. sockjs_path: '/pusher',
  38592. stats_host: 'stats.pusher.com',
  38593. channel_auth_endpoint: '/pusher/auth',
  38594. channel_auth_transport: 'ajax',
  38595. activity_timeout: 120000,
  38596. pong_timeout: 30000,
  38597. unavailable_timeout: 10000,
  38598. cdn_http: "http://js.pusher.com",
  38599. cdn_https: "https://js.pusher.com",
  38600. dependency_suffix: ""
  38601. };
  38602. /* harmony default export */ var defaults = (Defaults);
  38603. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  38604. var dependency_loader_DependencyLoader = (function () {
  38605. function DependencyLoader(options) {
  38606. this.options = options;
  38607. this.receivers = options.receivers || ScriptReceivers;
  38608. this.loading = {};
  38609. }
  38610. DependencyLoader.prototype.load = function (name, options, callback) {
  38611. var self = this;
  38612. if (self.loading[name] && self.loading[name].length > 0) {
  38613. self.loading[name].push(callback);
  38614. }
  38615. else {
  38616. self.loading[name] = [callback];
  38617. var request = runtime.createScriptRequest(self.getPath(name, options));
  38618. var receiver = self.receivers.create(function (error) {
  38619. self.receivers.remove(receiver);
  38620. if (self.loading[name]) {
  38621. var callbacks = self.loading[name];
  38622. delete self.loading[name];
  38623. var successCallback = function (wasSuccessful) {
  38624. if (!wasSuccessful) {
  38625. request.cleanup();
  38626. }
  38627. };
  38628. for (var i = 0; i < callbacks.length; i++) {
  38629. callbacks[i](error, successCallback);
  38630. }
  38631. }
  38632. });
  38633. request.send(receiver);
  38634. }
  38635. };
  38636. DependencyLoader.prototype.getRoot = function (options) {
  38637. var cdn;
  38638. var protocol = runtime.getDocument().location.protocol;
  38639. if ((options && options.useTLS) || protocol === "https:") {
  38640. cdn = this.options.cdn_https;
  38641. }
  38642. else {
  38643. cdn = this.options.cdn_http;
  38644. }
  38645. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  38646. };
  38647. DependencyLoader.prototype.getPath = function (name, options) {
  38648. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  38649. };
  38650. ;
  38651. return DependencyLoader;
  38652. }());
  38653. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  38654. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  38655. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  38656. var Dependencies = new dependency_loader({
  38657. cdn_http: defaults.cdn_http,
  38658. cdn_https: defaults.cdn_https,
  38659. version: defaults.VERSION,
  38660. suffix: defaults.dependency_suffix,
  38661. receivers: DependenciesReceivers
  38662. });
  38663. // CONCATENATED MODULE: ./src/core/base64.ts
  38664. function encode(s) {
  38665. return btoa(utob(s));
  38666. }
  38667. var fromCharCode = String.fromCharCode;
  38668. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  38669. var b64tab = {};
  38670. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  38671. b64tab[b64chars.charAt(base64_i)] = base64_i;
  38672. }
  38673. var cb_utob = function (c) {
  38674. var cc = c.charCodeAt(0);
  38675. return cc < 0x80
  38676. ? c
  38677. : cc < 0x800
  38678. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  38679. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  38680. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  38681. fromCharCode(0x80 | (cc & 0x3f));
  38682. };
  38683. var utob = function (u) {
  38684. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  38685. };
  38686. var cb_encode = function (ccc) {
  38687. var padlen = [0, 2, 1][ccc.length % 3];
  38688. var ord = (ccc.charCodeAt(0) << 16) |
  38689. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  38690. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  38691. var chars = [
  38692. b64chars.charAt(ord >>> 18),
  38693. b64chars.charAt((ord >>> 12) & 63),
  38694. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  38695. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  38696. ];
  38697. return chars.join('');
  38698. };
  38699. var btoa = window.btoa ||
  38700. function (b) {
  38701. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  38702. };
  38703. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  38704. var Timer = (function () {
  38705. function Timer(set, clear, delay, callback) {
  38706. var _this = this;
  38707. this.clear = clear;
  38708. this.timer = set(function () {
  38709. if (_this.timer) {
  38710. _this.timer = callback(_this.timer);
  38711. }
  38712. }, delay);
  38713. }
  38714. Timer.prototype.isRunning = function () {
  38715. return this.timer !== null;
  38716. };
  38717. Timer.prototype.ensureAborted = function () {
  38718. if (this.timer) {
  38719. this.clear(this.timer);
  38720. this.timer = null;
  38721. }
  38722. };
  38723. return Timer;
  38724. }());
  38725. /* harmony default export */ var abstract_timer = (Timer);
  38726. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  38727. var __extends = (undefined && undefined.__extends) || (function () {
  38728. var extendStatics = function (d, b) {
  38729. extendStatics = Object.setPrototypeOf ||
  38730. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38731. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38732. return extendStatics(d, b);
  38733. };
  38734. return function (d, b) {
  38735. extendStatics(d, b);
  38736. function __() { this.constructor = d; }
  38737. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38738. };
  38739. })();
  38740. function timers_clearTimeout(timer) {
  38741. window.clearTimeout(timer);
  38742. }
  38743. function timers_clearInterval(timer) {
  38744. window.clearInterval(timer);
  38745. }
  38746. var OneOffTimer = (function (_super) {
  38747. __extends(OneOffTimer, _super);
  38748. function OneOffTimer(delay, callback) {
  38749. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  38750. callback();
  38751. return null;
  38752. }) || this;
  38753. }
  38754. return OneOffTimer;
  38755. }(abstract_timer));
  38756. var PeriodicTimer = (function (_super) {
  38757. __extends(PeriodicTimer, _super);
  38758. function PeriodicTimer(delay, callback) {
  38759. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  38760. callback();
  38761. return timer;
  38762. }) || this;
  38763. }
  38764. return PeriodicTimer;
  38765. }(abstract_timer));
  38766. // CONCATENATED MODULE: ./src/core/util.ts
  38767. var Util = {
  38768. now: function () {
  38769. if (Date.now) {
  38770. return Date.now();
  38771. }
  38772. else {
  38773. return new Date().valueOf();
  38774. }
  38775. },
  38776. defer: function (callback) {
  38777. return new OneOffTimer(0, callback);
  38778. },
  38779. method: function (name) {
  38780. var args = [];
  38781. for (var _i = 1; _i < arguments.length; _i++) {
  38782. args[_i - 1] = arguments[_i];
  38783. }
  38784. var boundArguments = Array.prototype.slice.call(arguments, 1);
  38785. return function (object) {
  38786. return object[name].apply(object, boundArguments.concat(arguments));
  38787. };
  38788. }
  38789. };
  38790. /* harmony default export */ var util = (Util);
  38791. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  38792. function extend(target) {
  38793. var sources = [];
  38794. for (var _i = 1; _i < arguments.length; _i++) {
  38795. sources[_i - 1] = arguments[_i];
  38796. }
  38797. for (var i = 0; i < sources.length; i++) {
  38798. var extensions = sources[i];
  38799. for (var property in extensions) {
  38800. if (extensions[property] && extensions[property].constructor &&
  38801. extensions[property].constructor === Object) {
  38802. target[property] = extend(target[property] || {}, extensions[property]);
  38803. }
  38804. else {
  38805. target[property] = extensions[property];
  38806. }
  38807. }
  38808. }
  38809. return target;
  38810. }
  38811. function stringify() {
  38812. var m = ["Pusher"];
  38813. for (var i = 0; i < arguments.length; i++) {
  38814. if (typeof arguments[i] === "string") {
  38815. m.push(arguments[i]);
  38816. }
  38817. else {
  38818. m.push(safeJSONStringify(arguments[i]));
  38819. }
  38820. }
  38821. return m.join(" : ");
  38822. }
  38823. function arrayIndexOf(array, item) {
  38824. var nativeIndexOf = Array.prototype.indexOf;
  38825. if (array === null) {
  38826. return -1;
  38827. }
  38828. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  38829. return array.indexOf(item);
  38830. }
  38831. for (var i = 0, l = array.length; i < l; i++) {
  38832. if (array[i] === item) {
  38833. return i;
  38834. }
  38835. }
  38836. return -1;
  38837. }
  38838. function objectApply(object, f) {
  38839. for (var key in object) {
  38840. if (Object.prototype.hasOwnProperty.call(object, key)) {
  38841. f(object[key], key, object);
  38842. }
  38843. }
  38844. }
  38845. function keys(object) {
  38846. var keys = [];
  38847. objectApply(object, function (_, key) {
  38848. keys.push(key);
  38849. });
  38850. return keys;
  38851. }
  38852. function values(object) {
  38853. var values = [];
  38854. objectApply(object, function (value) {
  38855. values.push(value);
  38856. });
  38857. return values;
  38858. }
  38859. function apply(array, f, context) {
  38860. for (var i = 0; i < array.length; i++) {
  38861. f.call(context || window, array[i], i, array);
  38862. }
  38863. }
  38864. function map(array, f) {
  38865. var result = [];
  38866. for (var i = 0; i < array.length; i++) {
  38867. result.push(f(array[i], i, array, result));
  38868. }
  38869. return result;
  38870. }
  38871. function mapObject(object, f) {
  38872. var result = {};
  38873. objectApply(object, function (value, key) {
  38874. result[key] = f(value);
  38875. });
  38876. return result;
  38877. }
  38878. function filter(array, test) {
  38879. test = test || function (value) { return !!value; };
  38880. var result = [];
  38881. for (var i = 0; i < array.length; i++) {
  38882. if (test(array[i], i, array, result)) {
  38883. result.push(array[i]);
  38884. }
  38885. }
  38886. return result;
  38887. }
  38888. function filterObject(object, test) {
  38889. var result = {};
  38890. objectApply(object, function (value, key) {
  38891. if ((test && test(value, key, object, result)) || Boolean(value)) {
  38892. result[key] = value;
  38893. }
  38894. });
  38895. return result;
  38896. }
  38897. function flatten(object) {
  38898. var result = [];
  38899. objectApply(object, function (value, key) {
  38900. result.push([key, value]);
  38901. });
  38902. return result;
  38903. }
  38904. function any(array, test) {
  38905. for (var i = 0; i < array.length; i++) {
  38906. if (test(array[i], i, array)) {
  38907. return true;
  38908. }
  38909. }
  38910. return false;
  38911. }
  38912. function collections_all(array, test) {
  38913. for (var i = 0; i < array.length; i++) {
  38914. if (!test(array[i], i, array)) {
  38915. return false;
  38916. }
  38917. }
  38918. return true;
  38919. }
  38920. function encodeParamsObject(data) {
  38921. return mapObject(data, function (value) {
  38922. if (typeof value === "object") {
  38923. value = safeJSONStringify(value);
  38924. }
  38925. return encodeURIComponent(encode(value.toString()));
  38926. });
  38927. }
  38928. function buildQueryString(data) {
  38929. var params = filterObject(data, function (value) {
  38930. return value !== undefined;
  38931. });
  38932. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  38933. return query;
  38934. }
  38935. function decycleObject(object) {
  38936. var objects = [], paths = [];
  38937. return (function derez(value, path) {
  38938. var i, name, nu;
  38939. switch (typeof value) {
  38940. case 'object':
  38941. if (!value) {
  38942. return null;
  38943. }
  38944. for (i = 0; i < objects.length; i += 1) {
  38945. if (objects[i] === value) {
  38946. return { $ref: paths[i] };
  38947. }
  38948. }
  38949. objects.push(value);
  38950. paths.push(path);
  38951. if (Object.prototype.toString.apply(value) === '[object Array]') {
  38952. nu = [];
  38953. for (i = 0; i < value.length; i += 1) {
  38954. nu[i] = derez(value[i], path + '[' + i + ']');
  38955. }
  38956. }
  38957. else {
  38958. nu = {};
  38959. for (name in value) {
  38960. if (Object.prototype.hasOwnProperty.call(value, name)) {
  38961. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  38962. }
  38963. }
  38964. }
  38965. return nu;
  38966. case 'number':
  38967. case 'string':
  38968. case 'boolean':
  38969. return value;
  38970. }
  38971. }(object, '$'));
  38972. }
  38973. function safeJSONStringify(source) {
  38974. try {
  38975. return JSON.stringify(source);
  38976. }
  38977. catch (e) {
  38978. return JSON.stringify(decycleObject(source));
  38979. }
  38980. }
  38981. // CONCATENATED MODULE: ./src/core/logger.ts
  38982. var logger_Logger = (function () {
  38983. function Logger() {
  38984. this.globalLog = function (message) {
  38985. if (window.console && window.console.log) {
  38986. window.console.log(message);
  38987. }
  38988. };
  38989. }
  38990. Logger.prototype.debug = function () {
  38991. var args = [];
  38992. for (var _i = 0; _i < arguments.length; _i++) {
  38993. args[_i] = arguments[_i];
  38994. }
  38995. this.log(this.globalLog, args);
  38996. };
  38997. Logger.prototype.warn = function () {
  38998. var args = [];
  38999. for (var _i = 0; _i < arguments.length; _i++) {
  39000. args[_i] = arguments[_i];
  39001. }
  39002. this.log(this.globalLogWarn, args);
  39003. };
  39004. Logger.prototype.error = function () {
  39005. var args = [];
  39006. for (var _i = 0; _i < arguments.length; _i++) {
  39007. args[_i] = arguments[_i];
  39008. }
  39009. this.log(this.globalLogError, args);
  39010. };
  39011. Logger.prototype.globalLogWarn = function (message) {
  39012. if (window.console && window.console.warn) {
  39013. window.console.warn(message);
  39014. }
  39015. else {
  39016. this.globalLog(message);
  39017. }
  39018. };
  39019. Logger.prototype.globalLogError = function (message) {
  39020. if (window.console && window.console.error) {
  39021. window.console.error(message);
  39022. }
  39023. else {
  39024. this.globalLogWarn(message);
  39025. }
  39026. };
  39027. Logger.prototype.log = function (defaultLoggingFunction) {
  39028. var args = [];
  39029. for (var _i = 1; _i < arguments.length; _i++) {
  39030. args[_i - 1] = arguments[_i];
  39031. }
  39032. var message = stringify.apply(this, arguments);
  39033. if (core_pusher.log) {
  39034. core_pusher.log(message);
  39035. }
  39036. else if (core_pusher.logToConsole) {
  39037. var log = defaultLoggingFunction.bind(this);
  39038. log(message);
  39039. }
  39040. };
  39041. return Logger;
  39042. }());
  39043. /* harmony default export */ var logger = (new logger_Logger());
  39044. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  39045. var urlStore = {
  39046. baseUrl: "https://pusher.com",
  39047. urls: {
  39048. authenticationEndpoint: {
  39049. path: "/docs/authenticating_users",
  39050. },
  39051. javascriptQuickStart: {
  39052. path: "/docs/javascript_quick_start"
  39053. },
  39054. triggeringClientEvents: {
  39055. path: "/docs/client_api_guide/client_events#trigger-events"
  39056. }
  39057. }
  39058. };
  39059. var buildLogSuffix = function (key) {
  39060. var urlPrefix = "See:";
  39061. var urlObj = urlStore.urls[key];
  39062. if (!urlObj)
  39063. return "";
  39064. var url;
  39065. if (urlObj.fullUrl) {
  39066. url = urlObj.fullUrl;
  39067. }
  39068. else if (urlObj.path) {
  39069. url = urlStore.baseUrl + urlObj.path;
  39070. }
  39071. if (!url)
  39072. return "";
  39073. return urlPrefix + " " + url;
  39074. };
  39075. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  39076. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  39077. var ajax = function (context, socketId, callback) {
  39078. var self = this, xhr;
  39079. xhr = runtime.createXHR();
  39080. xhr.open("POST", self.options.authEndpoint, true);
  39081. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  39082. for (var headerName in this.authOptions.headers) {
  39083. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  39084. }
  39085. xhr.onreadystatechange = function () {
  39086. if (xhr.readyState === 4) {
  39087. if (xhr.status === 200) {
  39088. var data, parsed = false;
  39089. try {
  39090. data = JSON.parse(xhr.responseText);
  39091. parsed = true;
  39092. }
  39093. catch (e) {
  39094. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  39095. }
  39096. if (parsed) {
  39097. callback(false, data);
  39098. }
  39099. }
  39100. else {
  39101. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39102. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  39103. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  39104. ("Clients must be authenticated to join private or presence channels. " + suffix));
  39105. callback(true, xhr.status);
  39106. }
  39107. }
  39108. };
  39109. xhr.send(this.composeQuery(socketId));
  39110. return xhr;
  39111. };
  39112. /* harmony default export */ var xhr_auth = (ajax);
  39113. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  39114. var jsonp = function (context, socketId, callback) {
  39115. if (this.authOptions.headers !== undefined) {
  39116. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  39117. }
  39118. var callbackName = context.nextAuthCallbackID.toString();
  39119. context.nextAuthCallbackID++;
  39120. var document = context.getDocument();
  39121. var script = document.createElement("script");
  39122. context.auth_callbacks[callbackName] = function (data) {
  39123. callback(false, data);
  39124. };
  39125. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  39126. script.src = this.options.authEndpoint +
  39127. '?callback=' +
  39128. encodeURIComponent(callback_name) +
  39129. '&' +
  39130. this.composeQuery(socketId);
  39131. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  39132. head.insertBefore(script, head.firstChild);
  39133. };
  39134. /* harmony default export */ var jsonp_auth = (jsonp);
  39135. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  39136. var ScriptRequest = (function () {
  39137. function ScriptRequest(src) {
  39138. this.src = src;
  39139. }
  39140. ScriptRequest.prototype.send = function (receiver) {
  39141. var self = this;
  39142. var errorString = "Error loading " + self.src;
  39143. self.script = document.createElement("script");
  39144. self.script.id = receiver.id;
  39145. self.script.src = self.src;
  39146. self.script.type = "text/javascript";
  39147. self.script.charset = "UTF-8";
  39148. if (self.script.addEventListener) {
  39149. self.script.onerror = function () {
  39150. receiver.callback(errorString);
  39151. };
  39152. self.script.onload = function () {
  39153. receiver.callback(null);
  39154. };
  39155. }
  39156. else {
  39157. self.script.onreadystatechange = function () {
  39158. if (self.script.readyState === 'loaded' ||
  39159. self.script.readyState === 'complete') {
  39160. receiver.callback(null);
  39161. }
  39162. };
  39163. }
  39164. if (self.script.async === undefined && document.attachEvent &&
  39165. /opera/i.test(navigator.userAgent)) {
  39166. self.errorScript = document.createElement("script");
  39167. self.errorScript.id = receiver.id + "_error";
  39168. self.errorScript.text = receiver.name + "('" + errorString + "');";
  39169. self.script.async = self.errorScript.async = false;
  39170. }
  39171. else {
  39172. self.script.async = true;
  39173. }
  39174. var head = document.getElementsByTagName('head')[0];
  39175. head.insertBefore(self.script, head.firstChild);
  39176. if (self.errorScript) {
  39177. head.insertBefore(self.errorScript, self.script.nextSibling);
  39178. }
  39179. };
  39180. ScriptRequest.prototype.cleanup = function () {
  39181. if (this.script) {
  39182. this.script.onload = this.script.onerror = null;
  39183. this.script.onreadystatechange = null;
  39184. }
  39185. if (this.script && this.script.parentNode) {
  39186. this.script.parentNode.removeChild(this.script);
  39187. }
  39188. if (this.errorScript && this.errorScript.parentNode) {
  39189. this.errorScript.parentNode.removeChild(this.errorScript);
  39190. }
  39191. this.script = null;
  39192. this.errorScript = null;
  39193. };
  39194. return ScriptRequest;
  39195. }());
  39196. /* harmony default export */ var script_request = (ScriptRequest);
  39197. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  39198. var jsonp_request_JSONPRequest = (function () {
  39199. function JSONPRequest(url, data) {
  39200. this.url = url;
  39201. this.data = data;
  39202. }
  39203. JSONPRequest.prototype.send = function (receiver) {
  39204. if (this.request) {
  39205. return;
  39206. }
  39207. var query = buildQueryString(this.data);
  39208. var url = this.url + "/" + receiver.number + "?" + query;
  39209. this.request = runtime.createScriptRequest(url);
  39210. this.request.send(receiver);
  39211. };
  39212. JSONPRequest.prototype.cleanup = function () {
  39213. if (this.request) {
  39214. this.request.cleanup();
  39215. }
  39216. };
  39217. return JSONPRequest;
  39218. }());
  39219. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  39220. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  39221. var getAgent = function (sender, useTLS) {
  39222. return function (data, callback) {
  39223. var scheme = "http" + (useTLS ? "s" : "") + "://";
  39224. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  39225. var request = runtime.createJSONPRequest(url, data);
  39226. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  39227. ScriptReceivers.remove(receiver);
  39228. request.cleanup();
  39229. if (result && result.host) {
  39230. sender.host = result.host;
  39231. }
  39232. if (callback) {
  39233. callback(error, result);
  39234. }
  39235. });
  39236. request.send(receiver);
  39237. };
  39238. };
  39239. var jsonp_timeline_jsonp = {
  39240. name: 'jsonp',
  39241. getAgent: getAgent
  39242. };
  39243. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  39244. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  39245. function getGenericURL(baseScheme, params, path) {
  39246. var scheme = baseScheme + (params.useTLS ? "s" : "");
  39247. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  39248. return scheme + "://" + host + path;
  39249. }
  39250. function getGenericPath(key, queryString) {
  39251. var path = "/app/" + key;
  39252. var query = "?protocol=" + defaults.PROTOCOL +
  39253. "&client=js" +
  39254. "&version=" + defaults.VERSION +
  39255. (queryString ? ("&" + queryString) : "");
  39256. return path + query;
  39257. }
  39258. var ws = {
  39259. getInitial: function (key, params) {
  39260. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  39261. return getGenericURL("ws", params, path);
  39262. }
  39263. };
  39264. var http = {
  39265. getInitial: function (key, params) {
  39266. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  39267. return getGenericURL("http", params, path);
  39268. }
  39269. };
  39270. var sockjs = {
  39271. getInitial: function (key, params) {
  39272. return getGenericURL("http", params, params.httpPath || "/pusher");
  39273. },
  39274. getPath: function (key, params) {
  39275. return getGenericPath(key);
  39276. }
  39277. };
  39278. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  39279. var callback_registry_CallbackRegistry = (function () {
  39280. function CallbackRegistry() {
  39281. this._callbacks = {};
  39282. }
  39283. CallbackRegistry.prototype.get = function (name) {
  39284. return this._callbacks[prefix(name)];
  39285. };
  39286. CallbackRegistry.prototype.add = function (name, callback, context) {
  39287. var prefixedEventName = prefix(name);
  39288. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  39289. this._callbacks[prefixedEventName].push({
  39290. fn: callback,
  39291. context: context
  39292. });
  39293. };
  39294. CallbackRegistry.prototype.remove = function (name, callback, context) {
  39295. if (!name && !callback && !context) {
  39296. this._callbacks = {};
  39297. return;
  39298. }
  39299. var names = name ? [prefix(name)] : keys(this._callbacks);
  39300. if (callback || context) {
  39301. this.removeCallback(names, callback, context);
  39302. }
  39303. else {
  39304. this.removeAllCallbacks(names);
  39305. }
  39306. };
  39307. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  39308. apply(names, function (name) {
  39309. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  39310. return (callback && callback !== binding.fn) ||
  39311. (context && context !== binding.context);
  39312. });
  39313. if (this._callbacks[name].length === 0) {
  39314. delete this._callbacks[name];
  39315. }
  39316. }, this);
  39317. };
  39318. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  39319. apply(names, function (name) {
  39320. delete this._callbacks[name];
  39321. }, this);
  39322. };
  39323. return CallbackRegistry;
  39324. }());
  39325. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  39326. function prefix(name) {
  39327. return "_" + name;
  39328. }
  39329. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  39330. var dispatcher_Dispatcher = (function () {
  39331. function Dispatcher(failThrough) {
  39332. this.callbacks = new callback_registry();
  39333. this.global_callbacks = [];
  39334. this.failThrough = failThrough;
  39335. }
  39336. Dispatcher.prototype.bind = function (eventName, callback, context) {
  39337. this.callbacks.add(eventName, callback, context);
  39338. return this;
  39339. };
  39340. Dispatcher.prototype.bind_global = function (callback) {
  39341. this.global_callbacks.push(callback);
  39342. return this;
  39343. };
  39344. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  39345. this.callbacks.remove(eventName, callback, context);
  39346. return this;
  39347. };
  39348. Dispatcher.prototype.unbind_global = function (callback) {
  39349. if (!callback) {
  39350. this.global_callbacks = [];
  39351. return this;
  39352. }
  39353. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  39354. return this;
  39355. };
  39356. Dispatcher.prototype.unbind_all = function () {
  39357. this.unbind();
  39358. this.unbind_global();
  39359. return this;
  39360. };
  39361. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  39362. for (var i = 0; i < this.global_callbacks.length; i++) {
  39363. this.global_callbacks[i](eventName, data);
  39364. }
  39365. var callbacks = this.callbacks.get(eventName);
  39366. var args = [];
  39367. if (metadata) {
  39368. args.push(data, metadata);
  39369. }
  39370. else if (data) {
  39371. args.push(data);
  39372. }
  39373. if (callbacks && callbacks.length > 0) {
  39374. for (var i = 0; i < callbacks.length; i++) {
  39375. callbacks[i].fn.apply(callbacks[i].context || window, args);
  39376. }
  39377. }
  39378. else if (this.failThrough) {
  39379. this.failThrough(eventName, data);
  39380. }
  39381. return this;
  39382. };
  39383. return Dispatcher;
  39384. }());
  39385. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  39386. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  39387. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  39388. var extendStatics = function (d, b) {
  39389. extendStatics = Object.setPrototypeOf ||
  39390. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39391. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39392. return extendStatics(d, b);
  39393. };
  39394. return function (d, b) {
  39395. extendStatics(d, b);
  39396. function __() { this.constructor = d; }
  39397. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39398. };
  39399. })();
  39400. var transport_connection_TransportConnection = (function (_super) {
  39401. transport_connection_extends(TransportConnection, _super);
  39402. function TransportConnection(hooks, name, priority, key, options) {
  39403. var _this = _super.call(this) || this;
  39404. _this.initialize = runtime.transportConnectionInitializer;
  39405. _this.hooks = hooks;
  39406. _this.name = name;
  39407. _this.priority = priority;
  39408. _this.key = key;
  39409. _this.options = options;
  39410. _this.state = "new";
  39411. _this.timeline = options.timeline;
  39412. _this.activityTimeout = options.activityTimeout;
  39413. _this.id = _this.timeline.generateUniqueID();
  39414. return _this;
  39415. }
  39416. TransportConnection.prototype.handlesActivityChecks = function () {
  39417. return Boolean(this.hooks.handlesActivityChecks);
  39418. };
  39419. TransportConnection.prototype.supportsPing = function () {
  39420. return Boolean(this.hooks.supportsPing);
  39421. };
  39422. TransportConnection.prototype.connect = function () {
  39423. var _this = this;
  39424. if (this.socket || this.state !== "initialized") {
  39425. return false;
  39426. }
  39427. var url = this.hooks.urls.getInitial(this.key, this.options);
  39428. try {
  39429. this.socket = this.hooks.getSocket(url, this.options);
  39430. }
  39431. catch (e) {
  39432. util.defer(function () {
  39433. _this.onError(e);
  39434. _this.changeState("closed");
  39435. });
  39436. return false;
  39437. }
  39438. this.bindListeners();
  39439. logger.debug("Connecting", { transport: this.name, url: url });
  39440. this.changeState("connecting");
  39441. return true;
  39442. };
  39443. TransportConnection.prototype.close = function () {
  39444. if (this.socket) {
  39445. this.socket.close();
  39446. return true;
  39447. }
  39448. else {
  39449. return false;
  39450. }
  39451. };
  39452. TransportConnection.prototype.send = function (data) {
  39453. var _this = this;
  39454. if (this.state === "open") {
  39455. util.defer(function () {
  39456. if (_this.socket) {
  39457. _this.socket.send(data);
  39458. }
  39459. });
  39460. return true;
  39461. }
  39462. else {
  39463. return false;
  39464. }
  39465. };
  39466. TransportConnection.prototype.ping = function () {
  39467. if (this.state === "open" && this.supportsPing()) {
  39468. this.socket.ping();
  39469. }
  39470. };
  39471. TransportConnection.prototype.onOpen = function () {
  39472. if (this.hooks.beforeOpen) {
  39473. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  39474. }
  39475. this.changeState("open");
  39476. this.socket.onopen = undefined;
  39477. };
  39478. TransportConnection.prototype.onError = function (error) {
  39479. this.emit("error", { type: 'WebSocketError', error: error });
  39480. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  39481. };
  39482. TransportConnection.prototype.onClose = function (closeEvent) {
  39483. if (closeEvent) {
  39484. this.changeState("closed", {
  39485. code: closeEvent.code,
  39486. reason: closeEvent.reason,
  39487. wasClean: closeEvent.wasClean
  39488. });
  39489. }
  39490. else {
  39491. this.changeState("closed");
  39492. }
  39493. this.unbindListeners();
  39494. this.socket = undefined;
  39495. };
  39496. TransportConnection.prototype.onMessage = function (message) {
  39497. this.emit("message", message);
  39498. };
  39499. TransportConnection.prototype.onActivity = function () {
  39500. this.emit("activity");
  39501. };
  39502. TransportConnection.prototype.bindListeners = function () {
  39503. var _this = this;
  39504. this.socket.onopen = function () {
  39505. _this.onOpen();
  39506. };
  39507. this.socket.onerror = function (error) {
  39508. _this.onError(error);
  39509. };
  39510. this.socket.onclose = function (closeEvent) {
  39511. _this.onClose(closeEvent);
  39512. };
  39513. this.socket.onmessage = function (message) {
  39514. _this.onMessage(message);
  39515. };
  39516. if (this.supportsPing()) {
  39517. this.socket.onactivity = function () { _this.onActivity(); };
  39518. }
  39519. };
  39520. TransportConnection.prototype.unbindListeners = function () {
  39521. if (this.socket) {
  39522. this.socket.onopen = undefined;
  39523. this.socket.onerror = undefined;
  39524. this.socket.onclose = undefined;
  39525. this.socket.onmessage = undefined;
  39526. if (this.supportsPing()) {
  39527. this.socket.onactivity = undefined;
  39528. }
  39529. }
  39530. };
  39531. TransportConnection.prototype.changeState = function (state, params) {
  39532. this.state = state;
  39533. this.timeline.info(this.buildTimelineMessage({
  39534. state: state,
  39535. params: params
  39536. }));
  39537. this.emit(state, params);
  39538. };
  39539. TransportConnection.prototype.buildTimelineMessage = function (message) {
  39540. return extend({ cid: this.id }, message);
  39541. };
  39542. return TransportConnection;
  39543. }(dispatcher));
  39544. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  39545. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  39546. var transport_Transport = (function () {
  39547. function Transport(hooks) {
  39548. this.hooks = hooks;
  39549. }
  39550. Transport.prototype.isSupported = function (environment) {
  39551. return this.hooks.isSupported(environment);
  39552. };
  39553. Transport.prototype.createConnection = function (name, priority, key, options) {
  39554. return new transport_connection(this.hooks, name, priority, key, options);
  39555. };
  39556. return Transport;
  39557. }());
  39558. /* harmony default export */ var transports_transport = (transport_Transport);
  39559. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  39560. var WSTransport = new transports_transport({
  39561. urls: ws,
  39562. handlesActivityChecks: false,
  39563. supportsPing: false,
  39564. isInitialized: function () {
  39565. return Boolean(runtime.getWebSocketAPI());
  39566. },
  39567. isSupported: function () {
  39568. return Boolean(runtime.getWebSocketAPI());
  39569. },
  39570. getSocket: function (url) {
  39571. return runtime.createWebSocket(url);
  39572. }
  39573. });
  39574. var httpConfiguration = {
  39575. urls: http,
  39576. handlesActivityChecks: false,
  39577. supportsPing: true,
  39578. isInitialized: function () {
  39579. return true;
  39580. }
  39581. };
  39582. var streamingConfiguration = extend({ getSocket: function (url) {
  39583. return runtime.HTTPFactory.createStreamingSocket(url);
  39584. }
  39585. }, httpConfiguration);
  39586. var pollingConfiguration = extend({ getSocket: function (url) {
  39587. return runtime.HTTPFactory.createPollingSocket(url);
  39588. }
  39589. }, httpConfiguration);
  39590. var xhrConfiguration = {
  39591. isSupported: function () {
  39592. return runtime.isXHRSupported();
  39593. }
  39594. };
  39595. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  39596. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  39597. var Transports = {
  39598. ws: WSTransport,
  39599. xhr_streaming: XHRStreamingTransport,
  39600. xhr_polling: XHRPollingTransport
  39601. };
  39602. /* harmony default export */ var transports = (Transports);
  39603. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  39604. var SockJSTransport = new transports_transport({
  39605. file: "sockjs",
  39606. urls: sockjs,
  39607. handlesActivityChecks: true,
  39608. supportsPing: false,
  39609. isSupported: function () {
  39610. return true;
  39611. },
  39612. isInitialized: function () {
  39613. return window.SockJS !== undefined;
  39614. },
  39615. getSocket: function (url, options) {
  39616. return new window.SockJS(url, null, {
  39617. js_path: Dependencies.getPath("sockjs", {
  39618. useTLS: options.useTLS
  39619. }),
  39620. ignore_null_origin: options.ignoreNullOrigin
  39621. });
  39622. },
  39623. beforeOpen: function (socket, path) {
  39624. socket.send(JSON.stringify({
  39625. path: path
  39626. }));
  39627. }
  39628. });
  39629. var xdrConfiguration = {
  39630. isSupported: function (environment) {
  39631. var yes = runtime.isXDRSupported(environment.useTLS);
  39632. return yes;
  39633. }
  39634. };
  39635. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  39636. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  39637. transports.xdr_streaming = XDRStreamingTransport;
  39638. transports.xdr_polling = XDRPollingTransport;
  39639. transports.sockjs = SockJSTransport;
  39640. /* harmony default export */ var transports_transports = (transports);
  39641. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  39642. var net_info_extends = (undefined && undefined.__extends) || (function () {
  39643. var extendStatics = function (d, b) {
  39644. extendStatics = Object.setPrototypeOf ||
  39645. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39646. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39647. return extendStatics(d, b);
  39648. };
  39649. return function (d, b) {
  39650. extendStatics(d, b);
  39651. function __() { this.constructor = d; }
  39652. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39653. };
  39654. })();
  39655. var NetInfo = (function (_super) {
  39656. net_info_extends(NetInfo, _super);
  39657. function NetInfo() {
  39658. var _this = _super.call(this) || this;
  39659. var self = _this;
  39660. if (window.addEventListener !== undefined) {
  39661. window.addEventListener("online", function () {
  39662. self.emit('online');
  39663. }, false);
  39664. window.addEventListener("offline", function () {
  39665. self.emit('offline');
  39666. }, false);
  39667. }
  39668. return _this;
  39669. }
  39670. NetInfo.prototype.isOnline = function () {
  39671. if (window.navigator.onLine === undefined) {
  39672. return true;
  39673. }
  39674. else {
  39675. return window.navigator.onLine;
  39676. }
  39677. };
  39678. return NetInfo;
  39679. }(dispatcher));
  39680. var net_info_Network = new NetInfo();
  39681. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  39682. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  39683. function AssistantToTheTransportManager(manager, transport, options) {
  39684. this.manager = manager;
  39685. this.transport = transport;
  39686. this.minPingDelay = options.minPingDelay;
  39687. this.maxPingDelay = options.maxPingDelay;
  39688. this.pingDelay = undefined;
  39689. }
  39690. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  39691. var _this = this;
  39692. options = extend({}, options, {
  39693. activityTimeout: this.pingDelay
  39694. });
  39695. var connection = this.transport.createConnection(name, priority, key, options);
  39696. var openTimestamp = null;
  39697. var onOpen = function () {
  39698. connection.unbind("open", onOpen);
  39699. connection.bind("closed", onClosed);
  39700. openTimestamp = util.now();
  39701. };
  39702. var onClosed = function (closeEvent) {
  39703. connection.unbind("closed", onClosed);
  39704. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  39705. _this.manager.reportDeath();
  39706. }
  39707. else if (!closeEvent.wasClean && openTimestamp) {
  39708. var lifespan = util.now() - openTimestamp;
  39709. if (lifespan < 2 * _this.maxPingDelay) {
  39710. _this.manager.reportDeath();
  39711. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  39712. }
  39713. }
  39714. };
  39715. connection.bind("open", onOpen);
  39716. return connection;
  39717. };
  39718. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  39719. return this.manager.isAlive() && this.transport.isSupported(environment);
  39720. };
  39721. return AssistantToTheTransportManager;
  39722. }());
  39723. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  39724. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  39725. var Protocol = {
  39726. decodeMessage: function (messageEvent) {
  39727. try {
  39728. var messageData = JSON.parse(messageEvent.data);
  39729. var pusherEventData = messageData.data;
  39730. if (typeof pusherEventData === 'string') {
  39731. try {
  39732. pusherEventData = JSON.parse(messageData.data);
  39733. }
  39734. catch (e) { }
  39735. }
  39736. var pusherEvent = {
  39737. event: messageData.event,
  39738. channel: messageData.channel,
  39739. data: pusherEventData,
  39740. };
  39741. if (messageData.user_id) {
  39742. pusherEvent.user_id = messageData.user_id;
  39743. }
  39744. return pusherEvent;
  39745. }
  39746. catch (e) {
  39747. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  39748. }
  39749. },
  39750. encodeMessage: function (event) {
  39751. return JSON.stringify(event);
  39752. },
  39753. processHandshake: function (messageEvent) {
  39754. var message = Protocol.decodeMessage(messageEvent);
  39755. if (message.event === "pusher:connection_established") {
  39756. if (!message.data.activity_timeout) {
  39757. throw "No activity timeout specified in handshake";
  39758. }
  39759. return {
  39760. action: "connected",
  39761. id: message.data.socket_id,
  39762. activityTimeout: message.data.activity_timeout * 1000
  39763. };
  39764. }
  39765. else if (message.event === "pusher:error") {
  39766. return {
  39767. action: this.getCloseAction(message.data),
  39768. error: this.getCloseError(message.data)
  39769. };
  39770. }
  39771. else {
  39772. throw "Invalid handshake";
  39773. }
  39774. },
  39775. getCloseAction: function (closeEvent) {
  39776. if (closeEvent.code < 4000) {
  39777. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  39778. return "backoff";
  39779. }
  39780. else {
  39781. return null;
  39782. }
  39783. }
  39784. else if (closeEvent.code === 4000) {
  39785. return "tls_only";
  39786. }
  39787. else if (closeEvent.code < 4100) {
  39788. return "refused";
  39789. }
  39790. else if (closeEvent.code < 4200) {
  39791. return "backoff";
  39792. }
  39793. else if (closeEvent.code < 4300) {
  39794. return "retry";
  39795. }
  39796. else {
  39797. return "refused";
  39798. }
  39799. },
  39800. getCloseError: function (closeEvent) {
  39801. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  39802. return {
  39803. type: 'PusherError',
  39804. data: {
  39805. code: closeEvent.code,
  39806. message: closeEvent.reason || closeEvent.message
  39807. }
  39808. };
  39809. }
  39810. else {
  39811. return null;
  39812. }
  39813. }
  39814. };
  39815. /* harmony default export */ var protocol_protocol = (Protocol);
  39816. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  39817. var connection_extends = (undefined && undefined.__extends) || (function () {
  39818. var extendStatics = function (d, b) {
  39819. extendStatics = Object.setPrototypeOf ||
  39820. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39821. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39822. return extendStatics(d, b);
  39823. };
  39824. return function (d, b) {
  39825. extendStatics(d, b);
  39826. function __() { this.constructor = d; }
  39827. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39828. };
  39829. })();
  39830. var connection_Connection = (function (_super) {
  39831. connection_extends(Connection, _super);
  39832. function Connection(id, transport) {
  39833. var _this = _super.call(this) || this;
  39834. _this.id = id;
  39835. _this.transport = transport;
  39836. _this.activityTimeout = transport.activityTimeout;
  39837. _this.bindListeners();
  39838. return _this;
  39839. }
  39840. Connection.prototype.handlesActivityChecks = function () {
  39841. return this.transport.handlesActivityChecks();
  39842. };
  39843. Connection.prototype.send = function (data) {
  39844. return this.transport.send(data);
  39845. };
  39846. Connection.prototype.send_event = function (name, data, channel) {
  39847. var event = { event: name, data: data };
  39848. if (channel) {
  39849. event.channel = channel;
  39850. }
  39851. logger.debug('Event sent', event);
  39852. return this.send(protocol_protocol.encodeMessage(event));
  39853. };
  39854. Connection.prototype.ping = function () {
  39855. if (this.transport.supportsPing()) {
  39856. this.transport.ping();
  39857. }
  39858. else {
  39859. this.send_event('pusher:ping', {});
  39860. }
  39861. };
  39862. Connection.prototype.close = function () {
  39863. this.transport.close();
  39864. };
  39865. Connection.prototype.bindListeners = function () {
  39866. var _this = this;
  39867. var listeners = {
  39868. message: function (messageEvent) {
  39869. var pusherEvent;
  39870. try {
  39871. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  39872. }
  39873. catch (e) {
  39874. _this.emit('error', {
  39875. type: 'MessageParseError',
  39876. error: e,
  39877. data: messageEvent.data
  39878. });
  39879. }
  39880. if (pusherEvent !== undefined) {
  39881. logger.debug('Event recd', pusherEvent);
  39882. switch (pusherEvent.event) {
  39883. case 'pusher:error':
  39884. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  39885. break;
  39886. case 'pusher:ping':
  39887. _this.emit("ping");
  39888. break;
  39889. case 'pusher:pong':
  39890. _this.emit("pong");
  39891. break;
  39892. }
  39893. _this.emit('message', pusherEvent);
  39894. }
  39895. },
  39896. activity: function () {
  39897. _this.emit("activity");
  39898. },
  39899. error: function (error) {
  39900. _this.emit("error", { type: "WebSocketError", error: error });
  39901. },
  39902. closed: function (closeEvent) {
  39903. unbindListeners();
  39904. if (closeEvent && closeEvent.code) {
  39905. _this.handleCloseEvent(closeEvent);
  39906. }
  39907. _this.transport = null;
  39908. _this.emit("closed");
  39909. }
  39910. };
  39911. var unbindListeners = function () {
  39912. objectApply(listeners, function (listener, event) {
  39913. _this.transport.unbind(event, listener);
  39914. });
  39915. };
  39916. objectApply(listeners, function (listener, event) {
  39917. _this.transport.bind(event, listener);
  39918. });
  39919. };
  39920. Connection.prototype.handleCloseEvent = function (closeEvent) {
  39921. var action = protocol_protocol.getCloseAction(closeEvent);
  39922. var error = protocol_protocol.getCloseError(closeEvent);
  39923. if (error) {
  39924. this.emit('error', error);
  39925. }
  39926. if (action) {
  39927. this.emit(action, { action: action, error: error });
  39928. }
  39929. };
  39930. return Connection;
  39931. }(dispatcher));
  39932. /* harmony default export */ var connection_connection = (connection_Connection);
  39933. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  39934. var handshake_Handshake = (function () {
  39935. function Handshake(transport, callback) {
  39936. this.transport = transport;
  39937. this.callback = callback;
  39938. this.bindListeners();
  39939. }
  39940. Handshake.prototype.close = function () {
  39941. this.unbindListeners();
  39942. this.transport.close();
  39943. };
  39944. Handshake.prototype.bindListeners = function () {
  39945. var _this = this;
  39946. this.onMessage = function (m) {
  39947. _this.unbindListeners();
  39948. var result;
  39949. try {
  39950. result = protocol_protocol.processHandshake(m);
  39951. }
  39952. catch (e) {
  39953. _this.finish("error", { error: e });
  39954. _this.transport.close();
  39955. return;
  39956. }
  39957. if (result.action === "connected") {
  39958. _this.finish("connected", {
  39959. connection: new connection_connection(result.id, _this.transport),
  39960. activityTimeout: result.activityTimeout
  39961. });
  39962. }
  39963. else {
  39964. _this.finish(result.action, { error: result.error });
  39965. _this.transport.close();
  39966. }
  39967. };
  39968. this.onClosed = function (closeEvent) {
  39969. _this.unbindListeners();
  39970. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  39971. var error = protocol_protocol.getCloseError(closeEvent);
  39972. _this.finish(action, { error: error });
  39973. };
  39974. this.transport.bind("message", this.onMessage);
  39975. this.transport.bind("closed", this.onClosed);
  39976. };
  39977. Handshake.prototype.unbindListeners = function () {
  39978. this.transport.unbind("message", this.onMessage);
  39979. this.transport.unbind("closed", this.onClosed);
  39980. };
  39981. Handshake.prototype.finish = function (action, params) {
  39982. this.callback(extend({ transport: this.transport, action: action }, params));
  39983. };
  39984. return Handshake;
  39985. }());
  39986. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  39987. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  39988. var pusher_authorizer_PusherAuthorizer = (function () {
  39989. function PusherAuthorizer(channel, options) {
  39990. this.channel = channel;
  39991. var authTransport = options.authTransport;
  39992. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  39993. throw "'" + authTransport + "' is not a recognized auth transport";
  39994. }
  39995. this.type = authTransport;
  39996. this.options = options;
  39997. this.authOptions = (options || {}).auth || {};
  39998. }
  39999. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  40000. var query = 'socket_id=' + encodeURIComponent(socketId) +
  40001. '&channel_name=' + encodeURIComponent(this.channel.name);
  40002. for (var i in this.authOptions.params) {
  40003. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  40004. }
  40005. return query;
  40006. };
  40007. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  40008. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  40009. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  40010. };
  40011. return PusherAuthorizer;
  40012. }());
  40013. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  40014. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  40015. var timeline_sender_TimelineSender = (function () {
  40016. function TimelineSender(timeline, options) {
  40017. this.timeline = timeline;
  40018. this.options = options || {};
  40019. }
  40020. TimelineSender.prototype.send = function (useTLS, callback) {
  40021. if (this.timeline.isEmpty()) {
  40022. return;
  40023. }
  40024. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  40025. };
  40026. return TimelineSender;
  40027. }());
  40028. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  40029. // CONCATENATED MODULE: ./src/core/errors.ts
  40030. var errors_extends = (undefined && undefined.__extends) || (function () {
  40031. var extendStatics = function (d, b) {
  40032. extendStatics = Object.setPrototypeOf ||
  40033. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40034. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40035. return extendStatics(d, b);
  40036. };
  40037. return function (d, b) {
  40038. extendStatics(d, b);
  40039. function __() { this.constructor = d; }
  40040. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40041. };
  40042. })();
  40043. var BadEventName = (function (_super) {
  40044. errors_extends(BadEventName, _super);
  40045. function BadEventName(msg) {
  40046. var _newTarget = this.constructor;
  40047. var _this = _super.call(this, msg) || this;
  40048. Object.setPrototypeOf(_this, _newTarget.prototype);
  40049. return _this;
  40050. }
  40051. return BadEventName;
  40052. }(Error));
  40053. var RequestTimedOut = (function (_super) {
  40054. errors_extends(RequestTimedOut, _super);
  40055. function RequestTimedOut(msg) {
  40056. var _newTarget = this.constructor;
  40057. var _this = _super.call(this, msg) || this;
  40058. Object.setPrototypeOf(_this, _newTarget.prototype);
  40059. return _this;
  40060. }
  40061. return RequestTimedOut;
  40062. }(Error));
  40063. var TransportPriorityTooLow = (function (_super) {
  40064. errors_extends(TransportPriorityTooLow, _super);
  40065. function TransportPriorityTooLow(msg) {
  40066. var _newTarget = this.constructor;
  40067. var _this = _super.call(this, msg) || this;
  40068. Object.setPrototypeOf(_this, _newTarget.prototype);
  40069. return _this;
  40070. }
  40071. return TransportPriorityTooLow;
  40072. }(Error));
  40073. var TransportClosed = (function (_super) {
  40074. errors_extends(TransportClosed, _super);
  40075. function TransportClosed(msg) {
  40076. var _newTarget = this.constructor;
  40077. var _this = _super.call(this, msg) || this;
  40078. Object.setPrototypeOf(_this, _newTarget.prototype);
  40079. return _this;
  40080. }
  40081. return TransportClosed;
  40082. }(Error));
  40083. var UnsupportedFeature = (function (_super) {
  40084. errors_extends(UnsupportedFeature, _super);
  40085. function UnsupportedFeature(msg) {
  40086. var _newTarget = this.constructor;
  40087. var _this = _super.call(this, msg) || this;
  40088. Object.setPrototypeOf(_this, _newTarget.prototype);
  40089. return _this;
  40090. }
  40091. return UnsupportedFeature;
  40092. }(Error));
  40093. var UnsupportedTransport = (function (_super) {
  40094. errors_extends(UnsupportedTransport, _super);
  40095. function UnsupportedTransport(msg) {
  40096. var _newTarget = this.constructor;
  40097. var _this = _super.call(this, msg) || this;
  40098. Object.setPrototypeOf(_this, _newTarget.prototype);
  40099. return _this;
  40100. }
  40101. return UnsupportedTransport;
  40102. }(Error));
  40103. var UnsupportedStrategy = (function (_super) {
  40104. errors_extends(UnsupportedStrategy, _super);
  40105. function UnsupportedStrategy(msg) {
  40106. var _newTarget = this.constructor;
  40107. var _this = _super.call(this, msg) || this;
  40108. Object.setPrototypeOf(_this, _newTarget.prototype);
  40109. return _this;
  40110. }
  40111. return UnsupportedStrategy;
  40112. }(Error));
  40113. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  40114. var channel_extends = (undefined && undefined.__extends) || (function () {
  40115. var extendStatics = function (d, b) {
  40116. extendStatics = Object.setPrototypeOf ||
  40117. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40118. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40119. return extendStatics(d, b);
  40120. };
  40121. return function (d, b) {
  40122. extendStatics(d, b);
  40123. function __() { this.constructor = d; }
  40124. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40125. };
  40126. })();
  40127. var channel_Channel = (function (_super) {
  40128. channel_extends(Channel, _super);
  40129. function Channel(name, pusher) {
  40130. var _this = _super.call(this, function (event, data) {
  40131. logger.debug('No callbacks on ' + name + ' for ' + event);
  40132. }) || this;
  40133. _this.name = name;
  40134. _this.pusher = pusher;
  40135. _this.subscribed = false;
  40136. _this.subscriptionPending = false;
  40137. _this.subscriptionCancelled = false;
  40138. return _this;
  40139. }
  40140. Channel.prototype.authorize = function (socketId, callback) {
  40141. return callback(false, {});
  40142. };
  40143. Channel.prototype.trigger = function (event, data) {
  40144. if (event.indexOf("client-") !== 0) {
  40145. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  40146. }
  40147. if (!this.subscribed) {
  40148. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  40149. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  40150. }
  40151. return this.pusher.send_event(event, data, this.name);
  40152. };
  40153. Channel.prototype.disconnect = function () {
  40154. this.subscribed = false;
  40155. this.subscriptionPending = false;
  40156. };
  40157. Channel.prototype.handleEvent = function (event) {
  40158. var eventName = event.event;
  40159. var data = event.data;
  40160. if (eventName === "pusher_internal:subscription_succeeded") {
  40161. this.handleSubscriptionSucceededEvent(event);
  40162. }
  40163. else if (eventName.indexOf("pusher_internal:") !== 0) {
  40164. var metadata = {};
  40165. this.emit(eventName, data, metadata);
  40166. }
  40167. };
  40168. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40169. this.subscriptionPending = false;
  40170. this.subscribed = true;
  40171. if (this.subscriptionCancelled) {
  40172. this.pusher.unsubscribe(this.name);
  40173. }
  40174. else {
  40175. this.emit("pusher:subscription_succeeded", event.data);
  40176. }
  40177. };
  40178. Channel.prototype.subscribe = function () {
  40179. var _this = this;
  40180. if (this.subscribed) {
  40181. return;
  40182. }
  40183. this.subscriptionPending = true;
  40184. this.subscriptionCancelled = false;
  40185. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  40186. if (error) {
  40187. logger.error(data);
  40188. _this.emit('pusher:subscription_error', data);
  40189. }
  40190. else {
  40191. _this.pusher.send_event('pusher:subscribe', {
  40192. auth: data.auth,
  40193. channel_data: data.channel_data,
  40194. channel: _this.name
  40195. });
  40196. }
  40197. });
  40198. };
  40199. Channel.prototype.unsubscribe = function () {
  40200. this.subscribed = false;
  40201. this.pusher.send_event('pusher:unsubscribe', {
  40202. channel: this.name
  40203. });
  40204. };
  40205. Channel.prototype.cancelSubscription = function () {
  40206. this.subscriptionCancelled = true;
  40207. };
  40208. Channel.prototype.reinstateSubscription = function () {
  40209. this.subscriptionCancelled = false;
  40210. };
  40211. return Channel;
  40212. }(dispatcher));
  40213. /* harmony default export */ var channels_channel = (channel_Channel);
  40214. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  40215. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  40216. var extendStatics = function (d, b) {
  40217. extendStatics = Object.setPrototypeOf ||
  40218. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40219. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40220. return extendStatics(d, b);
  40221. };
  40222. return function (d, b) {
  40223. extendStatics(d, b);
  40224. function __() { this.constructor = d; }
  40225. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40226. };
  40227. })();
  40228. var private_channel_PrivateChannel = (function (_super) {
  40229. private_channel_extends(PrivateChannel, _super);
  40230. function PrivateChannel() {
  40231. return _super !== null && _super.apply(this, arguments) || this;
  40232. }
  40233. PrivateChannel.prototype.authorize = function (socketId, callback) {
  40234. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  40235. return authorizer.authorize(socketId, callback);
  40236. };
  40237. return PrivateChannel;
  40238. }(channels_channel));
  40239. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  40240. // CONCATENATED MODULE: ./src/core/channels/members.ts
  40241. var members_Members = (function () {
  40242. function Members() {
  40243. this.reset();
  40244. }
  40245. Members.prototype.get = function (id) {
  40246. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  40247. return {
  40248. id: id,
  40249. info: this.members[id]
  40250. };
  40251. }
  40252. else {
  40253. return null;
  40254. }
  40255. };
  40256. Members.prototype.each = function (callback) {
  40257. var _this = this;
  40258. objectApply(this.members, function (member, id) {
  40259. callback(_this.get(id));
  40260. });
  40261. };
  40262. Members.prototype.setMyID = function (id) {
  40263. this.myID = id;
  40264. };
  40265. Members.prototype.onSubscription = function (subscriptionData) {
  40266. this.members = subscriptionData.presence.hash;
  40267. this.count = subscriptionData.presence.count;
  40268. this.me = this.get(this.myID);
  40269. };
  40270. Members.prototype.addMember = function (memberData) {
  40271. if (this.get(memberData.user_id) === null) {
  40272. this.count++;
  40273. }
  40274. this.members[memberData.user_id] = memberData.user_info;
  40275. return this.get(memberData.user_id);
  40276. };
  40277. Members.prototype.removeMember = function (memberData) {
  40278. var member = this.get(memberData.user_id);
  40279. if (member) {
  40280. delete this.members[memberData.user_id];
  40281. this.count--;
  40282. }
  40283. return member;
  40284. };
  40285. Members.prototype.reset = function () {
  40286. this.members = {};
  40287. this.count = 0;
  40288. this.myID = null;
  40289. this.me = null;
  40290. };
  40291. return Members;
  40292. }());
  40293. /* harmony default export */ var members = (members_Members);
  40294. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  40295. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  40296. var extendStatics = function (d, b) {
  40297. extendStatics = Object.setPrototypeOf ||
  40298. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40299. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40300. return extendStatics(d, b);
  40301. };
  40302. return function (d, b) {
  40303. extendStatics(d, b);
  40304. function __() { this.constructor = d; }
  40305. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40306. };
  40307. })();
  40308. var presence_channel_PresenceChannel = (function (_super) {
  40309. presence_channel_extends(PresenceChannel, _super);
  40310. function PresenceChannel(name, pusher) {
  40311. var _this = _super.call(this, name, pusher) || this;
  40312. _this.members = new members();
  40313. return _this;
  40314. }
  40315. PresenceChannel.prototype.authorize = function (socketId, callback) {
  40316. var _this = this;
  40317. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40318. if (!error) {
  40319. if (authData.channel_data === undefined) {
  40320. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  40321. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  40322. ("expected 'channel_data' field. " + suffix));
  40323. callback("Invalid auth response");
  40324. return;
  40325. }
  40326. var channelData = JSON.parse(authData.channel_data);
  40327. _this.members.setMyID(channelData.user_id);
  40328. }
  40329. callback(error, authData);
  40330. });
  40331. };
  40332. PresenceChannel.prototype.handleEvent = function (event) {
  40333. var eventName = event.event;
  40334. if (eventName.indexOf("pusher_internal:") === 0) {
  40335. this.handleInternalEvent(event);
  40336. }
  40337. else {
  40338. var data = event.data;
  40339. var metadata = {};
  40340. if (event.user_id) {
  40341. metadata.user_id = event.user_id;
  40342. }
  40343. this.emit(eventName, data, metadata);
  40344. }
  40345. };
  40346. PresenceChannel.prototype.handleInternalEvent = function (event) {
  40347. var eventName = event.event;
  40348. var data = event.data;
  40349. switch (eventName) {
  40350. case "pusher_internal:subscription_succeeded":
  40351. this.handleSubscriptionSucceededEvent(event);
  40352. break;
  40353. case "pusher_internal:member_added":
  40354. var addedMember = this.members.addMember(data);
  40355. this.emit('pusher:member_added', addedMember);
  40356. break;
  40357. case "pusher_internal:member_removed":
  40358. var removedMember = this.members.removeMember(data);
  40359. if (removedMember) {
  40360. this.emit('pusher:member_removed', removedMember);
  40361. }
  40362. break;
  40363. }
  40364. };
  40365. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40366. this.subscriptionPending = false;
  40367. this.subscribed = true;
  40368. if (this.subscriptionCancelled) {
  40369. this.pusher.unsubscribe(this.name);
  40370. }
  40371. else {
  40372. this.members.onSubscription(event.data);
  40373. this.emit("pusher:subscription_succeeded", this.members);
  40374. }
  40375. };
  40376. PresenceChannel.prototype.disconnect = function () {
  40377. this.members.reset();
  40378. _super.prototype.disconnect.call(this);
  40379. };
  40380. return PresenceChannel;
  40381. }(private_channel));
  40382. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  40383. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  40384. var nacl_fast = __webpack_require__(0);
  40385. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  40386. var nacl_util = __webpack_require__(1);
  40387. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  40388. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  40389. var extendStatics = function (d, b) {
  40390. extendStatics = Object.setPrototypeOf ||
  40391. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40392. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40393. return extendStatics(d, b);
  40394. };
  40395. return function (d, b) {
  40396. extendStatics(d, b);
  40397. function __() { this.constructor = d; }
  40398. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40399. };
  40400. })();
  40401. var encrypted_channel_EncryptedChannel = (function (_super) {
  40402. encrypted_channel_extends(EncryptedChannel, _super);
  40403. function EncryptedChannel() {
  40404. var _this = _super !== null && _super.apply(this, arguments) || this;
  40405. _this.key = null;
  40406. return _this;
  40407. }
  40408. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  40409. var _this = this;
  40410. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40411. if (error) {
  40412. callback(true, authData);
  40413. return;
  40414. }
  40415. var sharedSecret = authData["shared_secret"];
  40416. if (!sharedSecret) {
  40417. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  40418. callback(true, errorMsg);
  40419. return;
  40420. }
  40421. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  40422. delete authData["shared_secret"];
  40423. callback(false, authData);
  40424. });
  40425. };
  40426. EncryptedChannel.prototype.trigger = function (event, data) {
  40427. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  40428. };
  40429. EncryptedChannel.prototype.handleEvent = function (event) {
  40430. var eventName = event.event;
  40431. var data = event.data;
  40432. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  40433. _super.prototype.handleEvent.call(this, event);
  40434. return;
  40435. }
  40436. this.handleEncryptedEvent(eventName, data);
  40437. };
  40438. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  40439. var _this = this;
  40440. if (!this.key) {
  40441. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  40442. return;
  40443. }
  40444. if (!data.ciphertext || !data.nonce) {
  40445. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  40446. return;
  40447. }
  40448. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  40449. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  40450. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  40451. return;
  40452. }
  40453. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  40454. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  40455. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  40456. return;
  40457. }
  40458. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  40459. if (bytes === null) {
  40460. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  40461. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  40462. if (error) {
  40463. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  40464. return;
  40465. }
  40466. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  40467. if (bytes === null) {
  40468. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  40469. return;
  40470. }
  40471. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40472. return;
  40473. });
  40474. return;
  40475. }
  40476. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40477. };
  40478. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  40479. try {
  40480. this.emit(eventName, JSON.parse(data));
  40481. }
  40482. catch (e) {
  40483. this.emit(eventName, data);
  40484. }
  40485. return this;
  40486. };
  40487. return EncryptedChannel;
  40488. }(private_channel));
  40489. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  40490. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  40491. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  40492. var extendStatics = function (d, b) {
  40493. extendStatics = Object.setPrototypeOf ||
  40494. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40495. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40496. return extendStatics(d, b);
  40497. };
  40498. return function (d, b) {
  40499. extendStatics(d, b);
  40500. function __() { this.constructor = d; }
  40501. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40502. };
  40503. })();
  40504. var connection_manager_ConnectionManager = (function (_super) {
  40505. connection_manager_extends(ConnectionManager, _super);
  40506. function ConnectionManager(key, options) {
  40507. var _this = _super.call(this) || this;
  40508. _this.key = key;
  40509. _this.options = options || {};
  40510. _this.state = "initialized";
  40511. _this.connection = null;
  40512. _this.usingTLS = !!options.useTLS;
  40513. _this.timeline = _this.options.timeline;
  40514. _this.errorCallbacks = _this.buildErrorCallbacks();
  40515. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  40516. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  40517. var Network = runtime.getNetwork();
  40518. Network.bind("online", function () {
  40519. _this.timeline.info({ netinfo: "online" });
  40520. if (_this.state === "connecting" || _this.state === "unavailable") {
  40521. _this.retryIn(0);
  40522. }
  40523. });
  40524. Network.bind("offline", function () {
  40525. _this.timeline.info({ netinfo: "offline" });
  40526. if (_this.connection) {
  40527. _this.sendActivityCheck();
  40528. }
  40529. });
  40530. _this.updateStrategy();
  40531. return _this;
  40532. }
  40533. ConnectionManager.prototype.connect = function () {
  40534. if (this.connection || this.runner) {
  40535. return;
  40536. }
  40537. if (!this.strategy.isSupported()) {
  40538. this.updateState("failed");
  40539. return;
  40540. }
  40541. this.updateState("connecting");
  40542. this.startConnecting();
  40543. this.setUnavailableTimer();
  40544. };
  40545. ;
  40546. ConnectionManager.prototype.send = function (data) {
  40547. if (this.connection) {
  40548. return this.connection.send(data);
  40549. }
  40550. else {
  40551. return false;
  40552. }
  40553. };
  40554. ;
  40555. ConnectionManager.prototype.send_event = function (name, data, channel) {
  40556. if (this.connection) {
  40557. return this.connection.send_event(name, data, channel);
  40558. }
  40559. else {
  40560. return false;
  40561. }
  40562. };
  40563. ;
  40564. ConnectionManager.prototype.disconnect = function () {
  40565. this.disconnectInternally();
  40566. this.updateState("disconnected");
  40567. };
  40568. ;
  40569. ConnectionManager.prototype.isUsingTLS = function () {
  40570. return this.usingTLS;
  40571. };
  40572. ;
  40573. ConnectionManager.prototype.startConnecting = function () {
  40574. var _this = this;
  40575. var callback = function (error, handshake) {
  40576. if (error) {
  40577. _this.runner = _this.strategy.connect(0, callback);
  40578. }
  40579. else {
  40580. if (handshake.action === "error") {
  40581. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  40582. _this.timeline.error({ handshakeError: handshake.error });
  40583. }
  40584. else {
  40585. _this.abortConnecting();
  40586. _this.handshakeCallbacks[handshake.action](handshake);
  40587. }
  40588. }
  40589. };
  40590. this.runner = this.strategy.connect(0, callback);
  40591. };
  40592. ;
  40593. ConnectionManager.prototype.abortConnecting = function () {
  40594. if (this.runner) {
  40595. this.runner.abort();
  40596. this.runner = null;
  40597. }
  40598. };
  40599. ;
  40600. ConnectionManager.prototype.disconnectInternally = function () {
  40601. this.abortConnecting();
  40602. this.clearRetryTimer();
  40603. this.clearUnavailableTimer();
  40604. if (this.connection) {
  40605. var connection = this.abandonConnection();
  40606. connection.close();
  40607. }
  40608. };
  40609. ;
  40610. ConnectionManager.prototype.updateStrategy = function () {
  40611. this.strategy = this.options.getStrategy({
  40612. key: this.key,
  40613. timeline: this.timeline,
  40614. useTLS: this.usingTLS
  40615. });
  40616. };
  40617. ;
  40618. ConnectionManager.prototype.retryIn = function (delay) {
  40619. var _this = this;
  40620. this.timeline.info({ action: "retry", delay: delay });
  40621. if (delay > 0) {
  40622. this.emit("connecting_in", Math.round(delay / 1000));
  40623. }
  40624. this.retryTimer = new OneOffTimer(delay || 0, function () {
  40625. _this.disconnectInternally();
  40626. _this.connect();
  40627. });
  40628. };
  40629. ;
  40630. ConnectionManager.prototype.clearRetryTimer = function () {
  40631. if (this.retryTimer) {
  40632. this.retryTimer.ensureAborted();
  40633. this.retryTimer = null;
  40634. }
  40635. };
  40636. ;
  40637. ConnectionManager.prototype.setUnavailableTimer = function () {
  40638. var _this = this;
  40639. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  40640. _this.updateState("unavailable");
  40641. });
  40642. };
  40643. ;
  40644. ConnectionManager.prototype.clearUnavailableTimer = function () {
  40645. if (this.unavailableTimer) {
  40646. this.unavailableTimer.ensureAborted();
  40647. }
  40648. };
  40649. ;
  40650. ConnectionManager.prototype.sendActivityCheck = function () {
  40651. var _this = this;
  40652. this.stopActivityCheck();
  40653. this.connection.ping();
  40654. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  40655. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  40656. _this.retryIn(0);
  40657. });
  40658. };
  40659. ;
  40660. ConnectionManager.prototype.resetActivityCheck = function () {
  40661. var _this = this;
  40662. this.stopActivityCheck();
  40663. if (this.connection && !this.connection.handlesActivityChecks()) {
  40664. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  40665. _this.sendActivityCheck();
  40666. });
  40667. }
  40668. };
  40669. ;
  40670. ConnectionManager.prototype.stopActivityCheck = function () {
  40671. if (this.activityTimer) {
  40672. this.activityTimer.ensureAborted();
  40673. }
  40674. };
  40675. ;
  40676. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  40677. var _this = this;
  40678. return extend({}, errorCallbacks, {
  40679. message: function (message) {
  40680. _this.resetActivityCheck();
  40681. _this.emit('message', message);
  40682. },
  40683. ping: function () {
  40684. _this.send_event('pusher:pong', {});
  40685. },
  40686. activity: function () {
  40687. _this.resetActivityCheck();
  40688. },
  40689. error: function (error) {
  40690. _this.emit("error", { type: "WebSocketError", error: error });
  40691. },
  40692. closed: function () {
  40693. _this.abandonConnection();
  40694. if (_this.shouldRetry()) {
  40695. _this.retryIn(1000);
  40696. }
  40697. }
  40698. });
  40699. };
  40700. ;
  40701. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  40702. var _this = this;
  40703. return extend({}, errorCallbacks, {
  40704. connected: function (handshake) {
  40705. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  40706. _this.clearUnavailableTimer();
  40707. _this.setConnection(handshake.connection);
  40708. _this.socket_id = _this.connection.id;
  40709. _this.updateState("connected", { socket_id: _this.socket_id });
  40710. }
  40711. });
  40712. };
  40713. ;
  40714. ConnectionManager.prototype.buildErrorCallbacks = function () {
  40715. var _this = this;
  40716. var withErrorEmitted = function (callback) {
  40717. return function (result) {
  40718. if (result.error) {
  40719. _this.emit("error", { type: "WebSocketError", error: result.error });
  40720. }
  40721. callback(result);
  40722. };
  40723. };
  40724. return {
  40725. tls_only: withErrorEmitted(function () {
  40726. _this.usingTLS = true;
  40727. _this.updateStrategy();
  40728. _this.retryIn(0);
  40729. }),
  40730. refused: withErrorEmitted(function () {
  40731. _this.disconnect();
  40732. }),
  40733. backoff: withErrorEmitted(function () {
  40734. _this.retryIn(1000);
  40735. }),
  40736. retry: withErrorEmitted(function () {
  40737. _this.retryIn(0);
  40738. })
  40739. };
  40740. };
  40741. ;
  40742. ConnectionManager.prototype.setConnection = function (connection) {
  40743. this.connection = connection;
  40744. for (var event in this.connectionCallbacks) {
  40745. this.connection.bind(event, this.connectionCallbacks[event]);
  40746. }
  40747. this.resetActivityCheck();
  40748. };
  40749. ;
  40750. ConnectionManager.prototype.abandonConnection = function () {
  40751. if (!this.connection) {
  40752. return;
  40753. }
  40754. this.stopActivityCheck();
  40755. for (var event in this.connectionCallbacks) {
  40756. this.connection.unbind(event, this.connectionCallbacks[event]);
  40757. }
  40758. var connection = this.connection;
  40759. this.connection = null;
  40760. return connection;
  40761. };
  40762. ConnectionManager.prototype.updateState = function (newState, data) {
  40763. var previousState = this.state;
  40764. this.state = newState;
  40765. if (previousState !== newState) {
  40766. var newStateDescription = newState;
  40767. if (newStateDescription === "connected") {
  40768. newStateDescription += " with new socket ID " + data.socket_id;
  40769. }
  40770. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  40771. this.timeline.info({ state: newState, params: data });
  40772. this.emit('state_change', { previous: previousState, current: newState });
  40773. this.emit(newState, data);
  40774. }
  40775. };
  40776. ConnectionManager.prototype.shouldRetry = function () {
  40777. return this.state === "connecting" || this.state === "connected";
  40778. };
  40779. return ConnectionManager;
  40780. }(dispatcher));
  40781. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  40782. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  40783. var channels_Channels = (function () {
  40784. function Channels() {
  40785. this.channels = {};
  40786. }
  40787. Channels.prototype.add = function (name, pusher) {
  40788. if (!this.channels[name]) {
  40789. this.channels[name] = createChannel(name, pusher);
  40790. }
  40791. return this.channels[name];
  40792. };
  40793. Channels.prototype.all = function () {
  40794. return values(this.channels);
  40795. };
  40796. Channels.prototype.find = function (name) {
  40797. return this.channels[name];
  40798. };
  40799. Channels.prototype.remove = function (name) {
  40800. var channel = this.channels[name];
  40801. delete this.channels[name];
  40802. return channel;
  40803. };
  40804. Channels.prototype.disconnect = function () {
  40805. objectApply(this.channels, function (channel) {
  40806. channel.disconnect();
  40807. });
  40808. };
  40809. return Channels;
  40810. }());
  40811. /* harmony default export */ var channels = (channels_Channels);
  40812. function createChannel(name, pusher) {
  40813. if (name.indexOf('private-encrypted-') === 0) {
  40814. if (false) { var errorMsg; }
  40815. return factory.createEncryptedChannel(name, pusher);
  40816. }
  40817. else if (name.indexOf('private-') === 0) {
  40818. return factory.createPrivateChannel(name, pusher);
  40819. }
  40820. else if (name.indexOf('presence-') === 0) {
  40821. return factory.createPresenceChannel(name, pusher);
  40822. }
  40823. else {
  40824. return factory.createChannel(name, pusher);
  40825. }
  40826. }
  40827. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  40828. var Factory = {
  40829. createChannels: function () {
  40830. return new channels();
  40831. },
  40832. createConnectionManager: function (key, options) {
  40833. return new connection_manager(key, options);
  40834. },
  40835. createChannel: function (name, pusher) {
  40836. return new channels_channel(name, pusher);
  40837. },
  40838. createPrivateChannel: function (name, pusher) {
  40839. return new private_channel(name, pusher);
  40840. },
  40841. createPresenceChannel: function (name, pusher) {
  40842. return new presence_channel(name, pusher);
  40843. },
  40844. createEncryptedChannel: function (name, pusher) {
  40845. return new encrypted_channel(name, pusher);
  40846. },
  40847. createTimelineSender: function (timeline, options) {
  40848. return new timeline_sender(timeline, options);
  40849. },
  40850. createAuthorizer: function (channel, options) {
  40851. if (options.authorizer) {
  40852. return options.authorizer(channel, options);
  40853. }
  40854. return new pusher_authorizer(channel, options);
  40855. },
  40856. createHandshake: function (transport, callback) {
  40857. return new connection_handshake(transport, callback);
  40858. },
  40859. createAssistantToTheTransportManager: function (manager, transport, options) {
  40860. return new assistant_to_the_transport_manager(manager, transport, options);
  40861. }
  40862. };
  40863. /* harmony default export */ var factory = (Factory);
  40864. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  40865. var transport_manager_TransportManager = (function () {
  40866. function TransportManager(options) {
  40867. this.options = options || {};
  40868. this.livesLeft = this.options.lives || Infinity;
  40869. }
  40870. TransportManager.prototype.getAssistant = function (transport) {
  40871. return factory.createAssistantToTheTransportManager(this, transport, {
  40872. minPingDelay: this.options.minPingDelay,
  40873. maxPingDelay: this.options.maxPingDelay
  40874. });
  40875. };
  40876. TransportManager.prototype.isAlive = function () {
  40877. return this.livesLeft > 0;
  40878. };
  40879. TransportManager.prototype.reportDeath = function () {
  40880. this.livesLeft -= 1;
  40881. };
  40882. return TransportManager;
  40883. }());
  40884. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  40885. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  40886. var sequential_strategy_SequentialStrategy = (function () {
  40887. function SequentialStrategy(strategies, options) {
  40888. this.strategies = strategies;
  40889. this.loop = Boolean(options.loop);
  40890. this.failFast = Boolean(options.failFast);
  40891. this.timeout = options.timeout;
  40892. this.timeoutLimit = options.timeoutLimit;
  40893. }
  40894. SequentialStrategy.prototype.isSupported = function () {
  40895. return any(this.strategies, util.method("isSupported"));
  40896. };
  40897. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  40898. var _this = this;
  40899. var strategies = this.strategies;
  40900. var current = 0;
  40901. var timeout = this.timeout;
  40902. var runner = null;
  40903. var tryNextStrategy = function (error, handshake) {
  40904. if (handshake) {
  40905. callback(null, handshake);
  40906. }
  40907. else {
  40908. current = current + 1;
  40909. if (_this.loop) {
  40910. current = current % strategies.length;
  40911. }
  40912. if (current < strategies.length) {
  40913. if (timeout) {
  40914. timeout = timeout * 2;
  40915. if (_this.timeoutLimit) {
  40916. timeout = Math.min(timeout, _this.timeoutLimit);
  40917. }
  40918. }
  40919. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  40920. }
  40921. else {
  40922. callback(true);
  40923. }
  40924. }
  40925. };
  40926. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  40927. return {
  40928. abort: function () {
  40929. runner.abort();
  40930. },
  40931. forceMinPriority: function (p) {
  40932. minPriority = p;
  40933. if (runner) {
  40934. runner.forceMinPriority(p);
  40935. }
  40936. }
  40937. };
  40938. };
  40939. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  40940. var timer = null;
  40941. var runner = null;
  40942. if (options.timeout > 0) {
  40943. timer = new OneOffTimer(options.timeout, function () {
  40944. runner.abort();
  40945. callback(true);
  40946. });
  40947. }
  40948. runner = strategy.connect(minPriority, function (error, handshake) {
  40949. if (error && timer && timer.isRunning() && !options.failFast) {
  40950. return;
  40951. }
  40952. if (timer) {
  40953. timer.ensureAborted();
  40954. }
  40955. callback(error, handshake);
  40956. });
  40957. return {
  40958. abort: function () {
  40959. if (timer) {
  40960. timer.ensureAborted();
  40961. }
  40962. runner.abort();
  40963. },
  40964. forceMinPriority: function (p) {
  40965. runner.forceMinPriority(p);
  40966. }
  40967. };
  40968. };
  40969. return SequentialStrategy;
  40970. }());
  40971. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  40972. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  40973. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  40974. function BestConnectedEverStrategy(strategies) {
  40975. this.strategies = strategies;
  40976. }
  40977. BestConnectedEverStrategy.prototype.isSupported = function () {
  40978. return any(this.strategies, util.method("isSupported"));
  40979. };
  40980. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  40981. return connect(this.strategies, minPriority, function (i, runners) {
  40982. return function (error, handshake) {
  40983. runners[i].error = error;
  40984. if (error) {
  40985. if (allRunnersFailed(runners)) {
  40986. callback(true);
  40987. }
  40988. return;
  40989. }
  40990. apply(runners, function (runner) {
  40991. runner.forceMinPriority(handshake.transport.priority);
  40992. });
  40993. callback(null, handshake);
  40994. };
  40995. });
  40996. };
  40997. return BestConnectedEverStrategy;
  40998. }());
  40999. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  41000. function connect(strategies, minPriority, callbackBuilder) {
  41001. var runners = map(strategies, function (strategy, i, _, rs) {
  41002. return strategy.connect(minPriority, callbackBuilder(i, rs));
  41003. });
  41004. return {
  41005. abort: function () {
  41006. apply(runners, abortRunner);
  41007. },
  41008. forceMinPriority: function (p) {
  41009. apply(runners, function (runner) {
  41010. runner.forceMinPriority(p);
  41011. });
  41012. }
  41013. };
  41014. }
  41015. function allRunnersFailed(runners) {
  41016. return collections_all(runners, function (runner) {
  41017. return Boolean(runner.error);
  41018. });
  41019. }
  41020. function abortRunner(runner) {
  41021. if (!runner.error && !runner.aborted) {
  41022. runner.abort();
  41023. runner.aborted = true;
  41024. }
  41025. }
  41026. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  41027. var cached_strategy_CachedStrategy = (function () {
  41028. function CachedStrategy(strategy, transports, options) {
  41029. this.strategy = strategy;
  41030. this.transports = transports;
  41031. this.ttl = options.ttl || 1800 * 1000;
  41032. this.usingTLS = options.useTLS;
  41033. this.timeline = options.timeline;
  41034. }
  41035. CachedStrategy.prototype.isSupported = function () {
  41036. return this.strategy.isSupported();
  41037. };
  41038. CachedStrategy.prototype.connect = function (minPriority, callback) {
  41039. var usingTLS = this.usingTLS;
  41040. var info = fetchTransportCache(usingTLS);
  41041. var strategies = [this.strategy];
  41042. if (info && info.timestamp + this.ttl >= util.now()) {
  41043. var transport = this.transports[info.transport];
  41044. if (transport) {
  41045. this.timeline.info({
  41046. cached: true,
  41047. transport: info.transport,
  41048. latency: info.latency
  41049. });
  41050. strategies.push(new sequential_strategy([transport], {
  41051. timeout: info.latency * 2 + 1000,
  41052. failFast: true
  41053. }));
  41054. }
  41055. }
  41056. var startTimestamp = util.now();
  41057. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  41058. if (error) {
  41059. flushTransportCache(usingTLS);
  41060. if (strategies.length > 0) {
  41061. startTimestamp = util.now();
  41062. runner = strategies.pop().connect(minPriority, cb);
  41063. }
  41064. else {
  41065. callback(error);
  41066. }
  41067. }
  41068. else {
  41069. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  41070. callback(null, handshake);
  41071. }
  41072. });
  41073. return {
  41074. abort: function () {
  41075. runner.abort();
  41076. },
  41077. forceMinPriority: function (p) {
  41078. minPriority = p;
  41079. if (runner) {
  41080. runner.forceMinPriority(p);
  41081. }
  41082. }
  41083. };
  41084. };
  41085. return CachedStrategy;
  41086. }());
  41087. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  41088. function getTransportCacheKey(usingTLS) {
  41089. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  41090. }
  41091. function fetchTransportCache(usingTLS) {
  41092. var storage = runtime.getLocalStorage();
  41093. if (storage) {
  41094. try {
  41095. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  41096. if (serializedCache) {
  41097. return JSON.parse(serializedCache);
  41098. }
  41099. }
  41100. catch (e) {
  41101. flushTransportCache(usingTLS);
  41102. }
  41103. }
  41104. return null;
  41105. }
  41106. function storeTransportCache(usingTLS, transport, latency) {
  41107. var storage = runtime.getLocalStorage();
  41108. if (storage) {
  41109. try {
  41110. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  41111. timestamp: util.now(),
  41112. transport: transport,
  41113. latency: latency
  41114. });
  41115. }
  41116. catch (e) {
  41117. }
  41118. }
  41119. }
  41120. function flushTransportCache(usingTLS) {
  41121. var storage = runtime.getLocalStorage();
  41122. if (storage) {
  41123. try {
  41124. delete storage[getTransportCacheKey(usingTLS)];
  41125. }
  41126. catch (e) {
  41127. }
  41128. }
  41129. }
  41130. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  41131. var delayed_strategy_DelayedStrategy = (function () {
  41132. function DelayedStrategy(strategy, _a) {
  41133. var number = _a.delay;
  41134. this.strategy = strategy;
  41135. this.options = { delay: number };
  41136. }
  41137. DelayedStrategy.prototype.isSupported = function () {
  41138. return this.strategy.isSupported();
  41139. };
  41140. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  41141. var strategy = this.strategy;
  41142. var runner;
  41143. var timer = new OneOffTimer(this.options.delay, function () {
  41144. runner = strategy.connect(minPriority, callback);
  41145. });
  41146. return {
  41147. abort: function () {
  41148. timer.ensureAborted();
  41149. if (runner) {
  41150. runner.abort();
  41151. }
  41152. },
  41153. forceMinPriority: function (p) {
  41154. minPriority = p;
  41155. if (runner) {
  41156. runner.forceMinPriority(p);
  41157. }
  41158. }
  41159. };
  41160. };
  41161. return DelayedStrategy;
  41162. }());
  41163. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  41164. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  41165. var IfStrategy = (function () {
  41166. function IfStrategy(test, trueBranch, falseBranch) {
  41167. this.test = test;
  41168. this.trueBranch = trueBranch;
  41169. this.falseBranch = falseBranch;
  41170. }
  41171. IfStrategy.prototype.isSupported = function () {
  41172. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41173. return branch.isSupported();
  41174. };
  41175. IfStrategy.prototype.connect = function (minPriority, callback) {
  41176. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41177. return branch.connect(minPriority, callback);
  41178. };
  41179. return IfStrategy;
  41180. }());
  41181. /* harmony default export */ var if_strategy = (IfStrategy);
  41182. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  41183. var FirstConnectedStrategy = (function () {
  41184. function FirstConnectedStrategy(strategy) {
  41185. this.strategy = strategy;
  41186. }
  41187. FirstConnectedStrategy.prototype.isSupported = function () {
  41188. return this.strategy.isSupported();
  41189. };
  41190. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  41191. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  41192. if (handshake) {
  41193. runner.abort();
  41194. }
  41195. callback(error, handshake);
  41196. });
  41197. return runner;
  41198. };
  41199. return FirstConnectedStrategy;
  41200. }());
  41201. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  41202. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  41203. function testSupportsStrategy(strategy) {
  41204. return function () {
  41205. return strategy.isSupported();
  41206. };
  41207. }
  41208. var getDefaultStrategy = function (config, defineTransport) {
  41209. var definedTransports = {};
  41210. function defineTransportStrategy(name, type, priority, options, manager) {
  41211. var transport = defineTransport(config, name, type, priority, options, manager);
  41212. definedTransports[name] = transport;
  41213. return transport;
  41214. }
  41215. var ws_options = {
  41216. hostNonTLS: config.wsHost + ":" + config.wsPort,
  41217. hostTLS: config.wsHost + ":" + config.wssPort,
  41218. httpPath: config.wsPath
  41219. };
  41220. var wss_options = extend({}, ws_options, {
  41221. useTLS: true
  41222. });
  41223. var sockjs_options = {
  41224. hostNonTLS: config.httpHost + ":" + config.httpPort,
  41225. hostTLS: config.httpHost + ":" + config.httpsPort,
  41226. httpPath: config.httpPath
  41227. };
  41228. var timeouts = {
  41229. loop: true,
  41230. timeout: 15000,
  41231. timeoutLimit: 60000
  41232. };
  41233. var ws_manager = new transport_manager({
  41234. lives: 2,
  41235. minPingDelay: 10000,
  41236. maxPingDelay: config.activity_timeout
  41237. });
  41238. var streaming_manager = new transport_manager({
  41239. lives: 2,
  41240. minPingDelay: 10000,
  41241. maxPingDelay: config.activity_timeout
  41242. });
  41243. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  41244. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  41245. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  41246. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  41247. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  41248. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  41249. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  41250. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  41251. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  41252. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  41253. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  41254. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  41255. 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);
  41256. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  41257. var wsStrategy;
  41258. if (config.useTLS) {
  41259. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  41260. }
  41261. else {
  41262. wsStrategy = new best_connected_ever_strategy([
  41263. ws_loop,
  41264. new delayed_strategy(wss_loop, { delay: 2000 }),
  41265. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  41266. ]);
  41267. }
  41268. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  41269. ttl: 1800000,
  41270. timeline: config.timeline,
  41271. useTLS: config.useTLS
  41272. });
  41273. };
  41274. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  41275. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  41276. /* harmony default export */ var transport_connection_initializer = (function () {
  41277. var self = this;
  41278. self.timeline.info(self.buildTimelineMessage({
  41279. transport: self.name + (self.options.useTLS ? "s" : "")
  41280. }));
  41281. if (self.hooks.isInitialized()) {
  41282. self.changeState("initialized");
  41283. }
  41284. else if (self.hooks.file) {
  41285. self.changeState("initializing");
  41286. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  41287. if (self.hooks.isInitialized()) {
  41288. self.changeState("initialized");
  41289. callback(true);
  41290. }
  41291. else {
  41292. if (error) {
  41293. self.onError(error);
  41294. }
  41295. self.onClose();
  41296. callback(false);
  41297. }
  41298. });
  41299. }
  41300. else {
  41301. self.onClose();
  41302. }
  41303. });
  41304. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  41305. var http_xdomain_request_hooks = {
  41306. getRequest: function (socket) {
  41307. var xdr = new window.XDomainRequest();
  41308. xdr.ontimeout = function () {
  41309. socket.emit("error", new RequestTimedOut());
  41310. socket.close();
  41311. };
  41312. xdr.onerror = function (e) {
  41313. socket.emit("error", e);
  41314. socket.close();
  41315. };
  41316. xdr.onprogress = function () {
  41317. if (xdr.responseText && xdr.responseText.length > 0) {
  41318. socket.onChunk(200, xdr.responseText);
  41319. }
  41320. };
  41321. xdr.onload = function () {
  41322. if (xdr.responseText && xdr.responseText.length > 0) {
  41323. socket.onChunk(200, xdr.responseText);
  41324. }
  41325. socket.emit("finished", 200);
  41326. socket.close();
  41327. };
  41328. return xdr;
  41329. },
  41330. abortRequest: function (xdr) {
  41331. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  41332. xdr.abort();
  41333. }
  41334. };
  41335. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  41336. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  41337. var http_request_extends = (undefined && undefined.__extends) || (function () {
  41338. var extendStatics = function (d, b) {
  41339. extendStatics = Object.setPrototypeOf ||
  41340. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41341. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41342. return extendStatics(d, b);
  41343. };
  41344. return function (d, b) {
  41345. extendStatics(d, b);
  41346. function __() { this.constructor = d; }
  41347. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41348. };
  41349. })();
  41350. var MAX_BUFFER_LENGTH = 256 * 1024;
  41351. var http_request_HTTPRequest = (function (_super) {
  41352. http_request_extends(HTTPRequest, _super);
  41353. function HTTPRequest(hooks, method, url) {
  41354. var _this = _super.call(this) || this;
  41355. _this.hooks = hooks;
  41356. _this.method = method;
  41357. _this.url = url;
  41358. return _this;
  41359. }
  41360. HTTPRequest.prototype.start = function (payload) {
  41361. var _this = this;
  41362. this.position = 0;
  41363. this.xhr = this.hooks.getRequest(this);
  41364. this.unloader = function () {
  41365. _this.close();
  41366. };
  41367. runtime.addUnloadListener(this.unloader);
  41368. this.xhr.open(this.method, this.url, true);
  41369. if (this.xhr.setRequestHeader) {
  41370. this.xhr.setRequestHeader("Content-Type", "application/json");
  41371. }
  41372. this.xhr.send(payload);
  41373. };
  41374. HTTPRequest.prototype.close = function () {
  41375. if (this.unloader) {
  41376. runtime.removeUnloadListener(this.unloader);
  41377. this.unloader = null;
  41378. }
  41379. if (this.xhr) {
  41380. this.hooks.abortRequest(this.xhr);
  41381. this.xhr = null;
  41382. }
  41383. };
  41384. HTTPRequest.prototype.onChunk = function (status, data) {
  41385. while (true) {
  41386. var chunk = this.advanceBuffer(data);
  41387. if (chunk) {
  41388. this.emit("chunk", { status: status, data: chunk });
  41389. }
  41390. else {
  41391. break;
  41392. }
  41393. }
  41394. if (this.isBufferTooLong(data)) {
  41395. this.emit("buffer_too_long");
  41396. }
  41397. };
  41398. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  41399. var unreadData = buffer.slice(this.position);
  41400. var endOfLinePosition = unreadData.indexOf("\n");
  41401. if (endOfLinePosition !== -1) {
  41402. this.position += endOfLinePosition + 1;
  41403. return unreadData.slice(0, endOfLinePosition);
  41404. }
  41405. else {
  41406. return null;
  41407. }
  41408. };
  41409. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  41410. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  41411. };
  41412. return HTTPRequest;
  41413. }(dispatcher));
  41414. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  41415. // CONCATENATED MODULE: ./src/core/http/state.ts
  41416. var State;
  41417. (function (State) {
  41418. State[State["CONNECTING"] = 0] = "CONNECTING";
  41419. State[State["OPEN"] = 1] = "OPEN";
  41420. State[State["CLOSED"] = 3] = "CLOSED";
  41421. })(State || (State = {}));
  41422. /* harmony default export */ var state = (State);
  41423. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  41424. var autoIncrement = 1;
  41425. var http_socket_HTTPSocket = (function () {
  41426. function HTTPSocket(hooks, url) {
  41427. this.hooks = hooks;
  41428. this.session = randomNumber(1000) + "/" + randomString(8);
  41429. this.location = getLocation(url);
  41430. this.readyState = state.CONNECTING;
  41431. this.openStream();
  41432. }
  41433. HTTPSocket.prototype.send = function (payload) {
  41434. return this.sendRaw(JSON.stringify([payload]));
  41435. };
  41436. HTTPSocket.prototype.ping = function () {
  41437. this.hooks.sendHeartbeat(this);
  41438. };
  41439. HTTPSocket.prototype.close = function (code, reason) {
  41440. this.onClose(code, reason, true);
  41441. };
  41442. HTTPSocket.prototype.sendRaw = function (payload) {
  41443. if (this.readyState === state.OPEN) {
  41444. try {
  41445. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  41446. return true;
  41447. }
  41448. catch (e) {
  41449. return false;
  41450. }
  41451. }
  41452. else {
  41453. return false;
  41454. }
  41455. };
  41456. HTTPSocket.prototype.reconnect = function () {
  41457. this.closeStream();
  41458. this.openStream();
  41459. };
  41460. ;
  41461. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  41462. this.closeStream();
  41463. this.readyState = state.CLOSED;
  41464. if (this.onclose) {
  41465. this.onclose({
  41466. code: code,
  41467. reason: reason,
  41468. wasClean: wasClean
  41469. });
  41470. }
  41471. };
  41472. HTTPSocket.prototype.onChunk = function (chunk) {
  41473. if (chunk.status !== 200) {
  41474. return;
  41475. }
  41476. if (this.readyState === state.OPEN) {
  41477. this.onActivity();
  41478. }
  41479. var payload;
  41480. var type = chunk.data.slice(0, 1);
  41481. switch (type) {
  41482. case 'o':
  41483. payload = JSON.parse(chunk.data.slice(1) || '{}');
  41484. this.onOpen(payload);
  41485. break;
  41486. case 'a':
  41487. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41488. for (var i = 0; i < payload.length; i++) {
  41489. this.onEvent(payload[i]);
  41490. }
  41491. break;
  41492. case 'm':
  41493. payload = JSON.parse(chunk.data.slice(1) || 'null');
  41494. this.onEvent(payload);
  41495. break;
  41496. case 'h':
  41497. this.hooks.onHeartbeat(this);
  41498. break;
  41499. case 'c':
  41500. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41501. this.onClose(payload[0], payload[1], true);
  41502. break;
  41503. }
  41504. };
  41505. HTTPSocket.prototype.onOpen = function (options) {
  41506. if (this.readyState === state.CONNECTING) {
  41507. if (options && options.hostname) {
  41508. this.location.base = replaceHost(this.location.base, options.hostname);
  41509. }
  41510. this.readyState = state.OPEN;
  41511. if (this.onopen) {
  41512. this.onopen();
  41513. }
  41514. }
  41515. else {
  41516. this.onClose(1006, "Server lost session", true);
  41517. }
  41518. };
  41519. HTTPSocket.prototype.onEvent = function (event) {
  41520. if (this.readyState === state.OPEN && this.onmessage) {
  41521. this.onmessage({ data: event });
  41522. }
  41523. };
  41524. HTTPSocket.prototype.onActivity = function () {
  41525. if (this.onactivity) {
  41526. this.onactivity();
  41527. }
  41528. };
  41529. HTTPSocket.prototype.onError = function (error) {
  41530. if (this.onerror) {
  41531. this.onerror(error);
  41532. }
  41533. };
  41534. HTTPSocket.prototype.openStream = function () {
  41535. var _this = this;
  41536. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  41537. this.stream.bind("chunk", function (chunk) {
  41538. _this.onChunk(chunk);
  41539. });
  41540. this.stream.bind("finished", function (status) {
  41541. _this.hooks.onFinished(_this, status);
  41542. });
  41543. this.stream.bind("buffer_too_long", function () {
  41544. _this.reconnect();
  41545. });
  41546. try {
  41547. this.stream.start();
  41548. }
  41549. catch (error) {
  41550. util.defer(function () {
  41551. _this.onError(error);
  41552. _this.onClose(1006, "Could not start streaming", false);
  41553. });
  41554. }
  41555. };
  41556. HTTPSocket.prototype.closeStream = function () {
  41557. if (this.stream) {
  41558. this.stream.unbind_all();
  41559. this.stream.close();
  41560. this.stream = null;
  41561. }
  41562. };
  41563. return HTTPSocket;
  41564. }());
  41565. function getLocation(url) {
  41566. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  41567. return {
  41568. base: parts[1],
  41569. queryString: parts[2]
  41570. };
  41571. }
  41572. function getSendURL(url, session) {
  41573. return url.base + "/" + session + "/xhr_send";
  41574. }
  41575. function getUniqueURL(url) {
  41576. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  41577. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  41578. }
  41579. function replaceHost(url, hostname) {
  41580. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  41581. return urlParts[1] + hostname + urlParts[3];
  41582. }
  41583. function randomNumber(max) {
  41584. return Math.floor(Math.random() * max);
  41585. }
  41586. function randomString(length) {
  41587. var result = [];
  41588. for (var i = 0; i < length; i++) {
  41589. result.push(randomNumber(32).toString(32));
  41590. }
  41591. return result.join('');
  41592. }
  41593. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  41594. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  41595. var http_streaming_socket_hooks = {
  41596. getReceiveURL: function (url, session) {
  41597. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  41598. },
  41599. onHeartbeat: function (socket) {
  41600. socket.sendRaw("[]");
  41601. },
  41602. sendHeartbeat: function (socket) {
  41603. socket.sendRaw("[]");
  41604. },
  41605. onFinished: function (socket, status) {
  41606. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41607. }
  41608. };
  41609. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  41610. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  41611. var http_polling_socket_hooks = {
  41612. getReceiveURL: function (url, session) {
  41613. return url.base + "/" + session + "/xhr" + url.queryString;
  41614. },
  41615. onHeartbeat: function () {
  41616. },
  41617. sendHeartbeat: function (socket) {
  41618. socket.sendRaw("[]");
  41619. },
  41620. onFinished: function (socket, status) {
  41621. if (status === 200) {
  41622. socket.reconnect();
  41623. }
  41624. else {
  41625. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41626. }
  41627. }
  41628. };
  41629. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  41630. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  41631. var http_xhr_request_hooks = {
  41632. getRequest: function (socket) {
  41633. var Constructor = runtime.getXHRAPI();
  41634. var xhr = new Constructor();
  41635. xhr.onreadystatechange = xhr.onprogress = function () {
  41636. switch (xhr.readyState) {
  41637. case 3:
  41638. if (xhr.responseText && xhr.responseText.length > 0) {
  41639. socket.onChunk(xhr.status, xhr.responseText);
  41640. }
  41641. break;
  41642. case 4:
  41643. if (xhr.responseText && xhr.responseText.length > 0) {
  41644. socket.onChunk(xhr.status, xhr.responseText);
  41645. }
  41646. socket.emit("finished", xhr.status);
  41647. socket.close();
  41648. break;
  41649. }
  41650. };
  41651. return xhr;
  41652. },
  41653. abortRequest: function (xhr) {
  41654. xhr.onreadystatechange = null;
  41655. xhr.abort();
  41656. }
  41657. };
  41658. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  41659. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  41660. var HTTP = {
  41661. createStreamingSocket: function (url) {
  41662. return this.createSocket(http_streaming_socket, url);
  41663. },
  41664. createPollingSocket: function (url) {
  41665. return this.createSocket(http_polling_socket, url);
  41666. },
  41667. createSocket: function (hooks, url) {
  41668. return new http_socket(hooks, url);
  41669. },
  41670. createXHR: function (method, url) {
  41671. return this.createRequest(http_xhr_request, method, url);
  41672. },
  41673. createRequest: function (hooks, method, url) {
  41674. return new http_request(hooks, method, url);
  41675. }
  41676. };
  41677. /* harmony default export */ var http_http = (HTTP);
  41678. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  41679. http_http.createXDR = function (method, url) {
  41680. return this.createRequest(http_xdomain_request, method, url);
  41681. };
  41682. /* harmony default export */ var web_http_http = (http_http);
  41683. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  41684. var Runtime = {
  41685. nextAuthCallbackID: 1,
  41686. auth_callbacks: {},
  41687. ScriptReceivers: ScriptReceivers,
  41688. DependenciesReceivers: DependenciesReceivers,
  41689. getDefaultStrategy: default_strategy,
  41690. Transports: transports_transports,
  41691. transportConnectionInitializer: transport_connection_initializer,
  41692. HTTPFactory: web_http_http,
  41693. TimelineTransport: jsonp_timeline,
  41694. getXHRAPI: function () {
  41695. return window.XMLHttpRequest;
  41696. },
  41697. getWebSocketAPI: function () {
  41698. return window.WebSocket || window.MozWebSocket;
  41699. },
  41700. setup: function (PusherClass) {
  41701. var _this = this;
  41702. window.Pusher = PusherClass;
  41703. var initializeOnDocumentBody = function () {
  41704. _this.onDocumentBody(PusherClass.ready);
  41705. };
  41706. if (!window.JSON) {
  41707. Dependencies.load("json2", {}, initializeOnDocumentBody);
  41708. }
  41709. else {
  41710. initializeOnDocumentBody();
  41711. }
  41712. },
  41713. getDocument: function () {
  41714. return document;
  41715. },
  41716. getProtocol: function () {
  41717. return this.getDocument().location.protocol;
  41718. },
  41719. getAuthorizers: function () {
  41720. return { ajax: xhr_auth, jsonp: jsonp_auth };
  41721. },
  41722. onDocumentBody: function (callback) {
  41723. var _this = this;
  41724. if (document.body) {
  41725. callback();
  41726. }
  41727. else {
  41728. setTimeout(function () {
  41729. _this.onDocumentBody(callback);
  41730. }, 0);
  41731. }
  41732. },
  41733. createJSONPRequest: function (url, data) {
  41734. return new jsonp_request(url, data);
  41735. },
  41736. createScriptRequest: function (src) {
  41737. return new script_request(src);
  41738. },
  41739. getLocalStorage: function () {
  41740. try {
  41741. return window.localStorage;
  41742. }
  41743. catch (e) {
  41744. return undefined;
  41745. }
  41746. },
  41747. createXHR: function () {
  41748. if (this.getXHRAPI()) {
  41749. return this.createXMLHttpRequest();
  41750. }
  41751. else {
  41752. return this.createMicrosoftXHR();
  41753. }
  41754. },
  41755. createXMLHttpRequest: function () {
  41756. var Constructor = this.getXHRAPI();
  41757. return new Constructor();
  41758. },
  41759. createMicrosoftXHR: function () {
  41760. return new ActiveXObject("Microsoft.XMLHTTP");
  41761. },
  41762. getNetwork: function () {
  41763. return net_info_Network;
  41764. },
  41765. createWebSocket: function (url) {
  41766. var Constructor = this.getWebSocketAPI();
  41767. return new Constructor(url);
  41768. },
  41769. createSocketRequest: function (method, url) {
  41770. if (this.isXHRSupported()) {
  41771. return this.HTTPFactory.createXHR(method, url);
  41772. }
  41773. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  41774. return this.HTTPFactory.createXDR(method, url);
  41775. }
  41776. else {
  41777. throw "Cross-origin HTTP requests are not supported";
  41778. }
  41779. },
  41780. isXHRSupported: function () {
  41781. var Constructor = this.getXHRAPI();
  41782. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  41783. },
  41784. isXDRSupported: function (useTLS) {
  41785. var protocol = useTLS ? "https:" : "http:";
  41786. var documentProtocol = this.getProtocol();
  41787. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  41788. },
  41789. addUnloadListener: function (listener) {
  41790. if (window.addEventListener !== undefined) {
  41791. window.addEventListener("unload", listener, false);
  41792. }
  41793. else if (window.attachEvent !== undefined) {
  41794. window.attachEvent("onunload", listener);
  41795. }
  41796. },
  41797. removeUnloadListener: function (listener) {
  41798. if (window.addEventListener !== undefined) {
  41799. window.removeEventListener("unload", listener, false);
  41800. }
  41801. else if (window.detachEvent !== undefined) {
  41802. window.detachEvent("onunload", listener);
  41803. }
  41804. }
  41805. };
  41806. /* harmony default export */ var runtime = (Runtime);
  41807. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  41808. var TimelineLevel;
  41809. (function (TimelineLevel) {
  41810. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  41811. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  41812. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  41813. })(TimelineLevel || (TimelineLevel = {}));
  41814. /* harmony default export */ var timeline_level = (TimelineLevel);
  41815. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  41816. var timeline_Timeline = (function () {
  41817. function Timeline(key, session, options) {
  41818. this.key = key;
  41819. this.session = session;
  41820. this.events = [];
  41821. this.options = options || {};
  41822. this.sent = 0;
  41823. this.uniqueID = 0;
  41824. }
  41825. Timeline.prototype.log = function (level, event) {
  41826. if (level <= this.options.level) {
  41827. this.events.push(extend({}, event, { timestamp: util.now() }));
  41828. if (this.options.limit && this.events.length > this.options.limit) {
  41829. this.events.shift();
  41830. }
  41831. }
  41832. };
  41833. Timeline.prototype.error = function (event) {
  41834. this.log(timeline_level.ERROR, event);
  41835. };
  41836. Timeline.prototype.info = function (event) {
  41837. this.log(timeline_level.INFO, event);
  41838. };
  41839. Timeline.prototype.debug = function (event) {
  41840. this.log(timeline_level.DEBUG, event);
  41841. };
  41842. Timeline.prototype.isEmpty = function () {
  41843. return this.events.length === 0;
  41844. };
  41845. Timeline.prototype.send = function (sendfn, callback) {
  41846. var _this = this;
  41847. var data = extend({
  41848. session: this.session,
  41849. bundle: this.sent + 1,
  41850. key: this.key,
  41851. lib: "js",
  41852. version: this.options.version,
  41853. cluster: this.options.cluster,
  41854. features: this.options.features,
  41855. timeline: this.events
  41856. }, this.options.params);
  41857. this.events = [];
  41858. sendfn(data, function (error, result) {
  41859. if (!error) {
  41860. _this.sent++;
  41861. }
  41862. if (callback) {
  41863. callback(error, result);
  41864. }
  41865. });
  41866. return true;
  41867. };
  41868. Timeline.prototype.generateUniqueID = function () {
  41869. this.uniqueID++;
  41870. return this.uniqueID;
  41871. };
  41872. return Timeline;
  41873. }());
  41874. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  41875. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  41876. var transport_strategy_TransportStrategy = (function () {
  41877. function TransportStrategy(name, priority, transport, options) {
  41878. this.name = name;
  41879. this.priority = priority;
  41880. this.transport = transport;
  41881. this.options = options || {};
  41882. }
  41883. TransportStrategy.prototype.isSupported = function () {
  41884. return this.transport.isSupported({
  41885. useTLS: this.options.useTLS
  41886. });
  41887. };
  41888. TransportStrategy.prototype.connect = function (minPriority, callback) {
  41889. var _this = this;
  41890. if (!this.isSupported()) {
  41891. return failAttempt(new UnsupportedStrategy(), callback);
  41892. }
  41893. else if (this.priority < minPriority) {
  41894. return failAttempt(new TransportPriorityTooLow(), callback);
  41895. }
  41896. var connected = false;
  41897. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  41898. var handshake = null;
  41899. var onInitialized = function () {
  41900. transport.unbind("initialized", onInitialized);
  41901. transport.connect();
  41902. };
  41903. var onOpen = function () {
  41904. handshake = factory.createHandshake(transport, function (result) {
  41905. connected = true;
  41906. unbindListeners();
  41907. callback(null, result);
  41908. });
  41909. };
  41910. var onError = function (error) {
  41911. unbindListeners();
  41912. callback(error);
  41913. };
  41914. var onClosed = function () {
  41915. unbindListeners();
  41916. var serializedTransport;
  41917. serializedTransport = safeJSONStringify(transport);
  41918. callback(new TransportClosed(serializedTransport));
  41919. };
  41920. var unbindListeners = function () {
  41921. transport.unbind("initialized", onInitialized);
  41922. transport.unbind("open", onOpen);
  41923. transport.unbind("error", onError);
  41924. transport.unbind("closed", onClosed);
  41925. };
  41926. transport.bind("initialized", onInitialized);
  41927. transport.bind("open", onOpen);
  41928. transport.bind("error", onError);
  41929. transport.bind("closed", onClosed);
  41930. transport.initialize();
  41931. return {
  41932. abort: function () {
  41933. if (connected) {
  41934. return;
  41935. }
  41936. unbindListeners();
  41937. if (handshake) {
  41938. handshake.close();
  41939. }
  41940. else {
  41941. transport.close();
  41942. }
  41943. },
  41944. forceMinPriority: function (p) {
  41945. if (connected) {
  41946. return;
  41947. }
  41948. if (_this.priority < p) {
  41949. if (handshake) {
  41950. handshake.close();
  41951. }
  41952. else {
  41953. transport.close();
  41954. }
  41955. }
  41956. }
  41957. };
  41958. };
  41959. return TransportStrategy;
  41960. }());
  41961. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  41962. function failAttempt(error, callback) {
  41963. util.defer(function () {
  41964. callback(error);
  41965. });
  41966. return {
  41967. abort: function () { },
  41968. forceMinPriority: function () { }
  41969. };
  41970. }
  41971. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  41972. var strategy_builder_Transports = runtime.Transports;
  41973. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  41974. var transportClass = strategy_builder_Transports[type];
  41975. if (!transportClass) {
  41976. throw new UnsupportedTransport(type);
  41977. }
  41978. var enabled = (!config.enabledTransports ||
  41979. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  41980. (!config.disabledTransports ||
  41981. arrayIndexOf(config.disabledTransports, name) === -1);
  41982. var transport;
  41983. if (enabled) {
  41984. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  41985. key: config.key,
  41986. useTLS: config.useTLS,
  41987. timeline: config.timeline,
  41988. ignoreNullOrigin: config.ignoreNullOrigin
  41989. }, options));
  41990. }
  41991. else {
  41992. transport = strategy_builder_UnsupportedStrategy;
  41993. }
  41994. return transport;
  41995. };
  41996. var strategy_builder_UnsupportedStrategy = {
  41997. isSupported: function () {
  41998. return false;
  41999. },
  42000. connect: function (_, callback) {
  42001. var deferred = util.defer(function () {
  42002. callback(new UnsupportedStrategy());
  42003. });
  42004. return {
  42005. abort: function () {
  42006. deferred.ensureAborted();
  42007. },
  42008. forceMinPriority: function () { }
  42009. };
  42010. }
  42011. };
  42012. // CONCATENATED MODULE: ./src/core/config.ts
  42013. var getGlobalConfig = function () {
  42014. return {
  42015. wsHost: defaults.host,
  42016. wsPort: defaults.ws_port,
  42017. wssPort: defaults.wss_port,
  42018. wsPath: defaults.ws_path,
  42019. httpHost: defaults.sockjs_host,
  42020. httpPort: defaults.sockjs_http_port,
  42021. httpsPort: defaults.sockjs_https_port,
  42022. httpPath: defaults.sockjs_path,
  42023. statsHost: defaults.stats_host,
  42024. authEndpoint: defaults.channel_auth_endpoint,
  42025. authTransport: defaults.channel_auth_transport,
  42026. activity_timeout: defaults.activity_timeout,
  42027. pong_timeout: defaults.pong_timeout,
  42028. unavailable_timeout: defaults.unavailable_timeout
  42029. };
  42030. };
  42031. var getClusterConfig = function (clusterName) {
  42032. return {
  42033. wsHost: 'ws-' + clusterName + '.pusher.com',
  42034. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  42035. };
  42036. };
  42037. // CONCATENATED MODULE: ./src/core/pusher.ts
  42038. var pusher_Pusher = (function () {
  42039. function Pusher(app_key, options) {
  42040. var _this = this;
  42041. checkAppKey(app_key);
  42042. options = options || {};
  42043. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  42044. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  42045. logger.warn("You should always specify a cluster when connecting. " + suffix);
  42046. }
  42047. this.key = app_key;
  42048. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  42049. this.channels = factory.createChannels();
  42050. this.global_emitter = new dispatcher();
  42051. this.sessionID = Math.floor(Math.random() * 1000000000);
  42052. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  42053. cluster: this.config.cluster,
  42054. features: Pusher.getClientFeatures(),
  42055. params: this.config.timelineParams || {},
  42056. limit: 50,
  42057. level: timeline_level.INFO,
  42058. version: defaults.VERSION
  42059. });
  42060. if (!this.config.disableStats) {
  42061. this.timelineSender = factory.createTimelineSender(this.timeline, {
  42062. host: this.config.statsHost,
  42063. path: '/timeline/v2/' + runtime.TimelineTransport.name
  42064. });
  42065. }
  42066. var getStrategy = function (options) {
  42067. var config = extend({}, _this.config, options);
  42068. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  42069. };
  42070. this.connection = factory.createConnectionManager(this.key, extend({
  42071. getStrategy: getStrategy,
  42072. timeline: this.timeline,
  42073. activityTimeout: this.config.activity_timeout,
  42074. pongTimeout: this.config.pong_timeout,
  42075. unavailableTimeout: this.config.unavailable_timeout
  42076. }, this.config, { useTLS: this.shouldUseTLS() }));
  42077. this.connection.bind('connected', function () {
  42078. _this.subscribeAll();
  42079. if (_this.timelineSender) {
  42080. _this.timelineSender.send(_this.connection.isUsingTLS());
  42081. }
  42082. });
  42083. this.connection.bind('message', function (event) {
  42084. var eventName = event.event;
  42085. var internal = eventName.indexOf('pusher_internal:') === 0;
  42086. if (event.channel) {
  42087. var channel = _this.channel(event.channel);
  42088. if (channel) {
  42089. channel.handleEvent(event);
  42090. }
  42091. }
  42092. if (!internal) {
  42093. _this.global_emitter.emit(event.event, event.data);
  42094. }
  42095. });
  42096. this.connection.bind('connecting', function () {
  42097. _this.channels.disconnect();
  42098. });
  42099. this.connection.bind('disconnected', function () {
  42100. _this.channels.disconnect();
  42101. });
  42102. this.connection.bind('error', function (err) {
  42103. logger.warn(err);
  42104. });
  42105. Pusher.instances.push(this);
  42106. this.timeline.info({ instances: Pusher.instances.length });
  42107. if (Pusher.isReady) {
  42108. this.connect();
  42109. }
  42110. }
  42111. Pusher.ready = function () {
  42112. Pusher.isReady = true;
  42113. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  42114. Pusher.instances[i].connect();
  42115. }
  42116. };
  42117. Pusher.getClientFeatures = function () {
  42118. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  42119. return t.isSupported({});
  42120. }));
  42121. };
  42122. Pusher.prototype.channel = function (name) {
  42123. return this.channels.find(name);
  42124. };
  42125. Pusher.prototype.allChannels = function () {
  42126. return this.channels.all();
  42127. };
  42128. Pusher.prototype.connect = function () {
  42129. this.connection.connect();
  42130. if (this.timelineSender) {
  42131. if (!this.timelineSenderTimer) {
  42132. var usingTLS = this.connection.isUsingTLS();
  42133. var timelineSender = this.timelineSender;
  42134. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  42135. timelineSender.send(usingTLS);
  42136. });
  42137. }
  42138. }
  42139. };
  42140. Pusher.prototype.disconnect = function () {
  42141. this.connection.disconnect();
  42142. if (this.timelineSenderTimer) {
  42143. this.timelineSenderTimer.ensureAborted();
  42144. this.timelineSenderTimer = null;
  42145. }
  42146. };
  42147. Pusher.prototype.bind = function (event_name, callback, context) {
  42148. this.global_emitter.bind(event_name, callback, context);
  42149. return this;
  42150. };
  42151. Pusher.prototype.unbind = function (event_name, callback, context) {
  42152. this.global_emitter.unbind(event_name, callback, context);
  42153. return this;
  42154. };
  42155. Pusher.prototype.bind_global = function (callback) {
  42156. this.global_emitter.bind_global(callback);
  42157. return this;
  42158. };
  42159. Pusher.prototype.unbind_global = function (callback) {
  42160. this.global_emitter.unbind_global(callback);
  42161. return this;
  42162. };
  42163. Pusher.prototype.unbind_all = function (callback) {
  42164. this.global_emitter.unbind_all();
  42165. return this;
  42166. };
  42167. Pusher.prototype.subscribeAll = function () {
  42168. var channelName;
  42169. for (channelName in this.channels.channels) {
  42170. if (this.channels.channels.hasOwnProperty(channelName)) {
  42171. this.subscribe(channelName);
  42172. }
  42173. }
  42174. };
  42175. Pusher.prototype.subscribe = function (channel_name) {
  42176. var channel = this.channels.add(channel_name, this);
  42177. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  42178. channel.reinstateSubscription();
  42179. }
  42180. else if (!channel.subscriptionPending &&
  42181. this.connection.state === 'connected') {
  42182. channel.subscribe();
  42183. }
  42184. return channel;
  42185. };
  42186. Pusher.prototype.unsubscribe = function (channel_name) {
  42187. var channel = this.channels.find(channel_name);
  42188. if (channel && channel.subscriptionPending) {
  42189. channel.cancelSubscription();
  42190. }
  42191. else {
  42192. channel = this.channels.remove(channel_name);
  42193. if (channel && this.connection.state === 'connected') {
  42194. channel.unsubscribe();
  42195. }
  42196. }
  42197. };
  42198. Pusher.prototype.send_event = function (event_name, data, channel) {
  42199. return this.connection.send_event(event_name, data, channel);
  42200. };
  42201. Pusher.prototype.shouldUseTLS = function () {
  42202. if (runtime.getProtocol() === 'https:') {
  42203. return true;
  42204. }
  42205. else if (this.config.forceTLS === true) {
  42206. return true;
  42207. }
  42208. else {
  42209. return Boolean(this.config.encrypted);
  42210. }
  42211. };
  42212. Pusher.instances = [];
  42213. Pusher.isReady = false;
  42214. Pusher.logToConsole = false;
  42215. Pusher.Runtime = runtime;
  42216. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  42217. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  42218. Pusher.auth_callbacks = runtime.auth_callbacks;
  42219. return Pusher;
  42220. }());
  42221. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  42222. function checkAppKey(key) {
  42223. if (key === null || key === undefined) {
  42224. throw 'You must pass your app key when you instantiate Pusher.';
  42225. }
  42226. }
  42227. runtime.setup(pusher_Pusher);
  42228. /***/ })
  42229. /******/ ]);
  42230. });
  42231. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  42232. /***/ }),
  42233. /***/ "./node_modules/setimmediate/setImmediate.js":
  42234. /*!***************************************************!*\
  42235. !*** ./node_modules/setimmediate/setImmediate.js ***!
  42236. \***************************************************/
  42237. /*! no static exports found */
  42238. /***/ (function(module, exports, __webpack_require__) {
  42239. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  42240. "use strict";
  42241. if (global.setImmediate) {
  42242. return;
  42243. }
  42244. var nextHandle = 1; // Spec says greater than zero
  42245. var tasksByHandle = {};
  42246. var currentlyRunningATask = false;
  42247. var doc = global.document;
  42248. var registerImmediate;
  42249. function setImmediate(callback) {
  42250. // Callback can either be a function or a string
  42251. if (typeof callback !== "function") {
  42252. callback = new Function("" + callback);
  42253. }
  42254. // Copy function arguments
  42255. var args = new Array(arguments.length - 1);
  42256. for (var i = 0; i < args.length; i++) {
  42257. args[i] = arguments[i + 1];
  42258. }
  42259. // Store and register the task
  42260. var task = { callback: callback, args: args };
  42261. tasksByHandle[nextHandle] = task;
  42262. registerImmediate(nextHandle);
  42263. return nextHandle++;
  42264. }
  42265. function clearImmediate(handle) {
  42266. delete tasksByHandle[handle];
  42267. }
  42268. function run(task) {
  42269. var callback = task.callback;
  42270. var args = task.args;
  42271. switch (args.length) {
  42272. case 0:
  42273. callback();
  42274. break;
  42275. case 1:
  42276. callback(args[0]);
  42277. break;
  42278. case 2:
  42279. callback(args[0], args[1]);
  42280. break;
  42281. case 3:
  42282. callback(args[0], args[1], args[2]);
  42283. break;
  42284. default:
  42285. callback.apply(undefined, args);
  42286. break;
  42287. }
  42288. }
  42289. function runIfPresent(handle) {
  42290. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  42291. // So if we're currently running a task, we'll need to delay this invocation.
  42292. if (currentlyRunningATask) {
  42293. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  42294. // "too much recursion" error.
  42295. setTimeout(runIfPresent, 0, handle);
  42296. } else {
  42297. var task = tasksByHandle[handle];
  42298. if (task) {
  42299. currentlyRunningATask = true;
  42300. try {
  42301. run(task);
  42302. } finally {
  42303. clearImmediate(handle);
  42304. currentlyRunningATask = false;
  42305. }
  42306. }
  42307. }
  42308. }
  42309. function installNextTickImplementation() {
  42310. registerImmediate = function(handle) {
  42311. process.nextTick(function () { runIfPresent(handle); });
  42312. };
  42313. }
  42314. function canUsePostMessage() {
  42315. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  42316. // where `global.postMessage` means something completely different and can't be used for this purpose.
  42317. if (global.postMessage && !global.importScripts) {
  42318. var postMessageIsAsynchronous = true;
  42319. var oldOnMessage = global.onmessage;
  42320. global.onmessage = function() {
  42321. postMessageIsAsynchronous = false;
  42322. };
  42323. global.postMessage("", "*");
  42324. global.onmessage = oldOnMessage;
  42325. return postMessageIsAsynchronous;
  42326. }
  42327. }
  42328. function installPostMessageImplementation() {
  42329. // Installs an event handler on `global` for the `message` event: see
  42330. // * https://developer.mozilla.org/en/DOM/window.postMessage
  42331. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  42332. var messagePrefix = "setImmediate$" + Math.random() + "$";
  42333. var onGlobalMessage = function(event) {
  42334. if (event.source === global &&
  42335. typeof event.data === "string" &&
  42336. event.data.indexOf(messagePrefix) === 0) {
  42337. runIfPresent(+event.data.slice(messagePrefix.length));
  42338. }
  42339. };
  42340. if (global.addEventListener) {
  42341. global.addEventListener("message", onGlobalMessage, false);
  42342. } else {
  42343. global.attachEvent("onmessage", onGlobalMessage);
  42344. }
  42345. registerImmediate = function(handle) {
  42346. global.postMessage(messagePrefix + handle, "*");
  42347. };
  42348. }
  42349. function installMessageChannelImplementation() {
  42350. var channel = new MessageChannel();
  42351. channel.port1.onmessage = function(event) {
  42352. var handle = event.data;
  42353. runIfPresent(handle);
  42354. };
  42355. registerImmediate = function(handle) {
  42356. channel.port2.postMessage(handle);
  42357. };
  42358. }
  42359. function installReadyStateChangeImplementation() {
  42360. var html = doc.documentElement;
  42361. registerImmediate = function(handle) {
  42362. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  42363. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  42364. var script = doc.createElement("script");
  42365. script.onreadystatechange = function () {
  42366. runIfPresent(handle);
  42367. script.onreadystatechange = null;
  42368. html.removeChild(script);
  42369. script = null;
  42370. };
  42371. html.appendChild(script);
  42372. };
  42373. }
  42374. function installSetTimeoutImplementation() {
  42375. registerImmediate = function(handle) {
  42376. setTimeout(runIfPresent, 0, handle);
  42377. };
  42378. }
  42379. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  42380. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  42381. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  42382. // Don't get fooled by e.g. browserify environments.
  42383. if ({}.toString.call(global.process) === "[object process]") {
  42384. // For Node.js before 0.9
  42385. installNextTickImplementation();
  42386. } else if (canUsePostMessage()) {
  42387. // For non-IE10 modern browsers
  42388. installPostMessageImplementation();
  42389. } else if (global.MessageChannel) {
  42390. // For web workers, where supported
  42391. installMessageChannelImplementation();
  42392. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  42393. // For IE 6–8
  42394. installReadyStateChangeImplementation();
  42395. } else {
  42396. // For older browsers
  42397. installSetTimeoutImplementation();
  42398. }
  42399. attachTo.setImmediate = setImmediate;
  42400. attachTo.clearImmediate = clearImmediate;
  42401. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  42402. /* 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")))
  42403. /***/ }),
  42404. /***/ "./node_modules/timers-browserify/main.js":
  42405. /*!************************************************!*\
  42406. !*** ./node_modules/timers-browserify/main.js ***!
  42407. \************************************************/
  42408. /*! no static exports found */
  42409. /***/ (function(module, exports, __webpack_require__) {
  42410. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  42411. (typeof self !== "undefined" && self) ||
  42412. window;
  42413. var apply = Function.prototype.apply;
  42414. // DOM APIs, for completeness
  42415. exports.setTimeout = function() {
  42416. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  42417. };
  42418. exports.setInterval = function() {
  42419. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  42420. };
  42421. exports.clearTimeout =
  42422. exports.clearInterval = function(timeout) {
  42423. if (timeout) {
  42424. timeout.close();
  42425. }
  42426. };
  42427. function Timeout(id, clearFn) {
  42428. this._id = id;
  42429. this._clearFn = clearFn;
  42430. }
  42431. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  42432. Timeout.prototype.close = function() {
  42433. this._clearFn.call(scope, this._id);
  42434. };
  42435. // Does not start the time, just sets up the members needed.
  42436. exports.enroll = function(item, msecs) {
  42437. clearTimeout(item._idleTimeoutId);
  42438. item._idleTimeout = msecs;
  42439. };
  42440. exports.unenroll = function(item) {
  42441. clearTimeout(item._idleTimeoutId);
  42442. item._idleTimeout = -1;
  42443. };
  42444. exports._unrefActive = exports.active = function(item) {
  42445. clearTimeout(item._idleTimeoutId);
  42446. var msecs = item._idleTimeout;
  42447. if (msecs >= 0) {
  42448. item._idleTimeoutId = setTimeout(function onTimeout() {
  42449. if (item._onTimeout)
  42450. item._onTimeout();
  42451. }, msecs);
  42452. }
  42453. };
  42454. // setimmediate attaches itself to the global object
  42455. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  42456. // On some exotic environments, it's not clear which object `setimmediate` was
  42457. // able to install onto. Search each possibility in the same order as the
  42458. // `setimmediate` library.
  42459. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  42460. (typeof global !== "undefined" && global.setImmediate) ||
  42461. (this && this.setImmediate);
  42462. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  42463. (typeof global !== "undefined" && global.clearImmediate) ||
  42464. (this && this.clearImmediate);
  42465. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  42466. /***/ }),
  42467. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  42468. /*!*******************************************************************************************************************************************************************************************************************!*\
  42469. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  42470. \*******************************************************************************************************************************************************************************************************************/
  42471. /*! exports provided: render, staticRenderFns */
  42472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42473. "use strict";
  42474. __webpack_require__.r(__webpack_exports__);
  42475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42477. var render = function() {
  42478. var _vm = this
  42479. var _h = _vm.$createElement
  42480. var _c = _vm._self._c || _h
  42481. return _vm._m(0)
  42482. }
  42483. var staticRenderFns = [
  42484. function() {
  42485. var _vm = this
  42486. var _h = _vm.$createElement
  42487. var _c = _vm._self._c || _h
  42488. return _c("div", { staticClass: "container" }, [
  42489. _c("div", { staticClass: "row justify-content-center" }, [
  42490. _c("div", { staticClass: "col-md-8" }, [
  42491. _c("div", { staticClass: "card" }, [
  42492. _c("div", { staticClass: "card-header" }, [
  42493. _vm._v("Example Component")
  42494. ]),
  42495. _vm._v(" "),
  42496. _c("div", { staticClass: "card-body" }, [
  42497. _vm._v(
  42498. "\n I'm an example component.\n "
  42499. )
  42500. ])
  42501. ])
  42502. ])
  42503. ])
  42504. ])
  42505. }
  42506. ]
  42507. render._withStripped = true
  42508. /***/ }),
  42509. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  42510. /*!************************************************************************************************************************************************************************************************************!*\
  42511. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  42512. \************************************************************************************************************************************************************************************************************/
  42513. /*! exports provided: render, staticRenderFns */
  42514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42515. "use strict";
  42516. __webpack_require__.r(__webpack_exports__);
  42517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42519. var render = function() {
  42520. var _vm = this
  42521. var _h = _vm.$createElement
  42522. var _c = _vm._self._c || _h
  42523. return _c("div", [
  42524. _c("h4", { staticClass: "text-center" }, [
  42525. _vm._v(_vm._s(this.data.pcmanu) + " " + _vm._s(this.data.pcmake) + " - "),
  42526. _c("small", { staticClass: "text-muted" }, [
  42527. _vm._v(_vm._s(this.data.pcnickname))
  42528. ])
  42529. ]),
  42530. _vm._v(" "),
  42531. _c("p", [_vm._v("S/N: " + _vm._s(this.data.pcserial))]),
  42532. _vm._v(" "),
  42533. _c("p", [_vm._v("CPU: " + _vm._s(this.data.pcproc))]),
  42534. _vm._v(" "),
  42535. _c("p", [_vm._v("RAM: " + _vm._s(this.data.pcram))]),
  42536. _vm._v(" "),
  42537. _c("p", [_vm._v("OS: " + _vm._s(this.data.pcos))])
  42538. ])
  42539. }
  42540. var staticRenderFns = []
  42541. render._withStripped = true
  42542. /***/ }),
  42543. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&":
  42544. /*!*************************************************************************************************************************************************************************************************************!*\
  42545. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/credential.vue?vue&type=template&id=0f5cc562& ***!
  42546. \*************************************************************************************************************************************************************************************************************/
  42547. /*! exports provided: render, staticRenderFns */
  42548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42549. "use strict";
  42550. __webpack_require__.r(__webpack_exports__);
  42551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42553. var render = function() {
  42554. var _vm = this
  42555. var _h = _vm.$createElement
  42556. var _c = _vm._self._c || _h
  42557. return _c(
  42558. "div",
  42559. { staticClass: "bg-lightgray m-1 p-2 border rounded container-fluid" },
  42560. [
  42561. _c("div", { staticClass: "row no-gutters" }, [
  42562. _c("div", { staticClass: "h5 col-3 text-left" }, [
  42563. _vm._v(_vm._s(this.data.creddesc))
  42564. ]),
  42565. _vm._v(" "),
  42566. _c("div", { staticClass: "col-9 text-right" }, [
  42567. _vm._v(_vm._s(this.data.creddate))
  42568. ])
  42569. ]),
  42570. _vm._v(" "),
  42571. _c("div", { staticClass: "row" }, [
  42572. _c("div", { staticClass: "col-lg-9" }, [
  42573. _c("div", [
  42574. _vm._m(0),
  42575. _vm._v(" "),
  42576. _c("input", {
  42577. staticClass: "border-0 credential",
  42578. attrs: {
  42579. type: "text",
  42580. id: "username" + this.data.credid,
  42581. readonly: ""
  42582. },
  42583. domProps: { value: this.data.creduser }
  42584. }),
  42585. _vm._v(" "),
  42586. _c(
  42587. "button",
  42588. {
  42589. staticClass: "btn-clip btn btn-sm btn-primary rounded-pill",
  42590. attrs: {
  42591. id: "btn-username" + this.data.credid,
  42592. "data-clipboard-target": "#username" + this.data.credid
  42593. }
  42594. },
  42595. [_c("i", { staticClass: "far fa-clone" })]
  42596. )
  42597. ]),
  42598. _vm._v(" "),
  42599. _c("div", [
  42600. _vm._m(1),
  42601. _vm._v(" "),
  42602. _c("input", {
  42603. staticClass: "border-0 credential",
  42604. attrs: {
  42605. type: "text",
  42606. id: "password" + this.data.credid,
  42607. readonly: ""
  42608. },
  42609. domProps: { value: this.data.credpass }
  42610. }),
  42611. _vm._v(" "),
  42612. _c(
  42613. "button",
  42614. {
  42615. staticClass: "btn-clip btn btn-sm btn-primary rounded-pill",
  42616. attrs: {
  42617. id: "btn-password" + this.data.credid,
  42618. "data-clipboard-target": "#password" + this.data.credid
  42619. }
  42620. },
  42621. [_c("i", { staticClass: "far fa-clone" })]
  42622. )
  42623. ])
  42624. ]),
  42625. _vm._v(" "),
  42626. _vm._m(2)
  42627. ])
  42628. ]
  42629. )
  42630. }
  42631. var staticRenderFns = [
  42632. function() {
  42633. var _vm = this
  42634. var _h = _vm.$createElement
  42635. var _c = _vm._self._c || _h
  42636. return _c("label", { attrs: { for: "username" } }, [
  42637. _c("i", { staticClass: "fas fa-fw fa-user" })
  42638. ])
  42639. },
  42640. function() {
  42641. var _vm = this
  42642. var _h = _vm.$createElement
  42643. var _c = _vm._self._c || _h
  42644. return _c("label", { attrs: { for: "password" } }, [
  42645. _c("i", { staticClass: "fas fa-fw fa-key" })
  42646. ])
  42647. },
  42648. function() {
  42649. var _vm = this
  42650. var _h = _vm.$createElement
  42651. var _c = _vm._self._c || _h
  42652. return _c(
  42653. "div",
  42654. {
  42655. staticClass: "btn-group col-lg-2 align-self-end w-25 w-lg-auto",
  42656. attrs: { role: "group", "aria-label": "Edit and Delete" }
  42657. },
  42658. [
  42659. _c(
  42660. "button",
  42661. {
  42662. staticClass: "btn btn-sm btn-secondary p-lg-1",
  42663. attrs: { type: "button" }
  42664. },
  42665. [_c("i", { staticClass: "fas fa-fw fa-edit" })]
  42666. ),
  42667. _vm._v(" "),
  42668. _c(
  42669. "button",
  42670. {
  42671. staticClass: "btn btn-sm btn-danger p-lg-1",
  42672. attrs: { type: "button" }
  42673. },
  42674. [_c("i", { staticClass: "fas fa-fw fa-trash-alt" })]
  42675. )
  42676. ]
  42677. )
  42678. }
  42679. ]
  42680. render._withStripped = true
  42681. /***/ }),
  42682. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/notes.vue?vue&type=template&id=73d141f4&":
  42683. /*!********************************************************************************************************************************************************************************************************!*\
  42684. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/notes.vue?vue&type=template&id=73d141f4& ***!
  42685. \********************************************************************************************************************************************************************************************************/
  42686. /*! exports provided: render, staticRenderFns */
  42687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42688. "use strict";
  42689. __webpack_require__.r(__webpack_exports__);
  42690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42692. var render = function() {
  42693. var _vm = this
  42694. var _h = _vm.$createElement
  42695. var _c = _vm._self._c || _h
  42696. return _c(
  42697. "ul",
  42698. { staticClass: "list-unstyled" },
  42699. _vm._l(this.notes, function(note) {
  42700. return _c(
  42701. "li",
  42702. { key: note.noteid, staticClass: "row no-gutters mb-2" },
  42703. [
  42704. _c("div", { staticClass: "col-md-1 d-flex flex-column mx-md-3" }, [
  42705. _c("div", { staticClass: "text-center p-0 m-0" }, [
  42706. _vm._v(_vm._s(note.noteuser))
  42707. ]),
  42708. _vm._v(" "),
  42709. _c(
  42710. "div",
  42711. { staticClass: "text-muted text-small text-center p-0 m-0" },
  42712. [_vm._v(_vm._s(_vm.getHRDate(note.notetime)))]
  42713. ),
  42714. _vm._v(" "),
  42715. _c(
  42716. "div",
  42717. { staticClass: "btn-group justify-content-center p-0 m-0" },
  42718. [
  42719. _vm.authusername === note.noteuser ||
  42720. _vm.authusername === "admin"
  42721. ? [
  42722. _vm._m(0, true),
  42723. _vm._v(" "),
  42724. _vm._m(1, true),
  42725. _vm._v(" "),
  42726. _vm._m(2, true)
  42727. ]
  42728. : _vm._e()
  42729. ],
  42730. 2
  42731. )
  42732. ]),
  42733. _vm._v(" "),
  42734. _c("div", { staticClass: "col-md-10" }, [
  42735. _c("div", { staticClass: "card m-2" }, [
  42736. _c("div", { staticClass: "card-body p-2" }, [
  42737. _vm._v(
  42738. "\n " +
  42739. _vm._s(note.thenote) +
  42740. "\n "
  42741. )
  42742. ])
  42743. ])
  42744. ])
  42745. ]
  42746. )
  42747. }),
  42748. 0
  42749. )
  42750. }
  42751. var staticRenderFns = [
  42752. function() {
  42753. var _vm = this
  42754. var _h = _vm.$createElement
  42755. var _c = _vm._self._c || _h
  42756. return _c("button", { staticClass: "btn btn-sm btn-primary m-1" }, [
  42757. _c("i", { staticClass: "fas fa-fw fa-edit" })
  42758. ])
  42759. },
  42760. function() {
  42761. var _vm = this
  42762. var _h = _vm.$createElement
  42763. var _c = _vm._self._c || _h
  42764. return _c("button", { staticClass: "btn btn-sm btn-danger m-1" }, [
  42765. _c("i", { staticClass: "fas fa-fw fa-trash-alt" })
  42766. ])
  42767. },
  42768. function() {
  42769. var _vm = this
  42770. var _h = _vm.$createElement
  42771. var _c = _vm._self._c || _h
  42772. return _c("button", { staticClass: "btn btn-sm btn-primary m-1" }, [
  42773. _c("i", { staticClass: "fa fa-fw fa-random" })
  42774. ])
  42775. }
  42776. ]
  42777. render._withStripped = true
  42778. /***/ }),
  42779. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  42780. /*!*********************************************************************************************************************************************************************************************************!*\
  42781. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  42782. \*********************************************************************************************************************************************************************************************************/
  42783. /*! exports provided: render, staticRenderFns */
  42784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42785. "use strict";
  42786. __webpack_require__.r(__webpack_exports__);
  42787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42789. var render = function() {
  42790. var _vm = this
  42791. var _h = _vm.$createElement
  42792. var _c = _vm._self._c || _h
  42793. return _c("div", [
  42794. _c("p", [
  42795. _c("i", { staticClass: "fas fa-fw fa-info-circle" }),
  42796. _vm._v(" "),
  42797. _c("span", { domProps: { textContent: _vm._s(this.data.probdesc) } })
  42798. ]),
  42799. _vm._v(" "),
  42800. _c("p", [
  42801. _c("i", { staticClass: "far fa-fw fa-lightbulb" }),
  42802. _vm._v(" "),
  42803. _c("span", { domProps: { textContent: _vm._s(this.data.suggested) } })
  42804. ]),
  42805. _vm._v(" "),
  42806. _c("p", [
  42807. _c("i", { staticClass: "fas fa-fw fa-paste" }),
  42808. _vm._v(" "),
  42809. _c("span", { domProps: { textContent: _vm._s(this.data.woid) } })
  42810. ]),
  42811. _vm._v(" "),
  42812. _c("p", [
  42813. _c("i", { staticClass: "fas fa-fw fa-building" }),
  42814. _vm._v(" "),
  42815. _c("span", { domProps: { textContent: _vm._s(this.data.storeid) } })
  42816. ]),
  42817. _vm._v(" "),
  42818. _c("p", [
  42819. _c("i", { staticClass: "fas fa-fw fa-sign-in-alt" }),
  42820. _vm._v(" "),
  42821. _c(
  42822. "span",
  42823. {
  42824. staticClass: "dashed-underline",
  42825. attrs: {
  42826. "data-toggle": "tooltip",
  42827. "data-placement": "bottom",
  42828. title: this.getHRDate(this.data.dropdate)
  42829. }
  42830. },
  42831. [
  42832. _vm._v(
  42833. "\n " +
  42834. _vm._s(Math.floor(this.daysSinceToday(this.data.dropdate))) +
  42835. " days ago\n "
  42836. )
  42837. ]
  42838. )
  42839. ]),
  42840. _vm._v(" "),
  42841. _c("p", [
  42842. _c("i", { staticClass: "fas fa-sign-out-alt" }),
  42843. _vm._v(" "),
  42844. !this.isZero(this.data.pickupdate)
  42845. ? _c(
  42846. "span",
  42847. {
  42848. staticClass: "dashed-underline",
  42849. attrs: {
  42850. "data-toggle": "tooltip",
  42851. "data-placement": "bottom",
  42852. tittle: this.getHRDate(this.data.pickupdate)
  42853. }
  42854. },
  42855. [
  42856. _vm._v(
  42857. "\n " +
  42858. _vm._s(
  42859. Math.floor(this.daysSinceToday(this.data.pickupdate))
  42860. ) +
  42861. " days ago\n "
  42862. )
  42863. ]
  42864. )
  42865. : _vm._e()
  42866. ])
  42867. ])
  42868. }
  42869. var staticRenderFns = []
  42870. render._withStripped = true
  42871. /***/ }),
  42872. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  42873. /*!********************************************************************!*\
  42874. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  42875. \********************************************************************/
  42876. /*! exports provided: default */
  42877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42878. "use strict";
  42879. __webpack_require__.r(__webpack_exports__);
  42880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  42881. /* globals __VUE_SSR_CONTEXT__ */
  42882. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  42883. // This module is a runtime utility for cleaner component module output and will
  42884. // be included in the final webpack user bundle.
  42885. function normalizeComponent (
  42886. scriptExports,
  42887. render,
  42888. staticRenderFns,
  42889. functionalTemplate,
  42890. injectStyles,
  42891. scopeId,
  42892. moduleIdentifier, /* server only */
  42893. shadowMode /* vue-cli only */
  42894. ) {
  42895. // Vue.extend constructor export interop
  42896. var options = typeof scriptExports === 'function'
  42897. ? scriptExports.options
  42898. : scriptExports
  42899. // render functions
  42900. if (render) {
  42901. options.render = render
  42902. options.staticRenderFns = staticRenderFns
  42903. options._compiled = true
  42904. }
  42905. // functional template
  42906. if (functionalTemplate) {
  42907. options.functional = true
  42908. }
  42909. // scopedId
  42910. if (scopeId) {
  42911. options._scopeId = 'data-v-' + scopeId
  42912. }
  42913. var hook
  42914. if (moduleIdentifier) { // server build
  42915. hook = function (context) {
  42916. // 2.3 injection
  42917. context =
  42918. context || // cached call
  42919. (this.$vnode && this.$vnode.ssrContext) || // stateful
  42920. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  42921. // 2.2 with runInNewContext: true
  42922. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  42923. context = __VUE_SSR_CONTEXT__
  42924. }
  42925. // inject component styles
  42926. if (injectStyles) {
  42927. injectStyles.call(this, context)
  42928. }
  42929. // register component module identifier for async chunk inferrence
  42930. if (context && context._registeredComponents) {
  42931. context._registeredComponents.add(moduleIdentifier)
  42932. }
  42933. }
  42934. // used by ssr in case component is cached and beforeCreate
  42935. // never gets called
  42936. options._ssrRegister = hook
  42937. } else if (injectStyles) {
  42938. hook = shadowMode
  42939. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  42940. : injectStyles
  42941. }
  42942. if (hook) {
  42943. if (options.functional) {
  42944. // for template-only hot-reload because in that case the render fn doesn't
  42945. // go through the normalizer
  42946. options._injectStyles = hook
  42947. // register for functioal component in vue file
  42948. var originalRender = options.render
  42949. options.render = function renderWithStyleInjection (h, context) {
  42950. hook.call(context)
  42951. return originalRender(h, context)
  42952. }
  42953. } else {
  42954. // inject component registration as beforeCreate hook
  42955. var existing = options.beforeCreate
  42956. options.beforeCreate = existing
  42957. ? [].concat(existing, hook)
  42958. : [hook]
  42959. }
  42960. }
  42961. return {
  42962. exports: scriptExports,
  42963. options: options
  42964. }
  42965. }
  42966. /***/ }),
  42967. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  42968. /*!*************************************************!*\
  42969. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  42970. \*************************************************/
  42971. /*! no static exports found */
  42972. /***/ (function(module, exports, __webpack_require__) {
  42973. "use strict";
  42974. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  42975. * Vue.js v2.6.11
  42976. * (c) 2014-2019 Evan You
  42977. * Released under the MIT License.
  42978. */
  42979. /* */
  42980. var emptyObject = Object.freeze({});
  42981. // These helpers produce better VM code in JS engines due to their
  42982. // explicitness and function inlining.
  42983. function isUndef (v) {
  42984. return v === undefined || v === null
  42985. }
  42986. function isDef (v) {
  42987. return v !== undefined && v !== null
  42988. }
  42989. function isTrue (v) {
  42990. return v === true
  42991. }
  42992. function isFalse (v) {
  42993. return v === false
  42994. }
  42995. /**
  42996. * Check if value is primitive.
  42997. */
  42998. function isPrimitive (value) {
  42999. return (
  43000. typeof value === 'string' ||
  43001. typeof value === 'number' ||
  43002. // $flow-disable-line
  43003. typeof value === 'symbol' ||
  43004. typeof value === 'boolean'
  43005. )
  43006. }
  43007. /**
  43008. * Quick object check - this is primarily used to tell
  43009. * Objects from primitive values when we know the value
  43010. * is a JSON-compliant type.
  43011. */
  43012. function isObject (obj) {
  43013. return obj !== null && typeof obj === 'object'
  43014. }
  43015. /**
  43016. * Get the raw type string of a value, e.g., [object Object].
  43017. */
  43018. var _toString = Object.prototype.toString;
  43019. function toRawType (value) {
  43020. return _toString.call(value).slice(8, -1)
  43021. }
  43022. /**
  43023. * Strict object type check. Only returns true
  43024. * for plain JavaScript objects.
  43025. */
  43026. function isPlainObject (obj) {
  43027. return _toString.call(obj) === '[object Object]'
  43028. }
  43029. function isRegExp (v) {
  43030. return _toString.call(v) === '[object RegExp]'
  43031. }
  43032. /**
  43033. * Check if val is a valid array index.
  43034. */
  43035. function isValidArrayIndex (val) {
  43036. var n = parseFloat(String(val));
  43037. return n >= 0 && Math.floor(n) === n && isFinite(val)
  43038. }
  43039. function isPromise (val) {
  43040. return (
  43041. isDef(val) &&
  43042. typeof val.then === 'function' &&
  43043. typeof val.catch === 'function'
  43044. )
  43045. }
  43046. /**
  43047. * Convert a value to a string that is actually rendered.
  43048. */
  43049. function toString (val) {
  43050. return val == null
  43051. ? ''
  43052. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  43053. ? JSON.stringify(val, null, 2)
  43054. : String(val)
  43055. }
  43056. /**
  43057. * Convert an input value to a number for persistence.
  43058. * If the conversion fails, return original string.
  43059. */
  43060. function toNumber (val) {
  43061. var n = parseFloat(val);
  43062. return isNaN(n) ? val : n
  43063. }
  43064. /**
  43065. * Make a map and return a function for checking if a key
  43066. * is in that map.
  43067. */
  43068. function makeMap (
  43069. str,
  43070. expectsLowerCase
  43071. ) {
  43072. var map = Object.create(null);
  43073. var list = str.split(',');
  43074. for (var i = 0; i < list.length; i++) {
  43075. map[list[i]] = true;
  43076. }
  43077. return expectsLowerCase
  43078. ? function (val) { return map[val.toLowerCase()]; }
  43079. : function (val) { return map[val]; }
  43080. }
  43081. /**
  43082. * Check if a tag is a built-in tag.
  43083. */
  43084. var isBuiltInTag = makeMap('slot,component', true);
  43085. /**
  43086. * Check if an attribute is a reserved attribute.
  43087. */
  43088. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  43089. /**
  43090. * Remove an item from an array.
  43091. */
  43092. function remove (arr, item) {
  43093. if (arr.length) {
  43094. var index = arr.indexOf(item);
  43095. if (index > -1) {
  43096. return arr.splice(index, 1)
  43097. }
  43098. }
  43099. }
  43100. /**
  43101. * Check whether an object has the property.
  43102. */
  43103. var hasOwnProperty = Object.prototype.hasOwnProperty;
  43104. function hasOwn (obj, key) {
  43105. return hasOwnProperty.call(obj, key)
  43106. }
  43107. /**
  43108. * Create a cached version of a pure function.
  43109. */
  43110. function cached (fn) {
  43111. var cache = Object.create(null);
  43112. return (function cachedFn (str) {
  43113. var hit = cache[str];
  43114. return hit || (cache[str] = fn(str))
  43115. })
  43116. }
  43117. /**
  43118. * Camelize a hyphen-delimited string.
  43119. */
  43120. var camelizeRE = /-(\w)/g;
  43121. var camelize = cached(function (str) {
  43122. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  43123. });
  43124. /**
  43125. * Capitalize a string.
  43126. */
  43127. var capitalize = cached(function (str) {
  43128. return str.charAt(0).toUpperCase() + str.slice(1)
  43129. });
  43130. /**
  43131. * Hyphenate a camelCase string.
  43132. */
  43133. var hyphenateRE = /\B([A-Z])/g;
  43134. var hyphenate = cached(function (str) {
  43135. return str.replace(hyphenateRE, '-$1').toLowerCase()
  43136. });
  43137. /**
  43138. * Simple bind polyfill for environments that do not support it,
  43139. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  43140. * since native bind is now performant enough in most browsers.
  43141. * But removing it would mean breaking code that was able to run in
  43142. * PhantomJS 1.x, so this must be kept for backward compatibility.
  43143. */
  43144. /* istanbul ignore next */
  43145. function polyfillBind (fn, ctx) {
  43146. function boundFn (a) {
  43147. var l = arguments.length;
  43148. return l
  43149. ? l > 1
  43150. ? fn.apply(ctx, arguments)
  43151. : fn.call(ctx, a)
  43152. : fn.call(ctx)
  43153. }
  43154. boundFn._length = fn.length;
  43155. return boundFn
  43156. }
  43157. function nativeBind (fn, ctx) {
  43158. return fn.bind(ctx)
  43159. }
  43160. var bind = Function.prototype.bind
  43161. ? nativeBind
  43162. : polyfillBind;
  43163. /**
  43164. * Convert an Array-like object to a real Array.
  43165. */
  43166. function toArray (list, start) {
  43167. start = start || 0;
  43168. var i = list.length - start;
  43169. var ret = new Array(i);
  43170. while (i--) {
  43171. ret[i] = list[i + start];
  43172. }
  43173. return ret
  43174. }
  43175. /**
  43176. * Mix properties into target object.
  43177. */
  43178. function extend (to, _from) {
  43179. for (var key in _from) {
  43180. to[key] = _from[key];
  43181. }
  43182. return to
  43183. }
  43184. /**
  43185. * Merge an Array of Objects into a single Object.
  43186. */
  43187. function toObject (arr) {
  43188. var res = {};
  43189. for (var i = 0; i < arr.length; i++) {
  43190. if (arr[i]) {
  43191. extend(res, arr[i]);
  43192. }
  43193. }
  43194. return res
  43195. }
  43196. /* eslint-disable no-unused-vars */
  43197. /**
  43198. * Perform no operation.
  43199. * Stubbing args to make Flow happy without leaving useless transpiled code
  43200. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  43201. */
  43202. function noop (a, b, c) {}
  43203. /**
  43204. * Always return false.
  43205. */
  43206. var no = function (a, b, c) { return false; };
  43207. /* eslint-enable no-unused-vars */
  43208. /**
  43209. * Return the same value.
  43210. */
  43211. var identity = function (_) { return _; };
  43212. /**
  43213. * Generate a string containing static keys from compiler modules.
  43214. */
  43215. function genStaticKeys (modules) {
  43216. return modules.reduce(function (keys, m) {
  43217. return keys.concat(m.staticKeys || [])
  43218. }, []).join(',')
  43219. }
  43220. /**
  43221. * Check if two values are loosely equal - that is,
  43222. * if they are plain objects, do they have the same shape?
  43223. */
  43224. function looseEqual (a, b) {
  43225. if (a === b) { return true }
  43226. var isObjectA = isObject(a);
  43227. var isObjectB = isObject(b);
  43228. if (isObjectA && isObjectB) {
  43229. try {
  43230. var isArrayA = Array.isArray(a);
  43231. var isArrayB = Array.isArray(b);
  43232. if (isArrayA && isArrayB) {
  43233. return a.length === b.length && a.every(function (e, i) {
  43234. return looseEqual(e, b[i])
  43235. })
  43236. } else if (a instanceof Date && b instanceof Date) {
  43237. return a.getTime() === b.getTime()
  43238. } else if (!isArrayA && !isArrayB) {
  43239. var keysA = Object.keys(a);
  43240. var keysB = Object.keys(b);
  43241. return keysA.length === keysB.length && keysA.every(function (key) {
  43242. return looseEqual(a[key], b[key])
  43243. })
  43244. } else {
  43245. /* istanbul ignore next */
  43246. return false
  43247. }
  43248. } catch (e) {
  43249. /* istanbul ignore next */
  43250. return false
  43251. }
  43252. } else if (!isObjectA && !isObjectB) {
  43253. return String(a) === String(b)
  43254. } else {
  43255. return false
  43256. }
  43257. }
  43258. /**
  43259. * Return the first index at which a loosely equal value can be
  43260. * found in the array (if value is a plain object, the array must
  43261. * contain an object of the same shape), or -1 if it is not present.
  43262. */
  43263. function looseIndexOf (arr, val) {
  43264. for (var i = 0; i < arr.length; i++) {
  43265. if (looseEqual(arr[i], val)) { return i }
  43266. }
  43267. return -1
  43268. }
  43269. /**
  43270. * Ensure a function is called only once.
  43271. */
  43272. function once (fn) {
  43273. var called = false;
  43274. return function () {
  43275. if (!called) {
  43276. called = true;
  43277. fn.apply(this, arguments);
  43278. }
  43279. }
  43280. }
  43281. var SSR_ATTR = 'data-server-rendered';
  43282. var ASSET_TYPES = [
  43283. 'component',
  43284. 'directive',
  43285. 'filter'
  43286. ];
  43287. var LIFECYCLE_HOOKS = [
  43288. 'beforeCreate',
  43289. 'created',
  43290. 'beforeMount',
  43291. 'mounted',
  43292. 'beforeUpdate',
  43293. 'updated',
  43294. 'beforeDestroy',
  43295. 'destroyed',
  43296. 'activated',
  43297. 'deactivated',
  43298. 'errorCaptured',
  43299. 'serverPrefetch'
  43300. ];
  43301. /* */
  43302. var config = ({
  43303. /**
  43304. * Option merge strategies (used in core/util/options)
  43305. */
  43306. // $flow-disable-line
  43307. optionMergeStrategies: Object.create(null),
  43308. /**
  43309. * Whether to suppress warnings.
  43310. */
  43311. silent: false,
  43312. /**
  43313. * Show production mode tip message on boot?
  43314. */
  43315. productionTip: "development" !== 'production',
  43316. /**
  43317. * Whether to enable devtools
  43318. */
  43319. devtools: "development" !== 'production',
  43320. /**
  43321. * Whether to record perf
  43322. */
  43323. performance: false,
  43324. /**
  43325. * Error handler for watcher errors
  43326. */
  43327. errorHandler: null,
  43328. /**
  43329. * Warn handler for watcher warns
  43330. */
  43331. warnHandler: null,
  43332. /**
  43333. * Ignore certain custom elements
  43334. */
  43335. ignoredElements: [],
  43336. /**
  43337. * Custom user key aliases for v-on
  43338. */
  43339. // $flow-disable-line
  43340. keyCodes: Object.create(null),
  43341. /**
  43342. * Check if a tag is reserved so that it cannot be registered as a
  43343. * component. This is platform-dependent and may be overwritten.
  43344. */
  43345. isReservedTag: no,
  43346. /**
  43347. * Check if an attribute is reserved so that it cannot be used as a component
  43348. * prop. This is platform-dependent and may be overwritten.
  43349. */
  43350. isReservedAttr: no,
  43351. /**
  43352. * Check if a tag is an unknown element.
  43353. * Platform-dependent.
  43354. */
  43355. isUnknownElement: no,
  43356. /**
  43357. * Get the namespace of an element
  43358. */
  43359. getTagNamespace: noop,
  43360. /**
  43361. * Parse the real tag name for the specific platform.
  43362. */
  43363. parsePlatformTagName: identity,
  43364. /**
  43365. * Check if an attribute must be bound using property, e.g. value
  43366. * Platform-dependent.
  43367. */
  43368. mustUseProp: no,
  43369. /**
  43370. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  43371. * This will significantly reduce performance if set to false.
  43372. */
  43373. async: true,
  43374. /**
  43375. * Exposed for legacy reasons
  43376. */
  43377. _lifecycleHooks: LIFECYCLE_HOOKS
  43378. });
  43379. /* */
  43380. /**
  43381. * unicode letters used for parsing html tags, component names and property paths.
  43382. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  43383. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  43384. */
  43385. 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/;
  43386. /**
  43387. * Check if a string starts with $ or _
  43388. */
  43389. function isReserved (str) {
  43390. var c = (str + '').charCodeAt(0);
  43391. return c === 0x24 || c === 0x5F
  43392. }
  43393. /**
  43394. * Define a property.
  43395. */
  43396. function def (obj, key, val, enumerable) {
  43397. Object.defineProperty(obj, key, {
  43398. value: val,
  43399. enumerable: !!enumerable,
  43400. writable: true,
  43401. configurable: true
  43402. });
  43403. }
  43404. /**
  43405. * Parse simple path.
  43406. */
  43407. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  43408. function parsePath (path) {
  43409. if (bailRE.test(path)) {
  43410. return
  43411. }
  43412. var segments = path.split('.');
  43413. return function (obj) {
  43414. for (var i = 0; i < segments.length; i++) {
  43415. if (!obj) { return }
  43416. obj = obj[segments[i]];
  43417. }
  43418. return obj
  43419. }
  43420. }
  43421. /* */
  43422. // can we use __proto__?
  43423. var hasProto = '__proto__' in {};
  43424. // Browser environment sniffing
  43425. var inBrowser = typeof window !== 'undefined';
  43426. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  43427. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  43428. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  43429. var isIE = UA && /msie|trident/.test(UA);
  43430. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  43431. var isEdge = UA && UA.indexOf('edge/') > 0;
  43432. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  43433. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  43434. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  43435. var isPhantomJS = UA && /phantomjs/.test(UA);
  43436. var isFF = UA && UA.match(/firefox\/(\d+)/);
  43437. // Firefox has a "watch" function on Object.prototype...
  43438. var nativeWatch = ({}).watch;
  43439. var supportsPassive = false;
  43440. if (inBrowser) {
  43441. try {
  43442. var opts = {};
  43443. Object.defineProperty(opts, 'passive', ({
  43444. get: function get () {
  43445. /* istanbul ignore next */
  43446. supportsPassive = true;
  43447. }
  43448. })); // https://github.com/facebook/flow/issues/285
  43449. window.addEventListener('test-passive', null, opts);
  43450. } catch (e) {}
  43451. }
  43452. // this needs to be lazy-evaled because vue may be required before
  43453. // vue-server-renderer can set VUE_ENV
  43454. var _isServer;
  43455. var isServerRendering = function () {
  43456. if (_isServer === undefined) {
  43457. /* istanbul ignore if */
  43458. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  43459. // detect presence of vue-server-renderer and avoid
  43460. // Webpack shimming the process
  43461. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  43462. } else {
  43463. _isServer = false;
  43464. }
  43465. }
  43466. return _isServer
  43467. };
  43468. // detect devtools
  43469. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  43470. /* istanbul ignore next */
  43471. function isNative (Ctor) {
  43472. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  43473. }
  43474. var hasSymbol =
  43475. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  43476. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  43477. var _Set;
  43478. /* istanbul ignore if */ // $flow-disable-line
  43479. if (typeof Set !== 'undefined' && isNative(Set)) {
  43480. // use native Set when available.
  43481. _Set = Set;
  43482. } else {
  43483. // a non-standard Set polyfill that only works with primitive keys.
  43484. _Set = /*@__PURE__*/(function () {
  43485. function Set () {
  43486. this.set = Object.create(null);
  43487. }
  43488. Set.prototype.has = function has (key) {
  43489. return this.set[key] === true
  43490. };
  43491. Set.prototype.add = function add (key) {
  43492. this.set[key] = true;
  43493. };
  43494. Set.prototype.clear = function clear () {
  43495. this.set = Object.create(null);
  43496. };
  43497. return Set;
  43498. }());
  43499. }
  43500. /* */
  43501. var warn = noop;
  43502. var tip = noop;
  43503. var generateComponentTrace = (noop); // work around flow check
  43504. var formatComponentName = (noop);
  43505. {
  43506. var hasConsole = typeof console !== 'undefined';
  43507. var classifyRE = /(?:^|[-_])(\w)/g;
  43508. var classify = function (str) { return str
  43509. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  43510. .replace(/[-_]/g, ''); };
  43511. warn = function (msg, vm) {
  43512. var trace = vm ? generateComponentTrace(vm) : '';
  43513. if (config.warnHandler) {
  43514. config.warnHandler.call(null, msg, vm, trace);
  43515. } else if (hasConsole && (!config.silent)) {
  43516. console.error(("[Vue warn]: " + msg + trace));
  43517. }
  43518. };
  43519. tip = function (msg, vm) {
  43520. if (hasConsole && (!config.silent)) {
  43521. console.warn("[Vue tip]: " + msg + (
  43522. vm ? generateComponentTrace(vm) : ''
  43523. ));
  43524. }
  43525. };
  43526. formatComponentName = function (vm, includeFile) {
  43527. if (vm.$root === vm) {
  43528. return '<Root>'
  43529. }
  43530. var options = typeof vm === 'function' && vm.cid != null
  43531. ? vm.options
  43532. : vm._isVue
  43533. ? vm.$options || vm.constructor.options
  43534. : vm;
  43535. var name = options.name || options._componentTag;
  43536. var file = options.__file;
  43537. if (!name && file) {
  43538. var match = file.match(/([^/\\]+)\.vue$/);
  43539. name = match && match[1];
  43540. }
  43541. return (
  43542. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  43543. (file && includeFile !== false ? (" at " + file) : '')
  43544. )
  43545. };
  43546. var repeat = function (str, n) {
  43547. var res = '';
  43548. while (n) {
  43549. if (n % 2 === 1) { res += str; }
  43550. if (n > 1) { str += str; }
  43551. n >>= 1;
  43552. }
  43553. return res
  43554. };
  43555. generateComponentTrace = function (vm) {
  43556. if (vm._isVue && vm.$parent) {
  43557. var tree = [];
  43558. var currentRecursiveSequence = 0;
  43559. while (vm) {
  43560. if (tree.length > 0) {
  43561. var last = tree[tree.length - 1];
  43562. if (last.constructor === vm.constructor) {
  43563. currentRecursiveSequence++;
  43564. vm = vm.$parent;
  43565. continue
  43566. } else if (currentRecursiveSequence > 0) {
  43567. tree[tree.length - 1] = [last, currentRecursiveSequence];
  43568. currentRecursiveSequence = 0;
  43569. }
  43570. }
  43571. tree.push(vm);
  43572. vm = vm.$parent;
  43573. }
  43574. return '\n\nfound in\n\n' + tree
  43575. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  43576. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  43577. : formatComponentName(vm))); })
  43578. .join('\n')
  43579. } else {
  43580. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  43581. }
  43582. };
  43583. }
  43584. /* */
  43585. var uid = 0;
  43586. /**
  43587. * A dep is an observable that can have multiple
  43588. * directives subscribing to it.
  43589. */
  43590. var Dep = function Dep () {
  43591. this.id = uid++;
  43592. this.subs = [];
  43593. };
  43594. Dep.prototype.addSub = function addSub (sub) {
  43595. this.subs.push(sub);
  43596. };
  43597. Dep.prototype.removeSub = function removeSub (sub) {
  43598. remove(this.subs, sub);
  43599. };
  43600. Dep.prototype.depend = function depend () {
  43601. if (Dep.target) {
  43602. Dep.target.addDep(this);
  43603. }
  43604. };
  43605. Dep.prototype.notify = function notify () {
  43606. // stabilize the subscriber list first
  43607. var subs = this.subs.slice();
  43608. if (!config.async) {
  43609. // subs aren't sorted in scheduler if not running async
  43610. // we need to sort them now to make sure they fire in correct
  43611. // order
  43612. subs.sort(function (a, b) { return a.id - b.id; });
  43613. }
  43614. for (var i = 0, l = subs.length; i < l; i++) {
  43615. subs[i].update();
  43616. }
  43617. };
  43618. // The current target watcher being evaluated.
  43619. // This is globally unique because only one watcher
  43620. // can be evaluated at a time.
  43621. Dep.target = null;
  43622. var targetStack = [];
  43623. function pushTarget (target) {
  43624. targetStack.push(target);
  43625. Dep.target = target;
  43626. }
  43627. function popTarget () {
  43628. targetStack.pop();
  43629. Dep.target = targetStack[targetStack.length - 1];
  43630. }
  43631. /* */
  43632. var VNode = function VNode (
  43633. tag,
  43634. data,
  43635. children,
  43636. text,
  43637. elm,
  43638. context,
  43639. componentOptions,
  43640. asyncFactory
  43641. ) {
  43642. this.tag = tag;
  43643. this.data = data;
  43644. this.children = children;
  43645. this.text = text;
  43646. this.elm = elm;
  43647. this.ns = undefined;
  43648. this.context = context;
  43649. this.fnContext = undefined;
  43650. this.fnOptions = undefined;
  43651. this.fnScopeId = undefined;
  43652. this.key = data && data.key;
  43653. this.componentOptions = componentOptions;
  43654. this.componentInstance = undefined;
  43655. this.parent = undefined;
  43656. this.raw = false;
  43657. this.isStatic = false;
  43658. this.isRootInsert = true;
  43659. this.isComment = false;
  43660. this.isCloned = false;
  43661. this.isOnce = false;
  43662. this.asyncFactory = asyncFactory;
  43663. this.asyncMeta = undefined;
  43664. this.isAsyncPlaceholder = false;
  43665. };
  43666. var prototypeAccessors = { child: { configurable: true } };
  43667. // DEPRECATED: alias for componentInstance for backwards compat.
  43668. /* istanbul ignore next */
  43669. prototypeAccessors.child.get = function () {
  43670. return this.componentInstance
  43671. };
  43672. Object.defineProperties( VNode.prototype, prototypeAccessors );
  43673. var createEmptyVNode = function (text) {
  43674. if ( text === void 0 ) text = '';
  43675. var node = new VNode();
  43676. node.text = text;
  43677. node.isComment = true;
  43678. return node
  43679. };
  43680. function createTextVNode (val) {
  43681. return new VNode(undefined, undefined, undefined, String(val))
  43682. }
  43683. // optimized shallow clone
  43684. // used for static nodes and slot nodes because they may be reused across
  43685. // multiple renders, cloning them avoids errors when DOM manipulations rely
  43686. // on their elm reference.
  43687. function cloneVNode (vnode) {
  43688. var cloned = new VNode(
  43689. vnode.tag,
  43690. vnode.data,
  43691. // #7975
  43692. // clone children array to avoid mutating original in case of cloning
  43693. // a child.
  43694. vnode.children && vnode.children.slice(),
  43695. vnode.text,
  43696. vnode.elm,
  43697. vnode.context,
  43698. vnode.componentOptions,
  43699. vnode.asyncFactory
  43700. );
  43701. cloned.ns = vnode.ns;
  43702. cloned.isStatic = vnode.isStatic;
  43703. cloned.key = vnode.key;
  43704. cloned.isComment = vnode.isComment;
  43705. cloned.fnContext = vnode.fnContext;
  43706. cloned.fnOptions = vnode.fnOptions;
  43707. cloned.fnScopeId = vnode.fnScopeId;
  43708. cloned.asyncMeta = vnode.asyncMeta;
  43709. cloned.isCloned = true;
  43710. return cloned
  43711. }
  43712. /*
  43713. * not type checking this file because flow doesn't play well with
  43714. * dynamically accessing methods on Array prototype
  43715. */
  43716. var arrayProto = Array.prototype;
  43717. var arrayMethods = Object.create(arrayProto);
  43718. var methodsToPatch = [
  43719. 'push',
  43720. 'pop',
  43721. 'shift',
  43722. 'unshift',
  43723. 'splice',
  43724. 'sort',
  43725. 'reverse'
  43726. ];
  43727. /**
  43728. * Intercept mutating methods and emit events
  43729. */
  43730. methodsToPatch.forEach(function (method) {
  43731. // cache original method
  43732. var original = arrayProto[method];
  43733. def(arrayMethods, method, function mutator () {
  43734. var args = [], len = arguments.length;
  43735. while ( len-- ) args[ len ] = arguments[ len ];
  43736. var result = original.apply(this, args);
  43737. var ob = this.__ob__;
  43738. var inserted;
  43739. switch (method) {
  43740. case 'push':
  43741. case 'unshift':
  43742. inserted = args;
  43743. break
  43744. case 'splice':
  43745. inserted = args.slice(2);
  43746. break
  43747. }
  43748. if (inserted) { ob.observeArray(inserted); }
  43749. // notify change
  43750. ob.dep.notify();
  43751. return result
  43752. });
  43753. });
  43754. /* */
  43755. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  43756. /**
  43757. * In some cases we may want to disable observation inside a component's
  43758. * update computation.
  43759. */
  43760. var shouldObserve = true;
  43761. function toggleObserving (value) {
  43762. shouldObserve = value;
  43763. }
  43764. /**
  43765. * Observer class that is attached to each observed
  43766. * object. Once attached, the observer converts the target
  43767. * object's property keys into getter/setters that
  43768. * collect dependencies and dispatch updates.
  43769. */
  43770. var Observer = function Observer (value) {
  43771. this.value = value;
  43772. this.dep = new Dep();
  43773. this.vmCount = 0;
  43774. def(value, '__ob__', this);
  43775. if (Array.isArray(value)) {
  43776. if (hasProto) {
  43777. protoAugment(value, arrayMethods);
  43778. } else {
  43779. copyAugment(value, arrayMethods, arrayKeys);
  43780. }
  43781. this.observeArray(value);
  43782. } else {
  43783. this.walk(value);
  43784. }
  43785. };
  43786. /**
  43787. * Walk through all properties and convert them into
  43788. * getter/setters. This method should only be called when
  43789. * value type is Object.
  43790. */
  43791. Observer.prototype.walk = function walk (obj) {
  43792. var keys = Object.keys(obj);
  43793. for (var i = 0; i < keys.length; i++) {
  43794. defineReactive$$1(obj, keys[i]);
  43795. }
  43796. };
  43797. /**
  43798. * Observe a list of Array items.
  43799. */
  43800. Observer.prototype.observeArray = function observeArray (items) {
  43801. for (var i = 0, l = items.length; i < l; i++) {
  43802. observe(items[i]);
  43803. }
  43804. };
  43805. // helpers
  43806. /**
  43807. * Augment a target Object or Array by intercepting
  43808. * the prototype chain using __proto__
  43809. */
  43810. function protoAugment (target, src) {
  43811. /* eslint-disable no-proto */
  43812. target.__proto__ = src;
  43813. /* eslint-enable no-proto */
  43814. }
  43815. /**
  43816. * Augment a target Object or Array by defining
  43817. * hidden properties.
  43818. */
  43819. /* istanbul ignore next */
  43820. function copyAugment (target, src, keys) {
  43821. for (var i = 0, l = keys.length; i < l; i++) {
  43822. var key = keys[i];
  43823. def(target, key, src[key]);
  43824. }
  43825. }
  43826. /**
  43827. * Attempt to create an observer instance for a value,
  43828. * returns the new observer if successfully observed,
  43829. * or the existing observer if the value already has one.
  43830. */
  43831. function observe (value, asRootData) {
  43832. if (!isObject(value) || value instanceof VNode) {
  43833. return
  43834. }
  43835. var ob;
  43836. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  43837. ob = value.__ob__;
  43838. } else if (
  43839. shouldObserve &&
  43840. !isServerRendering() &&
  43841. (Array.isArray(value) || isPlainObject(value)) &&
  43842. Object.isExtensible(value) &&
  43843. !value._isVue
  43844. ) {
  43845. ob = new Observer(value);
  43846. }
  43847. if (asRootData && ob) {
  43848. ob.vmCount++;
  43849. }
  43850. return ob
  43851. }
  43852. /**
  43853. * Define a reactive property on an Object.
  43854. */
  43855. function defineReactive$$1 (
  43856. obj,
  43857. key,
  43858. val,
  43859. customSetter,
  43860. shallow
  43861. ) {
  43862. var dep = new Dep();
  43863. var property = Object.getOwnPropertyDescriptor(obj, key);
  43864. if (property && property.configurable === false) {
  43865. return
  43866. }
  43867. // cater for pre-defined getter/setters
  43868. var getter = property && property.get;
  43869. var setter = property && property.set;
  43870. if ((!getter || setter) && arguments.length === 2) {
  43871. val = obj[key];
  43872. }
  43873. var childOb = !shallow && observe(val);
  43874. Object.defineProperty(obj, key, {
  43875. enumerable: true,
  43876. configurable: true,
  43877. get: function reactiveGetter () {
  43878. var value = getter ? getter.call(obj) : val;
  43879. if (Dep.target) {
  43880. dep.depend();
  43881. if (childOb) {
  43882. childOb.dep.depend();
  43883. if (Array.isArray(value)) {
  43884. dependArray(value);
  43885. }
  43886. }
  43887. }
  43888. return value
  43889. },
  43890. set: function reactiveSetter (newVal) {
  43891. var value = getter ? getter.call(obj) : val;
  43892. /* eslint-disable no-self-compare */
  43893. if (newVal === value || (newVal !== newVal && value !== value)) {
  43894. return
  43895. }
  43896. /* eslint-enable no-self-compare */
  43897. if (customSetter) {
  43898. customSetter();
  43899. }
  43900. // #7981: for accessor properties without setter
  43901. if (getter && !setter) { return }
  43902. if (setter) {
  43903. setter.call(obj, newVal);
  43904. } else {
  43905. val = newVal;
  43906. }
  43907. childOb = !shallow && observe(newVal);
  43908. dep.notify();
  43909. }
  43910. });
  43911. }
  43912. /**
  43913. * Set a property on an object. Adds the new property and
  43914. * triggers change notification if the property doesn't
  43915. * already exist.
  43916. */
  43917. function set (target, key, val) {
  43918. if (isUndef(target) || isPrimitive(target)
  43919. ) {
  43920. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  43921. }
  43922. if (Array.isArray(target) && isValidArrayIndex(key)) {
  43923. target.length = Math.max(target.length, key);
  43924. target.splice(key, 1, val);
  43925. return val
  43926. }
  43927. if (key in target && !(key in Object.prototype)) {
  43928. target[key] = val;
  43929. return val
  43930. }
  43931. var ob = (target).__ob__;
  43932. if (target._isVue || (ob && ob.vmCount)) {
  43933. warn(
  43934. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  43935. 'at runtime - declare it upfront in the data option.'
  43936. );
  43937. return val
  43938. }
  43939. if (!ob) {
  43940. target[key] = val;
  43941. return val
  43942. }
  43943. defineReactive$$1(ob.value, key, val);
  43944. ob.dep.notify();
  43945. return val
  43946. }
  43947. /**
  43948. * Delete a property and trigger change if necessary.
  43949. */
  43950. function del (target, key) {
  43951. if (isUndef(target) || isPrimitive(target)
  43952. ) {
  43953. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  43954. }
  43955. if (Array.isArray(target) && isValidArrayIndex(key)) {
  43956. target.splice(key, 1);
  43957. return
  43958. }
  43959. var ob = (target).__ob__;
  43960. if (target._isVue || (ob && ob.vmCount)) {
  43961. warn(
  43962. 'Avoid deleting properties on a Vue instance or its root $data ' +
  43963. '- just set it to null.'
  43964. );
  43965. return
  43966. }
  43967. if (!hasOwn(target, key)) {
  43968. return
  43969. }
  43970. delete target[key];
  43971. if (!ob) {
  43972. return
  43973. }
  43974. ob.dep.notify();
  43975. }
  43976. /**
  43977. * Collect dependencies on array elements when the array is touched, since
  43978. * we cannot intercept array element access like property getters.
  43979. */
  43980. function dependArray (value) {
  43981. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  43982. e = value[i];
  43983. e && e.__ob__ && e.__ob__.dep.depend();
  43984. if (Array.isArray(e)) {
  43985. dependArray(e);
  43986. }
  43987. }
  43988. }
  43989. /* */
  43990. /**
  43991. * Option overwriting strategies are functions that handle
  43992. * how to merge a parent option value and a child option
  43993. * value into the final value.
  43994. */
  43995. var strats = config.optionMergeStrategies;
  43996. /**
  43997. * Options with restrictions
  43998. */
  43999. {
  44000. strats.el = strats.propsData = function (parent, child, vm, key) {
  44001. if (!vm) {
  44002. warn(
  44003. "option \"" + key + "\" can only be used during instance " +
  44004. 'creation with the `new` keyword.'
  44005. );
  44006. }
  44007. return defaultStrat(parent, child)
  44008. };
  44009. }
  44010. /**
  44011. * Helper that recursively merges two data objects together.
  44012. */
  44013. function mergeData (to, from) {
  44014. if (!from) { return to }
  44015. var key, toVal, fromVal;
  44016. var keys = hasSymbol
  44017. ? Reflect.ownKeys(from)
  44018. : Object.keys(from);
  44019. for (var i = 0; i < keys.length; i++) {
  44020. key = keys[i];
  44021. // in case the object is already observed...
  44022. if (key === '__ob__') { continue }
  44023. toVal = to[key];
  44024. fromVal = from[key];
  44025. if (!hasOwn(to, key)) {
  44026. set(to, key, fromVal);
  44027. } else if (
  44028. toVal !== fromVal &&
  44029. isPlainObject(toVal) &&
  44030. isPlainObject(fromVal)
  44031. ) {
  44032. mergeData(toVal, fromVal);
  44033. }
  44034. }
  44035. return to
  44036. }
  44037. /**
  44038. * Data
  44039. */
  44040. function mergeDataOrFn (
  44041. parentVal,
  44042. childVal,
  44043. vm
  44044. ) {
  44045. if (!vm) {
  44046. // in a Vue.extend merge, both should be functions
  44047. if (!childVal) {
  44048. return parentVal
  44049. }
  44050. if (!parentVal) {
  44051. return childVal
  44052. }
  44053. // when parentVal & childVal are both present,
  44054. // we need to return a function that returns the
  44055. // merged result of both functions... no need to
  44056. // check if parentVal is a function here because
  44057. // it has to be a function to pass previous merges.
  44058. return function mergedDataFn () {
  44059. return mergeData(
  44060. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  44061. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  44062. )
  44063. }
  44064. } else {
  44065. return function mergedInstanceDataFn () {
  44066. // instance merge
  44067. var instanceData = typeof childVal === 'function'
  44068. ? childVal.call(vm, vm)
  44069. : childVal;
  44070. var defaultData = typeof parentVal === 'function'
  44071. ? parentVal.call(vm, vm)
  44072. : parentVal;
  44073. if (instanceData) {
  44074. return mergeData(instanceData, defaultData)
  44075. } else {
  44076. return defaultData
  44077. }
  44078. }
  44079. }
  44080. }
  44081. strats.data = function (
  44082. parentVal,
  44083. childVal,
  44084. vm
  44085. ) {
  44086. if (!vm) {
  44087. if (childVal && typeof childVal !== 'function') {
  44088. warn(
  44089. 'The "data" option should be a function ' +
  44090. 'that returns a per-instance value in component ' +
  44091. 'definitions.',
  44092. vm
  44093. );
  44094. return parentVal
  44095. }
  44096. return mergeDataOrFn(parentVal, childVal)
  44097. }
  44098. return mergeDataOrFn(parentVal, childVal, vm)
  44099. };
  44100. /**
  44101. * Hooks and props are merged as arrays.
  44102. */
  44103. function mergeHook (
  44104. parentVal,
  44105. childVal
  44106. ) {
  44107. var res = childVal
  44108. ? parentVal
  44109. ? parentVal.concat(childVal)
  44110. : Array.isArray(childVal)
  44111. ? childVal
  44112. : [childVal]
  44113. : parentVal;
  44114. return res
  44115. ? dedupeHooks(res)
  44116. : res
  44117. }
  44118. function dedupeHooks (hooks) {
  44119. var res = [];
  44120. for (var i = 0; i < hooks.length; i++) {
  44121. if (res.indexOf(hooks[i]) === -1) {
  44122. res.push(hooks[i]);
  44123. }
  44124. }
  44125. return res
  44126. }
  44127. LIFECYCLE_HOOKS.forEach(function (hook) {
  44128. strats[hook] = mergeHook;
  44129. });
  44130. /**
  44131. * Assets
  44132. *
  44133. * When a vm is present (instance creation), we need to do
  44134. * a three-way merge between constructor options, instance
  44135. * options and parent options.
  44136. */
  44137. function mergeAssets (
  44138. parentVal,
  44139. childVal,
  44140. vm,
  44141. key
  44142. ) {
  44143. var res = Object.create(parentVal || null);
  44144. if (childVal) {
  44145. assertObjectType(key, childVal, vm);
  44146. return extend(res, childVal)
  44147. } else {
  44148. return res
  44149. }
  44150. }
  44151. ASSET_TYPES.forEach(function (type) {
  44152. strats[type + 's'] = mergeAssets;
  44153. });
  44154. /**
  44155. * Watchers.
  44156. *
  44157. * Watchers hashes should not overwrite one
  44158. * another, so we merge them as arrays.
  44159. */
  44160. strats.watch = function (
  44161. parentVal,
  44162. childVal,
  44163. vm,
  44164. key
  44165. ) {
  44166. // work around Firefox's Object.prototype.watch...
  44167. if (parentVal === nativeWatch) { parentVal = undefined; }
  44168. if (childVal === nativeWatch) { childVal = undefined; }
  44169. /* istanbul ignore if */
  44170. if (!childVal) { return Object.create(parentVal || null) }
  44171. {
  44172. assertObjectType(key, childVal, vm);
  44173. }
  44174. if (!parentVal) { return childVal }
  44175. var ret = {};
  44176. extend(ret, parentVal);
  44177. for (var key$1 in childVal) {
  44178. var parent = ret[key$1];
  44179. var child = childVal[key$1];
  44180. if (parent && !Array.isArray(parent)) {
  44181. parent = [parent];
  44182. }
  44183. ret[key$1] = parent
  44184. ? parent.concat(child)
  44185. : Array.isArray(child) ? child : [child];
  44186. }
  44187. return ret
  44188. };
  44189. /**
  44190. * Other object hashes.
  44191. */
  44192. strats.props =
  44193. strats.methods =
  44194. strats.inject =
  44195. strats.computed = function (
  44196. parentVal,
  44197. childVal,
  44198. vm,
  44199. key
  44200. ) {
  44201. if (childVal && "development" !== 'production') {
  44202. assertObjectType(key, childVal, vm);
  44203. }
  44204. if (!parentVal) { return childVal }
  44205. var ret = Object.create(null);
  44206. extend(ret, parentVal);
  44207. if (childVal) { extend(ret, childVal); }
  44208. return ret
  44209. };
  44210. strats.provide = mergeDataOrFn;
  44211. /**
  44212. * Default strategy.
  44213. */
  44214. var defaultStrat = function (parentVal, childVal) {
  44215. return childVal === undefined
  44216. ? parentVal
  44217. : childVal
  44218. };
  44219. /**
  44220. * Validate component names
  44221. */
  44222. function checkComponents (options) {
  44223. for (var key in options.components) {
  44224. validateComponentName(key);
  44225. }
  44226. }
  44227. function validateComponentName (name) {
  44228. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  44229. warn(
  44230. 'Invalid component name: "' + name + '". Component names ' +
  44231. 'should conform to valid custom element name in html5 specification.'
  44232. );
  44233. }
  44234. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  44235. warn(
  44236. 'Do not use built-in or reserved HTML elements as component ' +
  44237. 'id: ' + name
  44238. );
  44239. }
  44240. }
  44241. /**
  44242. * Ensure all props option syntax are normalized into the
  44243. * Object-based format.
  44244. */
  44245. function normalizeProps (options, vm) {
  44246. var props = options.props;
  44247. if (!props) { return }
  44248. var res = {};
  44249. var i, val, name;
  44250. if (Array.isArray(props)) {
  44251. i = props.length;
  44252. while (i--) {
  44253. val = props[i];
  44254. if (typeof val === 'string') {
  44255. name = camelize(val);
  44256. res[name] = { type: null };
  44257. } else {
  44258. warn('props must be strings when using array syntax.');
  44259. }
  44260. }
  44261. } else if (isPlainObject(props)) {
  44262. for (var key in props) {
  44263. val = props[key];
  44264. name = camelize(key);
  44265. res[name] = isPlainObject(val)
  44266. ? val
  44267. : { type: val };
  44268. }
  44269. } else {
  44270. warn(
  44271. "Invalid value for option \"props\": expected an Array or an Object, " +
  44272. "but got " + (toRawType(props)) + ".",
  44273. vm
  44274. );
  44275. }
  44276. options.props = res;
  44277. }
  44278. /**
  44279. * Normalize all injections into Object-based format
  44280. */
  44281. function normalizeInject (options, vm) {
  44282. var inject = options.inject;
  44283. if (!inject) { return }
  44284. var normalized = options.inject = {};
  44285. if (Array.isArray(inject)) {
  44286. for (var i = 0; i < inject.length; i++) {
  44287. normalized[inject[i]] = { from: inject[i] };
  44288. }
  44289. } else if (isPlainObject(inject)) {
  44290. for (var key in inject) {
  44291. var val = inject[key];
  44292. normalized[key] = isPlainObject(val)
  44293. ? extend({ from: key }, val)
  44294. : { from: val };
  44295. }
  44296. } else {
  44297. warn(
  44298. "Invalid value for option \"inject\": expected an Array or an Object, " +
  44299. "but got " + (toRawType(inject)) + ".",
  44300. vm
  44301. );
  44302. }
  44303. }
  44304. /**
  44305. * Normalize raw function directives into object format.
  44306. */
  44307. function normalizeDirectives (options) {
  44308. var dirs = options.directives;
  44309. if (dirs) {
  44310. for (var key in dirs) {
  44311. var def$$1 = dirs[key];
  44312. if (typeof def$$1 === 'function') {
  44313. dirs[key] = { bind: def$$1, update: def$$1 };
  44314. }
  44315. }
  44316. }
  44317. }
  44318. function assertObjectType (name, value, vm) {
  44319. if (!isPlainObject(value)) {
  44320. warn(
  44321. "Invalid value for option \"" + name + "\": expected an Object, " +
  44322. "but got " + (toRawType(value)) + ".",
  44323. vm
  44324. );
  44325. }
  44326. }
  44327. /**
  44328. * Merge two option objects into a new one.
  44329. * Core utility used in both instantiation and inheritance.
  44330. */
  44331. function mergeOptions (
  44332. parent,
  44333. child,
  44334. vm
  44335. ) {
  44336. {
  44337. checkComponents(child);
  44338. }
  44339. if (typeof child === 'function') {
  44340. child = child.options;
  44341. }
  44342. normalizeProps(child, vm);
  44343. normalizeInject(child, vm);
  44344. normalizeDirectives(child);
  44345. // Apply extends and mixins on the child options,
  44346. // but only if it is a raw options object that isn't
  44347. // the result of another mergeOptions call.
  44348. // Only merged options has the _base property.
  44349. if (!child._base) {
  44350. if (child.extends) {
  44351. parent = mergeOptions(parent, child.extends, vm);
  44352. }
  44353. if (child.mixins) {
  44354. for (var i = 0, l = child.mixins.length; i < l; i++) {
  44355. parent = mergeOptions(parent, child.mixins[i], vm);
  44356. }
  44357. }
  44358. }
  44359. var options = {};
  44360. var key;
  44361. for (key in parent) {
  44362. mergeField(key);
  44363. }
  44364. for (key in child) {
  44365. if (!hasOwn(parent, key)) {
  44366. mergeField(key);
  44367. }
  44368. }
  44369. function mergeField (key) {
  44370. var strat = strats[key] || defaultStrat;
  44371. options[key] = strat(parent[key], child[key], vm, key);
  44372. }
  44373. return options
  44374. }
  44375. /**
  44376. * Resolve an asset.
  44377. * This function is used because child instances need access
  44378. * to assets defined in its ancestor chain.
  44379. */
  44380. function resolveAsset (
  44381. options,
  44382. type,
  44383. id,
  44384. warnMissing
  44385. ) {
  44386. /* istanbul ignore if */
  44387. if (typeof id !== 'string') {
  44388. return
  44389. }
  44390. var assets = options[type];
  44391. // check local registration variations first
  44392. if (hasOwn(assets, id)) { return assets[id] }
  44393. var camelizedId = camelize(id);
  44394. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  44395. var PascalCaseId = capitalize(camelizedId);
  44396. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  44397. // fallback to prototype chain
  44398. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  44399. if (warnMissing && !res) {
  44400. warn(
  44401. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  44402. options
  44403. );
  44404. }
  44405. return res
  44406. }
  44407. /* */
  44408. function validateProp (
  44409. key,
  44410. propOptions,
  44411. propsData,
  44412. vm
  44413. ) {
  44414. var prop = propOptions[key];
  44415. var absent = !hasOwn(propsData, key);
  44416. var value = propsData[key];
  44417. // boolean casting
  44418. var booleanIndex = getTypeIndex(Boolean, prop.type);
  44419. if (booleanIndex > -1) {
  44420. if (absent && !hasOwn(prop, 'default')) {
  44421. value = false;
  44422. } else if (value === '' || value === hyphenate(key)) {
  44423. // only cast empty string / same name to boolean if
  44424. // boolean has higher priority
  44425. var stringIndex = getTypeIndex(String, prop.type);
  44426. if (stringIndex < 0 || booleanIndex < stringIndex) {
  44427. value = true;
  44428. }
  44429. }
  44430. }
  44431. // check default value
  44432. if (value === undefined) {
  44433. value = getPropDefaultValue(vm, prop, key);
  44434. // since the default value is a fresh copy,
  44435. // make sure to observe it.
  44436. var prevShouldObserve = shouldObserve;
  44437. toggleObserving(true);
  44438. observe(value);
  44439. toggleObserving(prevShouldObserve);
  44440. }
  44441. {
  44442. assertProp(prop, key, value, vm, absent);
  44443. }
  44444. return value
  44445. }
  44446. /**
  44447. * Get the default value of a prop.
  44448. */
  44449. function getPropDefaultValue (vm, prop, key) {
  44450. // no default, return undefined
  44451. if (!hasOwn(prop, 'default')) {
  44452. return undefined
  44453. }
  44454. var def = prop.default;
  44455. // warn against non-factory defaults for Object & Array
  44456. if (isObject(def)) {
  44457. warn(
  44458. 'Invalid default value for prop "' + key + '": ' +
  44459. 'Props with type Object/Array must use a factory function ' +
  44460. 'to return the default value.',
  44461. vm
  44462. );
  44463. }
  44464. // the raw prop value was also undefined from previous render,
  44465. // return previous default value to avoid unnecessary watcher trigger
  44466. if (vm && vm.$options.propsData &&
  44467. vm.$options.propsData[key] === undefined &&
  44468. vm._props[key] !== undefined
  44469. ) {
  44470. return vm._props[key]
  44471. }
  44472. // call factory function for non-Function types
  44473. // a value is Function if its prototype is function even across different execution context
  44474. return typeof def === 'function' && getType(prop.type) !== 'Function'
  44475. ? def.call(vm)
  44476. : def
  44477. }
  44478. /**
  44479. * Assert whether a prop is valid.
  44480. */
  44481. function assertProp (
  44482. prop,
  44483. name,
  44484. value,
  44485. vm,
  44486. absent
  44487. ) {
  44488. if (prop.required && absent) {
  44489. warn(
  44490. 'Missing required prop: "' + name + '"',
  44491. vm
  44492. );
  44493. return
  44494. }
  44495. if (value == null && !prop.required) {
  44496. return
  44497. }
  44498. var type = prop.type;
  44499. var valid = !type || type === true;
  44500. var expectedTypes = [];
  44501. if (type) {
  44502. if (!Array.isArray(type)) {
  44503. type = [type];
  44504. }
  44505. for (var i = 0; i < type.length && !valid; i++) {
  44506. var assertedType = assertType(value, type[i]);
  44507. expectedTypes.push(assertedType.expectedType || '');
  44508. valid = assertedType.valid;
  44509. }
  44510. }
  44511. if (!valid) {
  44512. warn(
  44513. getInvalidTypeMessage(name, value, expectedTypes),
  44514. vm
  44515. );
  44516. return
  44517. }
  44518. var validator = prop.validator;
  44519. if (validator) {
  44520. if (!validator(value)) {
  44521. warn(
  44522. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  44523. vm
  44524. );
  44525. }
  44526. }
  44527. }
  44528. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  44529. function assertType (value, type) {
  44530. var valid;
  44531. var expectedType = getType(type);
  44532. if (simpleCheckRE.test(expectedType)) {
  44533. var t = typeof value;
  44534. valid = t === expectedType.toLowerCase();
  44535. // for primitive wrapper objects
  44536. if (!valid && t === 'object') {
  44537. valid = value instanceof type;
  44538. }
  44539. } else if (expectedType === 'Object') {
  44540. valid = isPlainObject(value);
  44541. } else if (expectedType === 'Array') {
  44542. valid = Array.isArray(value);
  44543. } else {
  44544. valid = value instanceof type;
  44545. }
  44546. return {
  44547. valid: valid,
  44548. expectedType: expectedType
  44549. }
  44550. }
  44551. /**
  44552. * Use function string name to check built-in types,
  44553. * because a simple equality check will fail when running
  44554. * across different vms / iframes.
  44555. */
  44556. function getType (fn) {
  44557. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  44558. return match ? match[1] : ''
  44559. }
  44560. function isSameType (a, b) {
  44561. return getType(a) === getType(b)
  44562. }
  44563. function getTypeIndex (type, expectedTypes) {
  44564. if (!Array.isArray(expectedTypes)) {
  44565. return isSameType(expectedTypes, type) ? 0 : -1
  44566. }
  44567. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  44568. if (isSameType(expectedTypes[i], type)) {
  44569. return i
  44570. }
  44571. }
  44572. return -1
  44573. }
  44574. function getInvalidTypeMessage (name, value, expectedTypes) {
  44575. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  44576. " Expected " + (expectedTypes.map(capitalize).join(', '));
  44577. var expectedType = expectedTypes[0];
  44578. var receivedType = toRawType(value);
  44579. var expectedValue = styleValue(value, expectedType);
  44580. var receivedValue = styleValue(value, receivedType);
  44581. // check if we need to specify expected value
  44582. if (expectedTypes.length === 1 &&
  44583. isExplicable(expectedType) &&
  44584. !isBoolean(expectedType, receivedType)) {
  44585. message += " with value " + expectedValue;
  44586. }
  44587. message += ", got " + receivedType + " ";
  44588. // check if we need to specify received value
  44589. if (isExplicable(receivedType)) {
  44590. message += "with value " + receivedValue + ".";
  44591. }
  44592. return message
  44593. }
  44594. function styleValue (value, type) {
  44595. if (type === 'String') {
  44596. return ("\"" + value + "\"")
  44597. } else if (type === 'Number') {
  44598. return ("" + (Number(value)))
  44599. } else {
  44600. return ("" + value)
  44601. }
  44602. }
  44603. function isExplicable (value) {
  44604. var explicitTypes = ['string', 'number', 'boolean'];
  44605. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  44606. }
  44607. function isBoolean () {
  44608. var args = [], len = arguments.length;
  44609. while ( len-- ) args[ len ] = arguments[ len ];
  44610. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  44611. }
  44612. /* */
  44613. function handleError (err, vm, info) {
  44614. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  44615. // See: https://github.com/vuejs/vuex/issues/1505
  44616. pushTarget();
  44617. try {
  44618. if (vm) {
  44619. var cur = vm;
  44620. while ((cur = cur.$parent)) {
  44621. var hooks = cur.$options.errorCaptured;
  44622. if (hooks) {
  44623. for (var i = 0; i < hooks.length; i++) {
  44624. try {
  44625. var capture = hooks[i].call(cur, err, vm, info) === false;
  44626. if (capture) { return }
  44627. } catch (e) {
  44628. globalHandleError(e, cur, 'errorCaptured hook');
  44629. }
  44630. }
  44631. }
  44632. }
  44633. }
  44634. globalHandleError(err, vm, info);
  44635. } finally {
  44636. popTarget();
  44637. }
  44638. }
  44639. function invokeWithErrorHandling (
  44640. handler,
  44641. context,
  44642. args,
  44643. vm,
  44644. info
  44645. ) {
  44646. var res;
  44647. try {
  44648. res = args ? handler.apply(context, args) : handler.call(context);
  44649. if (res && !res._isVue && isPromise(res) && !res._handled) {
  44650. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  44651. // issue #9511
  44652. // avoid catch triggering multiple times when nested calls
  44653. res._handled = true;
  44654. }
  44655. } catch (e) {
  44656. handleError(e, vm, info);
  44657. }
  44658. return res
  44659. }
  44660. function globalHandleError (err, vm, info) {
  44661. if (config.errorHandler) {
  44662. try {
  44663. return config.errorHandler.call(null, err, vm, info)
  44664. } catch (e) {
  44665. // if the user intentionally throws the original error in the handler,
  44666. // do not log it twice
  44667. if (e !== err) {
  44668. logError(e, null, 'config.errorHandler');
  44669. }
  44670. }
  44671. }
  44672. logError(err, vm, info);
  44673. }
  44674. function logError (err, vm, info) {
  44675. {
  44676. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  44677. }
  44678. /* istanbul ignore else */
  44679. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  44680. console.error(err);
  44681. } else {
  44682. throw err
  44683. }
  44684. }
  44685. /* */
  44686. var isUsingMicroTask = false;
  44687. var callbacks = [];
  44688. var pending = false;
  44689. function flushCallbacks () {
  44690. pending = false;
  44691. var copies = callbacks.slice(0);
  44692. callbacks.length = 0;
  44693. for (var i = 0; i < copies.length; i++) {
  44694. copies[i]();
  44695. }
  44696. }
  44697. // Here we have async deferring wrappers using microtasks.
  44698. // In 2.5 we used (macro) tasks (in combination with microtasks).
  44699. // However, it has subtle problems when state is changed right before repaint
  44700. // (e.g. #6813, out-in transitions).
  44701. // Also, using (macro) tasks in event handler would cause some weird behaviors
  44702. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  44703. // So we now use microtasks everywhere, again.
  44704. // A major drawback of this tradeoff is that there are some scenarios
  44705. // where microtasks have too high a priority and fire in between supposedly
  44706. // sequential events (e.g. #4521, #6690, which have workarounds)
  44707. // or even between bubbling of the same event (#6566).
  44708. var timerFunc;
  44709. // The nextTick behavior leverages the microtask queue, which can be accessed
  44710. // via either native Promise.then or MutationObserver.
  44711. // MutationObserver has wider support, however it is seriously bugged in
  44712. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  44713. // completely stops working after triggering a few times... so, if native
  44714. // Promise is available, we will use it:
  44715. /* istanbul ignore next, $flow-disable-line */
  44716. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  44717. var p = Promise.resolve();
  44718. timerFunc = function () {
  44719. p.then(flushCallbacks);
  44720. // In problematic UIWebViews, Promise.then doesn't completely break, but
  44721. // it can get stuck in a weird state where callbacks are pushed into the
  44722. // microtask queue but the queue isn't being flushed, until the browser
  44723. // needs to do some other work, e.g. handle a timer. Therefore we can
  44724. // "force" the microtask queue to be flushed by adding an empty timer.
  44725. if (isIOS) { setTimeout(noop); }
  44726. };
  44727. isUsingMicroTask = true;
  44728. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  44729. isNative(MutationObserver) ||
  44730. // PhantomJS and iOS 7.x
  44731. MutationObserver.toString() === '[object MutationObserverConstructor]'
  44732. )) {
  44733. // Use MutationObserver where native Promise is not available,
  44734. // e.g. PhantomJS, iOS7, Android 4.4
  44735. // (#6466 MutationObserver is unreliable in IE11)
  44736. var counter = 1;
  44737. var observer = new MutationObserver(flushCallbacks);
  44738. var textNode = document.createTextNode(String(counter));
  44739. observer.observe(textNode, {
  44740. characterData: true
  44741. });
  44742. timerFunc = function () {
  44743. counter = (counter + 1) % 2;
  44744. textNode.data = String(counter);
  44745. };
  44746. isUsingMicroTask = true;
  44747. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  44748. // Fallback to setImmediate.
  44749. // Technically it leverages the (macro) task queue,
  44750. // but it is still a better choice than setTimeout.
  44751. timerFunc = function () {
  44752. setImmediate(flushCallbacks);
  44753. };
  44754. } else {
  44755. // Fallback to setTimeout.
  44756. timerFunc = function () {
  44757. setTimeout(flushCallbacks, 0);
  44758. };
  44759. }
  44760. function nextTick (cb, ctx) {
  44761. var _resolve;
  44762. callbacks.push(function () {
  44763. if (cb) {
  44764. try {
  44765. cb.call(ctx);
  44766. } catch (e) {
  44767. handleError(e, ctx, 'nextTick');
  44768. }
  44769. } else if (_resolve) {
  44770. _resolve(ctx);
  44771. }
  44772. });
  44773. if (!pending) {
  44774. pending = true;
  44775. timerFunc();
  44776. }
  44777. // $flow-disable-line
  44778. if (!cb && typeof Promise !== 'undefined') {
  44779. return new Promise(function (resolve) {
  44780. _resolve = resolve;
  44781. })
  44782. }
  44783. }
  44784. /* */
  44785. var mark;
  44786. var measure;
  44787. {
  44788. var perf = inBrowser && window.performance;
  44789. /* istanbul ignore if */
  44790. if (
  44791. perf &&
  44792. perf.mark &&
  44793. perf.measure &&
  44794. perf.clearMarks &&
  44795. perf.clearMeasures
  44796. ) {
  44797. mark = function (tag) { return perf.mark(tag); };
  44798. measure = function (name, startTag, endTag) {
  44799. perf.measure(name, startTag, endTag);
  44800. perf.clearMarks(startTag);
  44801. perf.clearMarks(endTag);
  44802. // perf.clearMeasures(name)
  44803. };
  44804. }
  44805. }
  44806. /* not type checking this file because flow doesn't play well with Proxy */
  44807. var initProxy;
  44808. {
  44809. var allowedGlobals = makeMap(
  44810. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  44811. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  44812. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  44813. 'require' // for Webpack/Browserify
  44814. );
  44815. var warnNonPresent = function (target, key) {
  44816. warn(
  44817. "Property or method \"" + key + "\" is not defined on the instance but " +
  44818. 'referenced during render. Make sure that this property is reactive, ' +
  44819. 'either in the data option, or for class-based components, by ' +
  44820. 'initializing the property. ' +
  44821. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  44822. target
  44823. );
  44824. };
  44825. var warnReservedPrefix = function (target, key) {
  44826. warn(
  44827. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  44828. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  44829. 'prevent conflicts with Vue internals. ' +
  44830. 'See: https://vuejs.org/v2/api/#data',
  44831. target
  44832. );
  44833. };
  44834. var hasProxy =
  44835. typeof Proxy !== 'undefined' && isNative(Proxy);
  44836. if (hasProxy) {
  44837. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  44838. config.keyCodes = new Proxy(config.keyCodes, {
  44839. set: function set (target, key, value) {
  44840. if (isBuiltInModifier(key)) {
  44841. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  44842. return false
  44843. } else {
  44844. target[key] = value;
  44845. return true
  44846. }
  44847. }
  44848. });
  44849. }
  44850. var hasHandler = {
  44851. has: function has (target, key) {
  44852. var has = key in target;
  44853. var isAllowed = allowedGlobals(key) ||
  44854. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  44855. if (!has && !isAllowed) {
  44856. if (key in target.$data) { warnReservedPrefix(target, key); }
  44857. else { warnNonPresent(target, key); }
  44858. }
  44859. return has || !isAllowed
  44860. }
  44861. };
  44862. var getHandler = {
  44863. get: function get (target, key) {
  44864. if (typeof key === 'string' && !(key in target)) {
  44865. if (key in target.$data) { warnReservedPrefix(target, key); }
  44866. else { warnNonPresent(target, key); }
  44867. }
  44868. return target[key]
  44869. }
  44870. };
  44871. initProxy = function initProxy (vm) {
  44872. if (hasProxy) {
  44873. // determine which proxy handler to use
  44874. var options = vm.$options;
  44875. var handlers = options.render && options.render._withStripped
  44876. ? getHandler
  44877. : hasHandler;
  44878. vm._renderProxy = new Proxy(vm, handlers);
  44879. } else {
  44880. vm._renderProxy = vm;
  44881. }
  44882. };
  44883. }
  44884. /* */
  44885. var seenObjects = new _Set();
  44886. /**
  44887. * Recursively traverse an object to evoke all converted
  44888. * getters, so that every nested property inside the object
  44889. * is collected as a "deep" dependency.
  44890. */
  44891. function traverse (val) {
  44892. _traverse(val, seenObjects);
  44893. seenObjects.clear();
  44894. }
  44895. function _traverse (val, seen) {
  44896. var i, keys;
  44897. var isA = Array.isArray(val);
  44898. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  44899. return
  44900. }
  44901. if (val.__ob__) {
  44902. var depId = val.__ob__.dep.id;
  44903. if (seen.has(depId)) {
  44904. return
  44905. }
  44906. seen.add(depId);
  44907. }
  44908. if (isA) {
  44909. i = val.length;
  44910. while (i--) { _traverse(val[i], seen); }
  44911. } else {
  44912. keys = Object.keys(val);
  44913. i = keys.length;
  44914. while (i--) { _traverse(val[keys[i]], seen); }
  44915. }
  44916. }
  44917. /* */
  44918. var normalizeEvent = cached(function (name) {
  44919. var passive = name.charAt(0) === '&';
  44920. name = passive ? name.slice(1) : name;
  44921. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  44922. name = once$$1 ? name.slice(1) : name;
  44923. var capture = name.charAt(0) === '!';
  44924. name = capture ? name.slice(1) : name;
  44925. return {
  44926. name: name,
  44927. once: once$$1,
  44928. capture: capture,
  44929. passive: passive
  44930. }
  44931. });
  44932. function createFnInvoker (fns, vm) {
  44933. function invoker () {
  44934. var arguments$1 = arguments;
  44935. var fns = invoker.fns;
  44936. if (Array.isArray(fns)) {
  44937. var cloned = fns.slice();
  44938. for (var i = 0; i < cloned.length; i++) {
  44939. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  44940. }
  44941. } else {
  44942. // return handler return value for single handlers
  44943. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  44944. }
  44945. }
  44946. invoker.fns = fns;
  44947. return invoker
  44948. }
  44949. function updateListeners (
  44950. on,
  44951. oldOn,
  44952. add,
  44953. remove$$1,
  44954. createOnceHandler,
  44955. vm
  44956. ) {
  44957. var name, def$$1, cur, old, event;
  44958. for (name in on) {
  44959. def$$1 = cur = on[name];
  44960. old = oldOn[name];
  44961. event = normalizeEvent(name);
  44962. if (isUndef(cur)) {
  44963. warn(
  44964. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  44965. vm
  44966. );
  44967. } else if (isUndef(old)) {
  44968. if (isUndef(cur.fns)) {
  44969. cur = on[name] = createFnInvoker(cur, vm);
  44970. }
  44971. if (isTrue(event.once)) {
  44972. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  44973. }
  44974. add(event.name, cur, event.capture, event.passive, event.params);
  44975. } else if (cur !== old) {
  44976. old.fns = cur;
  44977. on[name] = old;
  44978. }
  44979. }
  44980. for (name in oldOn) {
  44981. if (isUndef(on[name])) {
  44982. event = normalizeEvent(name);
  44983. remove$$1(event.name, oldOn[name], event.capture);
  44984. }
  44985. }
  44986. }
  44987. /* */
  44988. function mergeVNodeHook (def, hookKey, hook) {
  44989. if (def instanceof VNode) {
  44990. def = def.data.hook || (def.data.hook = {});
  44991. }
  44992. var invoker;
  44993. var oldHook = def[hookKey];
  44994. function wrappedHook () {
  44995. hook.apply(this, arguments);
  44996. // important: remove merged hook to ensure it's called only once
  44997. // and prevent memory leak
  44998. remove(invoker.fns, wrappedHook);
  44999. }
  45000. if (isUndef(oldHook)) {
  45001. // no existing hook
  45002. invoker = createFnInvoker([wrappedHook]);
  45003. } else {
  45004. /* istanbul ignore if */
  45005. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  45006. // already a merged invoker
  45007. invoker = oldHook;
  45008. invoker.fns.push(wrappedHook);
  45009. } else {
  45010. // existing plain hook
  45011. invoker = createFnInvoker([oldHook, wrappedHook]);
  45012. }
  45013. }
  45014. invoker.merged = true;
  45015. def[hookKey] = invoker;
  45016. }
  45017. /* */
  45018. function extractPropsFromVNodeData (
  45019. data,
  45020. Ctor,
  45021. tag
  45022. ) {
  45023. // we are only extracting raw values here.
  45024. // validation and default values are handled in the child
  45025. // component itself.
  45026. var propOptions = Ctor.options.props;
  45027. if (isUndef(propOptions)) {
  45028. return
  45029. }
  45030. var res = {};
  45031. var attrs = data.attrs;
  45032. var props = data.props;
  45033. if (isDef(attrs) || isDef(props)) {
  45034. for (var key in propOptions) {
  45035. var altKey = hyphenate(key);
  45036. {
  45037. var keyInLowerCase = key.toLowerCase();
  45038. if (
  45039. key !== keyInLowerCase &&
  45040. attrs && hasOwn(attrs, keyInLowerCase)
  45041. ) {
  45042. tip(
  45043. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  45044. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  45045. " \"" + key + "\". " +
  45046. "Note that HTML attributes are case-insensitive and camelCased " +
  45047. "props need to use their kebab-case equivalents when using in-DOM " +
  45048. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  45049. );
  45050. }
  45051. }
  45052. checkProp(res, props, key, altKey, true) ||
  45053. checkProp(res, attrs, key, altKey, false);
  45054. }
  45055. }
  45056. return res
  45057. }
  45058. function checkProp (
  45059. res,
  45060. hash,
  45061. key,
  45062. altKey,
  45063. preserve
  45064. ) {
  45065. if (isDef(hash)) {
  45066. if (hasOwn(hash, key)) {
  45067. res[key] = hash[key];
  45068. if (!preserve) {
  45069. delete hash[key];
  45070. }
  45071. return true
  45072. } else if (hasOwn(hash, altKey)) {
  45073. res[key] = hash[altKey];
  45074. if (!preserve) {
  45075. delete hash[altKey];
  45076. }
  45077. return true
  45078. }
  45079. }
  45080. return false
  45081. }
  45082. /* */
  45083. // The template compiler attempts to minimize the need for normalization by
  45084. // statically analyzing the template at compile time.
  45085. //
  45086. // For plain HTML markup, normalization can be completely skipped because the
  45087. // generated render function is guaranteed to return Array<VNode>. There are
  45088. // two cases where extra normalization is needed:
  45089. // 1. When the children contains components - because a functional component
  45090. // may return an Array instead of a single root. In this case, just a simple
  45091. // normalization is needed - if any child is an Array, we flatten the whole
  45092. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  45093. // because functional components already normalize their own children.
  45094. function simpleNormalizeChildren (children) {
  45095. for (var i = 0; i < children.length; i++) {
  45096. if (Array.isArray(children[i])) {
  45097. return Array.prototype.concat.apply([], children)
  45098. }
  45099. }
  45100. return children
  45101. }
  45102. // 2. When the children contains constructs that always generated nested Arrays,
  45103. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  45104. // with hand-written render functions / JSX. In such cases a full normalization
  45105. // is needed to cater to all possible types of children values.
  45106. function normalizeChildren (children) {
  45107. return isPrimitive(children)
  45108. ? [createTextVNode(children)]
  45109. : Array.isArray(children)
  45110. ? normalizeArrayChildren(children)
  45111. : undefined
  45112. }
  45113. function isTextNode (node) {
  45114. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  45115. }
  45116. function normalizeArrayChildren (children, nestedIndex) {
  45117. var res = [];
  45118. var i, c, lastIndex, last;
  45119. for (i = 0; i < children.length; i++) {
  45120. c = children[i];
  45121. if (isUndef(c) || typeof c === 'boolean') { continue }
  45122. lastIndex = res.length - 1;
  45123. last = res[lastIndex];
  45124. // nested
  45125. if (Array.isArray(c)) {
  45126. if (c.length > 0) {
  45127. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  45128. // merge adjacent text nodes
  45129. if (isTextNode(c[0]) && isTextNode(last)) {
  45130. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  45131. c.shift();
  45132. }
  45133. res.push.apply(res, c);
  45134. }
  45135. } else if (isPrimitive(c)) {
  45136. if (isTextNode(last)) {
  45137. // merge adjacent text nodes
  45138. // this is necessary for SSR hydration because text nodes are
  45139. // essentially merged when rendered to HTML strings
  45140. res[lastIndex] = createTextVNode(last.text + c);
  45141. } else if (c !== '') {
  45142. // convert primitive to vnode
  45143. res.push(createTextVNode(c));
  45144. }
  45145. } else {
  45146. if (isTextNode(c) && isTextNode(last)) {
  45147. // merge adjacent text nodes
  45148. res[lastIndex] = createTextVNode(last.text + c.text);
  45149. } else {
  45150. // default key for nested array children (likely generated by v-for)
  45151. if (isTrue(children._isVList) &&
  45152. isDef(c.tag) &&
  45153. isUndef(c.key) &&
  45154. isDef(nestedIndex)) {
  45155. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  45156. }
  45157. res.push(c);
  45158. }
  45159. }
  45160. }
  45161. return res
  45162. }
  45163. /* */
  45164. function initProvide (vm) {
  45165. var provide = vm.$options.provide;
  45166. if (provide) {
  45167. vm._provided = typeof provide === 'function'
  45168. ? provide.call(vm)
  45169. : provide;
  45170. }
  45171. }
  45172. function initInjections (vm) {
  45173. var result = resolveInject(vm.$options.inject, vm);
  45174. if (result) {
  45175. toggleObserving(false);
  45176. Object.keys(result).forEach(function (key) {
  45177. /* istanbul ignore else */
  45178. {
  45179. defineReactive$$1(vm, key, result[key], function () {
  45180. warn(
  45181. "Avoid mutating an injected value directly since the changes will be " +
  45182. "overwritten whenever the provided component re-renders. " +
  45183. "injection being mutated: \"" + key + "\"",
  45184. vm
  45185. );
  45186. });
  45187. }
  45188. });
  45189. toggleObserving(true);
  45190. }
  45191. }
  45192. function resolveInject (inject, vm) {
  45193. if (inject) {
  45194. // inject is :any because flow is not smart enough to figure out cached
  45195. var result = Object.create(null);
  45196. var keys = hasSymbol
  45197. ? Reflect.ownKeys(inject)
  45198. : Object.keys(inject);
  45199. for (var i = 0; i < keys.length; i++) {
  45200. var key = keys[i];
  45201. // #6574 in case the inject object is observed...
  45202. if (key === '__ob__') { continue }
  45203. var provideKey = inject[key].from;
  45204. var source = vm;
  45205. while (source) {
  45206. if (source._provided && hasOwn(source._provided, provideKey)) {
  45207. result[key] = source._provided[provideKey];
  45208. break
  45209. }
  45210. source = source.$parent;
  45211. }
  45212. if (!source) {
  45213. if ('default' in inject[key]) {
  45214. var provideDefault = inject[key].default;
  45215. result[key] = typeof provideDefault === 'function'
  45216. ? provideDefault.call(vm)
  45217. : provideDefault;
  45218. } else {
  45219. warn(("Injection \"" + key + "\" not found"), vm);
  45220. }
  45221. }
  45222. }
  45223. return result
  45224. }
  45225. }
  45226. /* */
  45227. /**
  45228. * Runtime helper for resolving raw children VNodes into a slot object.
  45229. */
  45230. function resolveSlots (
  45231. children,
  45232. context
  45233. ) {
  45234. if (!children || !children.length) {
  45235. return {}
  45236. }
  45237. var slots = {};
  45238. for (var i = 0, l = children.length; i < l; i++) {
  45239. var child = children[i];
  45240. var data = child.data;
  45241. // remove slot attribute if the node is resolved as a Vue slot node
  45242. if (data && data.attrs && data.attrs.slot) {
  45243. delete data.attrs.slot;
  45244. }
  45245. // named slots should only be respected if the vnode was rendered in the
  45246. // same context.
  45247. if ((child.context === context || child.fnContext === context) &&
  45248. data && data.slot != null
  45249. ) {
  45250. var name = data.slot;
  45251. var slot = (slots[name] || (slots[name] = []));
  45252. if (child.tag === 'template') {
  45253. slot.push.apply(slot, child.children || []);
  45254. } else {
  45255. slot.push(child);
  45256. }
  45257. } else {
  45258. (slots.default || (slots.default = [])).push(child);
  45259. }
  45260. }
  45261. // ignore slots that contains only whitespace
  45262. for (var name$1 in slots) {
  45263. if (slots[name$1].every(isWhitespace)) {
  45264. delete slots[name$1];
  45265. }
  45266. }
  45267. return slots
  45268. }
  45269. function isWhitespace (node) {
  45270. return (node.isComment && !node.asyncFactory) || node.text === ' '
  45271. }
  45272. /* */
  45273. function normalizeScopedSlots (
  45274. slots,
  45275. normalSlots,
  45276. prevSlots
  45277. ) {
  45278. var res;
  45279. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  45280. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  45281. var key = slots && slots.$key;
  45282. if (!slots) {
  45283. res = {};
  45284. } else if (slots._normalized) {
  45285. // fast path 1: child component re-render only, parent did not change
  45286. return slots._normalized
  45287. } else if (
  45288. isStable &&
  45289. prevSlots &&
  45290. prevSlots !== emptyObject &&
  45291. key === prevSlots.$key &&
  45292. !hasNormalSlots &&
  45293. !prevSlots.$hasNormal
  45294. ) {
  45295. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  45296. // only need to normalize once
  45297. return prevSlots
  45298. } else {
  45299. res = {};
  45300. for (var key$1 in slots) {
  45301. if (slots[key$1] && key$1[0] !== '$') {
  45302. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  45303. }
  45304. }
  45305. }
  45306. // expose normal slots on scopedSlots
  45307. for (var key$2 in normalSlots) {
  45308. if (!(key$2 in res)) {
  45309. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  45310. }
  45311. }
  45312. // avoriaz seems to mock a non-extensible $scopedSlots object
  45313. // and when that is passed down this would cause an error
  45314. if (slots && Object.isExtensible(slots)) {
  45315. (slots)._normalized = res;
  45316. }
  45317. def(res, '$stable', isStable);
  45318. def(res, '$key', key);
  45319. def(res, '$hasNormal', hasNormalSlots);
  45320. return res
  45321. }
  45322. function normalizeScopedSlot(normalSlots, key, fn) {
  45323. var normalized = function () {
  45324. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  45325. res = res && typeof res === 'object' && !Array.isArray(res)
  45326. ? [res] // single vnode
  45327. : normalizeChildren(res);
  45328. return res && (
  45329. res.length === 0 ||
  45330. (res.length === 1 && res[0].isComment) // #9658
  45331. ) ? undefined
  45332. : res
  45333. };
  45334. // this is a slot using the new v-slot syntax without scope. although it is
  45335. // compiled as a scoped slot, render fn users would expect it to be present
  45336. // on this.$slots because the usage is semantically a normal slot.
  45337. if (fn.proxy) {
  45338. Object.defineProperty(normalSlots, key, {
  45339. get: normalized,
  45340. enumerable: true,
  45341. configurable: true
  45342. });
  45343. }
  45344. return normalized
  45345. }
  45346. function proxyNormalSlot(slots, key) {
  45347. return function () { return slots[key]; }
  45348. }
  45349. /* */
  45350. /**
  45351. * Runtime helper for rendering v-for lists.
  45352. */
  45353. function renderList (
  45354. val,
  45355. render
  45356. ) {
  45357. var ret, i, l, keys, key;
  45358. if (Array.isArray(val) || typeof val === 'string') {
  45359. ret = new Array(val.length);
  45360. for (i = 0, l = val.length; i < l; i++) {
  45361. ret[i] = render(val[i], i);
  45362. }
  45363. } else if (typeof val === 'number') {
  45364. ret = new Array(val);
  45365. for (i = 0; i < val; i++) {
  45366. ret[i] = render(i + 1, i);
  45367. }
  45368. } else if (isObject(val)) {
  45369. if (hasSymbol && val[Symbol.iterator]) {
  45370. ret = [];
  45371. var iterator = val[Symbol.iterator]();
  45372. var result = iterator.next();
  45373. while (!result.done) {
  45374. ret.push(render(result.value, ret.length));
  45375. result = iterator.next();
  45376. }
  45377. } else {
  45378. keys = Object.keys(val);
  45379. ret = new Array(keys.length);
  45380. for (i = 0, l = keys.length; i < l; i++) {
  45381. key = keys[i];
  45382. ret[i] = render(val[key], key, i);
  45383. }
  45384. }
  45385. }
  45386. if (!isDef(ret)) {
  45387. ret = [];
  45388. }
  45389. (ret)._isVList = true;
  45390. return ret
  45391. }
  45392. /* */
  45393. /**
  45394. * Runtime helper for rendering <slot>
  45395. */
  45396. function renderSlot (
  45397. name,
  45398. fallback,
  45399. props,
  45400. bindObject
  45401. ) {
  45402. var scopedSlotFn = this.$scopedSlots[name];
  45403. var nodes;
  45404. if (scopedSlotFn) { // scoped slot
  45405. props = props || {};
  45406. if (bindObject) {
  45407. if (!isObject(bindObject)) {
  45408. warn(
  45409. 'slot v-bind without argument expects an Object',
  45410. this
  45411. );
  45412. }
  45413. props = extend(extend({}, bindObject), props);
  45414. }
  45415. nodes = scopedSlotFn(props) || fallback;
  45416. } else {
  45417. nodes = this.$slots[name] || fallback;
  45418. }
  45419. var target = props && props.slot;
  45420. if (target) {
  45421. return this.$createElement('template', { slot: target }, nodes)
  45422. } else {
  45423. return nodes
  45424. }
  45425. }
  45426. /* */
  45427. /**
  45428. * Runtime helper for resolving filters
  45429. */
  45430. function resolveFilter (id) {
  45431. return resolveAsset(this.$options, 'filters', id, true) || identity
  45432. }
  45433. /* */
  45434. function isKeyNotMatch (expect, actual) {
  45435. if (Array.isArray(expect)) {
  45436. return expect.indexOf(actual) === -1
  45437. } else {
  45438. return expect !== actual
  45439. }
  45440. }
  45441. /**
  45442. * Runtime helper for checking keyCodes from config.
  45443. * exposed as Vue.prototype._k
  45444. * passing in eventKeyName as last argument separately for backwards compat
  45445. */
  45446. function checkKeyCodes (
  45447. eventKeyCode,
  45448. key,
  45449. builtInKeyCode,
  45450. eventKeyName,
  45451. builtInKeyName
  45452. ) {
  45453. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  45454. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  45455. return isKeyNotMatch(builtInKeyName, eventKeyName)
  45456. } else if (mappedKeyCode) {
  45457. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  45458. } else if (eventKeyName) {
  45459. return hyphenate(eventKeyName) !== key
  45460. }
  45461. }
  45462. /* */
  45463. /**
  45464. * Runtime helper for merging v-bind="object" into a VNode's data.
  45465. */
  45466. function bindObjectProps (
  45467. data,
  45468. tag,
  45469. value,
  45470. asProp,
  45471. isSync
  45472. ) {
  45473. if (value) {
  45474. if (!isObject(value)) {
  45475. warn(
  45476. 'v-bind without argument expects an Object or Array value',
  45477. this
  45478. );
  45479. } else {
  45480. if (Array.isArray(value)) {
  45481. value = toObject(value);
  45482. }
  45483. var hash;
  45484. var loop = function ( key ) {
  45485. if (
  45486. key === 'class' ||
  45487. key === 'style' ||
  45488. isReservedAttribute(key)
  45489. ) {
  45490. hash = data;
  45491. } else {
  45492. var type = data.attrs && data.attrs.type;
  45493. hash = asProp || config.mustUseProp(tag, type, key)
  45494. ? data.domProps || (data.domProps = {})
  45495. : data.attrs || (data.attrs = {});
  45496. }
  45497. var camelizedKey = camelize(key);
  45498. var hyphenatedKey = hyphenate(key);
  45499. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  45500. hash[key] = value[key];
  45501. if (isSync) {
  45502. var on = data.on || (data.on = {});
  45503. on[("update:" + key)] = function ($event) {
  45504. value[key] = $event;
  45505. };
  45506. }
  45507. }
  45508. };
  45509. for (var key in value) loop( key );
  45510. }
  45511. }
  45512. return data
  45513. }
  45514. /* */
  45515. /**
  45516. * Runtime helper for rendering static trees.
  45517. */
  45518. function renderStatic (
  45519. index,
  45520. isInFor
  45521. ) {
  45522. var cached = this._staticTrees || (this._staticTrees = []);
  45523. var tree = cached[index];
  45524. // if has already-rendered static tree and not inside v-for,
  45525. // we can reuse the same tree.
  45526. if (tree && !isInFor) {
  45527. return tree
  45528. }
  45529. // otherwise, render a fresh tree.
  45530. tree = cached[index] = this.$options.staticRenderFns[index].call(
  45531. this._renderProxy,
  45532. null,
  45533. this // for render fns generated for functional component templates
  45534. );
  45535. markStatic(tree, ("__static__" + index), false);
  45536. return tree
  45537. }
  45538. /**
  45539. * Runtime helper for v-once.
  45540. * Effectively it means marking the node as static with a unique key.
  45541. */
  45542. function markOnce (
  45543. tree,
  45544. index,
  45545. key
  45546. ) {
  45547. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  45548. return tree
  45549. }
  45550. function markStatic (
  45551. tree,
  45552. key,
  45553. isOnce
  45554. ) {
  45555. if (Array.isArray(tree)) {
  45556. for (var i = 0; i < tree.length; i++) {
  45557. if (tree[i] && typeof tree[i] !== 'string') {
  45558. markStaticNode(tree[i], (key + "_" + i), isOnce);
  45559. }
  45560. }
  45561. } else {
  45562. markStaticNode(tree, key, isOnce);
  45563. }
  45564. }
  45565. function markStaticNode (node, key, isOnce) {
  45566. node.isStatic = true;
  45567. node.key = key;
  45568. node.isOnce = isOnce;
  45569. }
  45570. /* */
  45571. function bindObjectListeners (data, value) {
  45572. if (value) {
  45573. if (!isPlainObject(value)) {
  45574. warn(
  45575. 'v-on without argument expects an Object value',
  45576. this
  45577. );
  45578. } else {
  45579. var on = data.on = data.on ? extend({}, data.on) : {};
  45580. for (var key in value) {
  45581. var existing = on[key];
  45582. var ours = value[key];
  45583. on[key] = existing ? [].concat(existing, ours) : ours;
  45584. }
  45585. }
  45586. }
  45587. return data
  45588. }
  45589. /* */
  45590. function resolveScopedSlots (
  45591. fns, // see flow/vnode
  45592. res,
  45593. // the following are added in 2.6
  45594. hasDynamicKeys,
  45595. contentHashKey
  45596. ) {
  45597. res = res || { $stable: !hasDynamicKeys };
  45598. for (var i = 0; i < fns.length; i++) {
  45599. var slot = fns[i];
  45600. if (Array.isArray(slot)) {
  45601. resolveScopedSlots(slot, res, hasDynamicKeys);
  45602. } else if (slot) {
  45603. // marker for reverse proxying v-slot without scope on this.$slots
  45604. if (slot.proxy) {
  45605. slot.fn.proxy = true;
  45606. }
  45607. res[slot.key] = slot.fn;
  45608. }
  45609. }
  45610. if (contentHashKey) {
  45611. (res).$key = contentHashKey;
  45612. }
  45613. return res
  45614. }
  45615. /* */
  45616. function bindDynamicKeys (baseObj, values) {
  45617. for (var i = 0; i < values.length; i += 2) {
  45618. var key = values[i];
  45619. if (typeof key === 'string' && key) {
  45620. baseObj[values[i]] = values[i + 1];
  45621. } else if (key !== '' && key !== null) {
  45622. // null is a special value for explicitly removing a binding
  45623. warn(
  45624. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  45625. this
  45626. );
  45627. }
  45628. }
  45629. return baseObj
  45630. }
  45631. // helper to dynamically append modifier runtime markers to event names.
  45632. // ensure only append when value is already string, otherwise it will be cast
  45633. // to string and cause the type check to miss.
  45634. function prependModifier (value, symbol) {
  45635. return typeof value === 'string' ? symbol + value : value
  45636. }
  45637. /* */
  45638. function installRenderHelpers (target) {
  45639. target._o = markOnce;
  45640. target._n = toNumber;
  45641. target._s = toString;
  45642. target._l = renderList;
  45643. target._t = renderSlot;
  45644. target._q = looseEqual;
  45645. target._i = looseIndexOf;
  45646. target._m = renderStatic;
  45647. target._f = resolveFilter;
  45648. target._k = checkKeyCodes;
  45649. target._b = bindObjectProps;
  45650. target._v = createTextVNode;
  45651. target._e = createEmptyVNode;
  45652. target._u = resolveScopedSlots;
  45653. target._g = bindObjectListeners;
  45654. target._d = bindDynamicKeys;
  45655. target._p = prependModifier;
  45656. }
  45657. /* */
  45658. function FunctionalRenderContext (
  45659. data,
  45660. props,
  45661. children,
  45662. parent,
  45663. Ctor
  45664. ) {
  45665. var this$1 = this;
  45666. var options = Ctor.options;
  45667. // ensure the createElement function in functional components
  45668. // gets a unique context - this is necessary for correct named slot check
  45669. var contextVm;
  45670. if (hasOwn(parent, '_uid')) {
  45671. contextVm = Object.create(parent);
  45672. // $flow-disable-line
  45673. contextVm._original = parent;
  45674. } else {
  45675. // the context vm passed in is a functional context as well.
  45676. // in this case we want to make sure we are able to get a hold to the
  45677. // real context instance.
  45678. contextVm = parent;
  45679. // $flow-disable-line
  45680. parent = parent._original;
  45681. }
  45682. var isCompiled = isTrue(options._compiled);
  45683. var needNormalization = !isCompiled;
  45684. this.data = data;
  45685. this.props = props;
  45686. this.children = children;
  45687. this.parent = parent;
  45688. this.listeners = data.on || emptyObject;
  45689. this.injections = resolveInject(options.inject, parent);
  45690. this.slots = function () {
  45691. if (!this$1.$slots) {
  45692. normalizeScopedSlots(
  45693. data.scopedSlots,
  45694. this$1.$slots = resolveSlots(children, parent)
  45695. );
  45696. }
  45697. return this$1.$slots
  45698. };
  45699. Object.defineProperty(this, 'scopedSlots', ({
  45700. enumerable: true,
  45701. get: function get () {
  45702. return normalizeScopedSlots(data.scopedSlots, this.slots())
  45703. }
  45704. }));
  45705. // support for compiled functional template
  45706. if (isCompiled) {
  45707. // exposing $options for renderStatic()
  45708. this.$options = options;
  45709. // pre-resolve slots for renderSlot()
  45710. this.$slots = this.slots();
  45711. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  45712. }
  45713. if (options._scopeId) {
  45714. this._c = function (a, b, c, d) {
  45715. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  45716. if (vnode && !Array.isArray(vnode)) {
  45717. vnode.fnScopeId = options._scopeId;
  45718. vnode.fnContext = parent;
  45719. }
  45720. return vnode
  45721. };
  45722. } else {
  45723. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  45724. }
  45725. }
  45726. installRenderHelpers(FunctionalRenderContext.prototype);
  45727. function createFunctionalComponent (
  45728. Ctor,
  45729. propsData,
  45730. data,
  45731. contextVm,
  45732. children
  45733. ) {
  45734. var options = Ctor.options;
  45735. var props = {};
  45736. var propOptions = options.props;
  45737. if (isDef(propOptions)) {
  45738. for (var key in propOptions) {
  45739. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  45740. }
  45741. } else {
  45742. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  45743. if (isDef(data.props)) { mergeProps(props, data.props); }
  45744. }
  45745. var renderContext = new FunctionalRenderContext(
  45746. data,
  45747. props,
  45748. children,
  45749. contextVm,
  45750. Ctor
  45751. );
  45752. var vnode = options.render.call(null, renderContext._c, renderContext);
  45753. if (vnode instanceof VNode) {
  45754. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  45755. } else if (Array.isArray(vnode)) {
  45756. var vnodes = normalizeChildren(vnode) || [];
  45757. var res = new Array(vnodes.length);
  45758. for (var i = 0; i < vnodes.length; i++) {
  45759. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  45760. }
  45761. return res
  45762. }
  45763. }
  45764. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  45765. // #7817 clone node before setting fnContext, otherwise if the node is reused
  45766. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  45767. // that should not be matched to match.
  45768. var clone = cloneVNode(vnode);
  45769. clone.fnContext = contextVm;
  45770. clone.fnOptions = options;
  45771. {
  45772. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  45773. }
  45774. if (data.slot) {
  45775. (clone.data || (clone.data = {})).slot = data.slot;
  45776. }
  45777. return clone
  45778. }
  45779. function mergeProps (to, from) {
  45780. for (var key in from) {
  45781. to[camelize(key)] = from[key];
  45782. }
  45783. }
  45784. /* */
  45785. /* */
  45786. /* */
  45787. /* */
  45788. // inline hooks to be invoked on component VNodes during patch
  45789. var componentVNodeHooks = {
  45790. init: function init (vnode, hydrating) {
  45791. if (
  45792. vnode.componentInstance &&
  45793. !vnode.componentInstance._isDestroyed &&
  45794. vnode.data.keepAlive
  45795. ) {
  45796. // kept-alive components, treat as a patch
  45797. var mountedNode = vnode; // work around flow
  45798. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  45799. } else {
  45800. var child = vnode.componentInstance = createComponentInstanceForVnode(
  45801. vnode,
  45802. activeInstance
  45803. );
  45804. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  45805. }
  45806. },
  45807. prepatch: function prepatch (oldVnode, vnode) {
  45808. var options = vnode.componentOptions;
  45809. var child = vnode.componentInstance = oldVnode.componentInstance;
  45810. updateChildComponent(
  45811. child,
  45812. options.propsData, // updated props
  45813. options.listeners, // updated listeners
  45814. vnode, // new parent vnode
  45815. options.children // new children
  45816. );
  45817. },
  45818. insert: function insert (vnode) {
  45819. var context = vnode.context;
  45820. var componentInstance = vnode.componentInstance;
  45821. if (!componentInstance._isMounted) {
  45822. componentInstance._isMounted = true;
  45823. callHook(componentInstance, 'mounted');
  45824. }
  45825. if (vnode.data.keepAlive) {
  45826. if (context._isMounted) {
  45827. // vue-router#1212
  45828. // During updates, a kept-alive component's child components may
  45829. // change, so directly walking the tree here may call activated hooks
  45830. // on incorrect children. Instead we push them into a queue which will
  45831. // be processed after the whole patch process ended.
  45832. queueActivatedComponent(componentInstance);
  45833. } else {
  45834. activateChildComponent(componentInstance, true /* direct */);
  45835. }
  45836. }
  45837. },
  45838. destroy: function destroy (vnode) {
  45839. var componentInstance = vnode.componentInstance;
  45840. if (!componentInstance._isDestroyed) {
  45841. if (!vnode.data.keepAlive) {
  45842. componentInstance.$destroy();
  45843. } else {
  45844. deactivateChildComponent(componentInstance, true /* direct */);
  45845. }
  45846. }
  45847. }
  45848. };
  45849. var hooksToMerge = Object.keys(componentVNodeHooks);
  45850. function createComponent (
  45851. Ctor,
  45852. data,
  45853. context,
  45854. children,
  45855. tag
  45856. ) {
  45857. if (isUndef(Ctor)) {
  45858. return
  45859. }
  45860. var baseCtor = context.$options._base;
  45861. // plain options object: turn it into a constructor
  45862. if (isObject(Ctor)) {
  45863. Ctor = baseCtor.extend(Ctor);
  45864. }
  45865. // if at this stage it's not a constructor or an async component factory,
  45866. // reject.
  45867. if (typeof Ctor !== 'function') {
  45868. {
  45869. warn(("Invalid Component definition: " + (String(Ctor))), context);
  45870. }
  45871. return
  45872. }
  45873. // async component
  45874. var asyncFactory;
  45875. if (isUndef(Ctor.cid)) {
  45876. asyncFactory = Ctor;
  45877. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  45878. if (Ctor === undefined) {
  45879. // return a placeholder node for async component, which is rendered
  45880. // as a comment node but preserves all the raw information for the node.
  45881. // the information will be used for async server-rendering and hydration.
  45882. return createAsyncPlaceholder(
  45883. asyncFactory,
  45884. data,
  45885. context,
  45886. children,
  45887. tag
  45888. )
  45889. }
  45890. }
  45891. data = data || {};
  45892. // resolve constructor options in case global mixins are applied after
  45893. // component constructor creation
  45894. resolveConstructorOptions(Ctor);
  45895. // transform component v-model data into props & events
  45896. if (isDef(data.model)) {
  45897. transformModel(Ctor.options, data);
  45898. }
  45899. // extract props
  45900. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  45901. // functional component
  45902. if (isTrue(Ctor.options.functional)) {
  45903. return createFunctionalComponent(Ctor, propsData, data, context, children)
  45904. }
  45905. // extract listeners, since these needs to be treated as
  45906. // child component listeners instead of DOM listeners
  45907. var listeners = data.on;
  45908. // replace with listeners with .native modifier
  45909. // so it gets processed during parent component patch.
  45910. data.on = data.nativeOn;
  45911. if (isTrue(Ctor.options.abstract)) {
  45912. // abstract components do not keep anything
  45913. // other than props & listeners & slot
  45914. // work around flow
  45915. var slot = data.slot;
  45916. data = {};
  45917. if (slot) {
  45918. data.slot = slot;
  45919. }
  45920. }
  45921. // install component management hooks onto the placeholder node
  45922. installComponentHooks(data);
  45923. // return a placeholder vnode
  45924. var name = Ctor.options.name || tag;
  45925. var vnode = new VNode(
  45926. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  45927. data, undefined, undefined, undefined, context,
  45928. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  45929. asyncFactory
  45930. );
  45931. return vnode
  45932. }
  45933. function createComponentInstanceForVnode (
  45934. vnode, // we know it's MountedComponentVNode but flow doesn't
  45935. parent // activeInstance in lifecycle state
  45936. ) {
  45937. var options = {
  45938. _isComponent: true,
  45939. _parentVnode: vnode,
  45940. parent: parent
  45941. };
  45942. // check inline-template render functions
  45943. var inlineTemplate = vnode.data.inlineTemplate;
  45944. if (isDef(inlineTemplate)) {
  45945. options.render = inlineTemplate.render;
  45946. options.staticRenderFns = inlineTemplate.staticRenderFns;
  45947. }
  45948. return new vnode.componentOptions.Ctor(options)
  45949. }
  45950. function installComponentHooks (data) {
  45951. var hooks = data.hook || (data.hook = {});
  45952. for (var i = 0; i < hooksToMerge.length; i++) {
  45953. var key = hooksToMerge[i];
  45954. var existing = hooks[key];
  45955. var toMerge = componentVNodeHooks[key];
  45956. if (existing !== toMerge && !(existing && existing._merged)) {
  45957. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  45958. }
  45959. }
  45960. }
  45961. function mergeHook$1 (f1, f2) {
  45962. var merged = function (a, b) {
  45963. // flow complains about extra args which is why we use any
  45964. f1(a, b);
  45965. f2(a, b);
  45966. };
  45967. merged._merged = true;
  45968. return merged
  45969. }
  45970. // transform component v-model info (value and callback) into
  45971. // prop and event handler respectively.
  45972. function transformModel (options, data) {
  45973. var prop = (options.model && options.model.prop) || 'value';
  45974. var event = (options.model && options.model.event) || 'input'
  45975. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  45976. var on = data.on || (data.on = {});
  45977. var existing = on[event];
  45978. var callback = data.model.callback;
  45979. if (isDef(existing)) {
  45980. if (
  45981. Array.isArray(existing)
  45982. ? existing.indexOf(callback) === -1
  45983. : existing !== callback
  45984. ) {
  45985. on[event] = [callback].concat(existing);
  45986. }
  45987. } else {
  45988. on[event] = callback;
  45989. }
  45990. }
  45991. /* */
  45992. var SIMPLE_NORMALIZE = 1;
  45993. var ALWAYS_NORMALIZE = 2;
  45994. // wrapper function for providing a more flexible interface
  45995. // without getting yelled at by flow
  45996. function createElement (
  45997. context,
  45998. tag,
  45999. data,
  46000. children,
  46001. normalizationType,
  46002. alwaysNormalize
  46003. ) {
  46004. if (Array.isArray(data) || isPrimitive(data)) {
  46005. normalizationType = children;
  46006. children = data;
  46007. data = undefined;
  46008. }
  46009. if (isTrue(alwaysNormalize)) {
  46010. normalizationType = ALWAYS_NORMALIZE;
  46011. }
  46012. return _createElement(context, tag, data, children, normalizationType)
  46013. }
  46014. function _createElement (
  46015. context,
  46016. tag,
  46017. data,
  46018. children,
  46019. normalizationType
  46020. ) {
  46021. if (isDef(data) && isDef((data).__ob__)) {
  46022. warn(
  46023. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  46024. 'Always create fresh vnode data objects in each render!',
  46025. context
  46026. );
  46027. return createEmptyVNode()
  46028. }
  46029. // object syntax in v-bind
  46030. if (isDef(data) && isDef(data.is)) {
  46031. tag = data.is;
  46032. }
  46033. if (!tag) {
  46034. // in case of component :is set to falsy value
  46035. return createEmptyVNode()
  46036. }
  46037. // warn against non-primitive key
  46038. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  46039. ) {
  46040. {
  46041. warn(
  46042. 'Avoid using non-primitive value as key, ' +
  46043. 'use string/number value instead.',
  46044. context
  46045. );
  46046. }
  46047. }
  46048. // support single function children as default scoped slot
  46049. if (Array.isArray(children) &&
  46050. typeof children[0] === 'function'
  46051. ) {
  46052. data = data || {};
  46053. data.scopedSlots = { default: children[0] };
  46054. children.length = 0;
  46055. }
  46056. if (normalizationType === ALWAYS_NORMALIZE) {
  46057. children = normalizeChildren(children);
  46058. } else if (normalizationType === SIMPLE_NORMALIZE) {
  46059. children = simpleNormalizeChildren(children);
  46060. }
  46061. var vnode, ns;
  46062. if (typeof tag === 'string') {
  46063. var Ctor;
  46064. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  46065. if (config.isReservedTag(tag)) {
  46066. // platform built-in elements
  46067. if (isDef(data) && isDef(data.nativeOn)) {
  46068. warn(
  46069. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  46070. context
  46071. );
  46072. }
  46073. vnode = new VNode(
  46074. config.parsePlatformTagName(tag), data, children,
  46075. undefined, undefined, context
  46076. );
  46077. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  46078. // component
  46079. vnode = createComponent(Ctor, data, context, children, tag);
  46080. } else {
  46081. // unknown or unlisted namespaced elements
  46082. // check at runtime because it may get assigned a namespace when its
  46083. // parent normalizes children
  46084. vnode = new VNode(
  46085. tag, data, children,
  46086. undefined, undefined, context
  46087. );
  46088. }
  46089. } else {
  46090. // direct component options / constructor
  46091. vnode = createComponent(tag, data, context, children);
  46092. }
  46093. if (Array.isArray(vnode)) {
  46094. return vnode
  46095. } else if (isDef(vnode)) {
  46096. if (isDef(ns)) { applyNS(vnode, ns); }
  46097. if (isDef(data)) { registerDeepBindings(data); }
  46098. return vnode
  46099. } else {
  46100. return createEmptyVNode()
  46101. }
  46102. }
  46103. function applyNS (vnode, ns, force) {
  46104. vnode.ns = ns;
  46105. if (vnode.tag === 'foreignObject') {
  46106. // use default namespace inside foreignObject
  46107. ns = undefined;
  46108. force = true;
  46109. }
  46110. if (isDef(vnode.children)) {
  46111. for (var i = 0, l = vnode.children.length; i < l; i++) {
  46112. var child = vnode.children[i];
  46113. if (isDef(child.tag) && (
  46114. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  46115. applyNS(child, ns, force);
  46116. }
  46117. }
  46118. }
  46119. }
  46120. // ref #5318
  46121. // necessary to ensure parent re-render when deep bindings like :style and
  46122. // :class are used on slot nodes
  46123. function registerDeepBindings (data) {
  46124. if (isObject(data.style)) {
  46125. traverse(data.style);
  46126. }
  46127. if (isObject(data.class)) {
  46128. traverse(data.class);
  46129. }
  46130. }
  46131. /* */
  46132. function initRender (vm) {
  46133. vm._vnode = null; // the root of the child tree
  46134. vm._staticTrees = null; // v-once cached trees
  46135. var options = vm.$options;
  46136. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  46137. var renderContext = parentVnode && parentVnode.context;
  46138. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  46139. vm.$scopedSlots = emptyObject;
  46140. // bind the createElement fn to this instance
  46141. // so that we get proper render context inside it.
  46142. // args order: tag, data, children, normalizationType, alwaysNormalize
  46143. // internal version is used by render functions compiled from templates
  46144. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  46145. // normalization is always applied for the public version, used in
  46146. // user-written render functions.
  46147. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  46148. // $attrs & $listeners are exposed for easier HOC creation.
  46149. // they need to be reactive so that HOCs using them are always updated
  46150. var parentData = parentVnode && parentVnode.data;
  46151. /* istanbul ignore else */
  46152. {
  46153. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  46154. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  46155. }, true);
  46156. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  46157. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  46158. }, true);
  46159. }
  46160. }
  46161. var currentRenderingInstance = null;
  46162. function renderMixin (Vue) {
  46163. // install runtime convenience helpers
  46164. installRenderHelpers(Vue.prototype);
  46165. Vue.prototype.$nextTick = function (fn) {
  46166. return nextTick(fn, this)
  46167. };
  46168. Vue.prototype._render = function () {
  46169. var vm = this;
  46170. var ref = vm.$options;
  46171. var render = ref.render;
  46172. var _parentVnode = ref._parentVnode;
  46173. if (_parentVnode) {
  46174. vm.$scopedSlots = normalizeScopedSlots(
  46175. _parentVnode.data.scopedSlots,
  46176. vm.$slots,
  46177. vm.$scopedSlots
  46178. );
  46179. }
  46180. // set parent vnode. this allows render functions to have access
  46181. // to the data on the placeholder node.
  46182. vm.$vnode = _parentVnode;
  46183. // render self
  46184. var vnode;
  46185. try {
  46186. // There's no need to maintain a stack because all render fns are called
  46187. // separately from one another. Nested component's render fns are called
  46188. // when parent component is patched.
  46189. currentRenderingInstance = vm;
  46190. vnode = render.call(vm._renderProxy, vm.$createElement);
  46191. } catch (e) {
  46192. handleError(e, vm, "render");
  46193. // return error render result,
  46194. // or previous vnode to prevent render error causing blank component
  46195. /* istanbul ignore else */
  46196. if (vm.$options.renderError) {
  46197. try {
  46198. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  46199. } catch (e) {
  46200. handleError(e, vm, "renderError");
  46201. vnode = vm._vnode;
  46202. }
  46203. } else {
  46204. vnode = vm._vnode;
  46205. }
  46206. } finally {
  46207. currentRenderingInstance = null;
  46208. }
  46209. // if the returned array contains only a single node, allow it
  46210. if (Array.isArray(vnode) && vnode.length === 1) {
  46211. vnode = vnode[0];
  46212. }
  46213. // return empty vnode in case the render function errored out
  46214. if (!(vnode instanceof VNode)) {
  46215. if (Array.isArray(vnode)) {
  46216. warn(
  46217. 'Multiple root nodes returned from render function. Render function ' +
  46218. 'should return a single root node.',
  46219. vm
  46220. );
  46221. }
  46222. vnode = createEmptyVNode();
  46223. }
  46224. // set parent
  46225. vnode.parent = _parentVnode;
  46226. return vnode
  46227. };
  46228. }
  46229. /* */
  46230. function ensureCtor (comp, base) {
  46231. if (
  46232. comp.__esModule ||
  46233. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  46234. ) {
  46235. comp = comp.default;
  46236. }
  46237. return isObject(comp)
  46238. ? base.extend(comp)
  46239. : comp
  46240. }
  46241. function createAsyncPlaceholder (
  46242. factory,
  46243. data,
  46244. context,
  46245. children,
  46246. tag
  46247. ) {
  46248. var node = createEmptyVNode();
  46249. node.asyncFactory = factory;
  46250. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  46251. return node
  46252. }
  46253. function resolveAsyncComponent (
  46254. factory,
  46255. baseCtor
  46256. ) {
  46257. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  46258. return factory.errorComp
  46259. }
  46260. if (isDef(factory.resolved)) {
  46261. return factory.resolved
  46262. }
  46263. var owner = currentRenderingInstance;
  46264. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  46265. // already pending
  46266. factory.owners.push(owner);
  46267. }
  46268. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  46269. return factory.loadingComp
  46270. }
  46271. if (owner && !isDef(factory.owners)) {
  46272. var owners = factory.owners = [owner];
  46273. var sync = true;
  46274. var timerLoading = null;
  46275. var timerTimeout = null
  46276. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  46277. var forceRender = function (renderCompleted) {
  46278. for (var i = 0, l = owners.length; i < l; i++) {
  46279. (owners[i]).$forceUpdate();
  46280. }
  46281. if (renderCompleted) {
  46282. owners.length = 0;
  46283. if (timerLoading !== null) {
  46284. clearTimeout(timerLoading);
  46285. timerLoading = null;
  46286. }
  46287. if (timerTimeout !== null) {
  46288. clearTimeout(timerTimeout);
  46289. timerTimeout = null;
  46290. }
  46291. }
  46292. };
  46293. var resolve = once(function (res) {
  46294. // cache resolved
  46295. factory.resolved = ensureCtor(res, baseCtor);
  46296. // invoke callbacks only if this is not a synchronous resolve
  46297. // (async resolves are shimmed as synchronous during SSR)
  46298. if (!sync) {
  46299. forceRender(true);
  46300. } else {
  46301. owners.length = 0;
  46302. }
  46303. });
  46304. var reject = once(function (reason) {
  46305. warn(
  46306. "Failed to resolve async component: " + (String(factory)) +
  46307. (reason ? ("\nReason: " + reason) : '')
  46308. );
  46309. if (isDef(factory.errorComp)) {
  46310. factory.error = true;
  46311. forceRender(true);
  46312. }
  46313. });
  46314. var res = factory(resolve, reject);
  46315. if (isObject(res)) {
  46316. if (isPromise(res)) {
  46317. // () => Promise
  46318. if (isUndef(factory.resolved)) {
  46319. res.then(resolve, reject);
  46320. }
  46321. } else if (isPromise(res.component)) {
  46322. res.component.then(resolve, reject);
  46323. if (isDef(res.error)) {
  46324. factory.errorComp = ensureCtor(res.error, baseCtor);
  46325. }
  46326. if (isDef(res.loading)) {
  46327. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  46328. if (res.delay === 0) {
  46329. factory.loading = true;
  46330. } else {
  46331. timerLoading = setTimeout(function () {
  46332. timerLoading = null;
  46333. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  46334. factory.loading = true;
  46335. forceRender(false);
  46336. }
  46337. }, res.delay || 200);
  46338. }
  46339. }
  46340. if (isDef(res.timeout)) {
  46341. timerTimeout = setTimeout(function () {
  46342. timerTimeout = null;
  46343. if (isUndef(factory.resolved)) {
  46344. reject(
  46345. "timeout (" + (res.timeout) + "ms)"
  46346. );
  46347. }
  46348. }, res.timeout);
  46349. }
  46350. }
  46351. }
  46352. sync = false;
  46353. // return in case resolved synchronously
  46354. return factory.loading
  46355. ? factory.loadingComp
  46356. : factory.resolved
  46357. }
  46358. }
  46359. /* */
  46360. function isAsyncPlaceholder (node) {
  46361. return node.isComment && node.asyncFactory
  46362. }
  46363. /* */
  46364. function getFirstComponentChild (children) {
  46365. if (Array.isArray(children)) {
  46366. for (var i = 0; i < children.length; i++) {
  46367. var c = children[i];
  46368. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  46369. return c
  46370. }
  46371. }
  46372. }
  46373. }
  46374. /* */
  46375. /* */
  46376. function initEvents (vm) {
  46377. vm._events = Object.create(null);
  46378. vm._hasHookEvent = false;
  46379. // init parent attached events
  46380. var listeners = vm.$options._parentListeners;
  46381. if (listeners) {
  46382. updateComponentListeners(vm, listeners);
  46383. }
  46384. }
  46385. var target;
  46386. function add (event, fn) {
  46387. target.$on(event, fn);
  46388. }
  46389. function remove$1 (event, fn) {
  46390. target.$off(event, fn);
  46391. }
  46392. function createOnceHandler (event, fn) {
  46393. var _target = target;
  46394. return function onceHandler () {
  46395. var res = fn.apply(null, arguments);
  46396. if (res !== null) {
  46397. _target.$off(event, onceHandler);
  46398. }
  46399. }
  46400. }
  46401. function updateComponentListeners (
  46402. vm,
  46403. listeners,
  46404. oldListeners
  46405. ) {
  46406. target = vm;
  46407. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  46408. target = undefined;
  46409. }
  46410. function eventsMixin (Vue) {
  46411. var hookRE = /^hook:/;
  46412. Vue.prototype.$on = function (event, fn) {
  46413. var vm = this;
  46414. if (Array.isArray(event)) {
  46415. for (var i = 0, l = event.length; i < l; i++) {
  46416. vm.$on(event[i], fn);
  46417. }
  46418. } else {
  46419. (vm._events[event] || (vm._events[event] = [])).push(fn);
  46420. // optimize hook:event cost by using a boolean flag marked at registration
  46421. // instead of a hash lookup
  46422. if (hookRE.test(event)) {
  46423. vm._hasHookEvent = true;
  46424. }
  46425. }
  46426. return vm
  46427. };
  46428. Vue.prototype.$once = function (event, fn) {
  46429. var vm = this;
  46430. function on () {
  46431. vm.$off(event, on);
  46432. fn.apply(vm, arguments);
  46433. }
  46434. on.fn = fn;
  46435. vm.$on(event, on);
  46436. return vm
  46437. };
  46438. Vue.prototype.$off = function (event, fn) {
  46439. var vm = this;
  46440. // all
  46441. if (!arguments.length) {
  46442. vm._events = Object.create(null);
  46443. return vm
  46444. }
  46445. // array of events
  46446. if (Array.isArray(event)) {
  46447. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  46448. vm.$off(event[i$1], fn);
  46449. }
  46450. return vm
  46451. }
  46452. // specific event
  46453. var cbs = vm._events[event];
  46454. if (!cbs) {
  46455. return vm
  46456. }
  46457. if (!fn) {
  46458. vm._events[event] = null;
  46459. return vm
  46460. }
  46461. // specific handler
  46462. var cb;
  46463. var i = cbs.length;
  46464. while (i--) {
  46465. cb = cbs[i];
  46466. if (cb === fn || cb.fn === fn) {
  46467. cbs.splice(i, 1);
  46468. break
  46469. }
  46470. }
  46471. return vm
  46472. };
  46473. Vue.prototype.$emit = function (event) {
  46474. var vm = this;
  46475. {
  46476. var lowerCaseEvent = event.toLowerCase();
  46477. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  46478. tip(
  46479. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  46480. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  46481. "Note that HTML attributes are case-insensitive and you cannot use " +
  46482. "v-on to listen to camelCase events when using in-DOM templates. " +
  46483. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  46484. );
  46485. }
  46486. }
  46487. var cbs = vm._events[event];
  46488. if (cbs) {
  46489. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  46490. var args = toArray(arguments, 1);
  46491. var info = "event handler for \"" + event + "\"";
  46492. for (var i = 0, l = cbs.length; i < l; i++) {
  46493. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  46494. }
  46495. }
  46496. return vm
  46497. };
  46498. }
  46499. /* */
  46500. var activeInstance = null;
  46501. var isUpdatingChildComponent = false;
  46502. function setActiveInstance(vm) {
  46503. var prevActiveInstance = activeInstance;
  46504. activeInstance = vm;
  46505. return function () {
  46506. activeInstance = prevActiveInstance;
  46507. }
  46508. }
  46509. function initLifecycle (vm) {
  46510. var options = vm.$options;
  46511. // locate first non-abstract parent
  46512. var parent = options.parent;
  46513. if (parent && !options.abstract) {
  46514. while (parent.$options.abstract && parent.$parent) {
  46515. parent = parent.$parent;
  46516. }
  46517. parent.$children.push(vm);
  46518. }
  46519. vm.$parent = parent;
  46520. vm.$root = parent ? parent.$root : vm;
  46521. vm.$children = [];
  46522. vm.$refs = {};
  46523. vm._watcher = null;
  46524. vm._inactive = null;
  46525. vm._directInactive = false;
  46526. vm._isMounted = false;
  46527. vm._isDestroyed = false;
  46528. vm._isBeingDestroyed = false;
  46529. }
  46530. function lifecycleMixin (Vue) {
  46531. Vue.prototype._update = function (vnode, hydrating) {
  46532. var vm = this;
  46533. var prevEl = vm.$el;
  46534. var prevVnode = vm._vnode;
  46535. var restoreActiveInstance = setActiveInstance(vm);
  46536. vm._vnode = vnode;
  46537. // Vue.prototype.__patch__ is injected in entry points
  46538. // based on the rendering backend used.
  46539. if (!prevVnode) {
  46540. // initial render
  46541. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  46542. } else {
  46543. // updates
  46544. vm.$el = vm.__patch__(prevVnode, vnode);
  46545. }
  46546. restoreActiveInstance();
  46547. // update __vue__ reference
  46548. if (prevEl) {
  46549. prevEl.__vue__ = null;
  46550. }
  46551. if (vm.$el) {
  46552. vm.$el.__vue__ = vm;
  46553. }
  46554. // if parent is an HOC, update its $el as well
  46555. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  46556. vm.$parent.$el = vm.$el;
  46557. }
  46558. // updated hook is called by the scheduler to ensure that children are
  46559. // updated in a parent's updated hook.
  46560. };
  46561. Vue.prototype.$forceUpdate = function () {
  46562. var vm = this;
  46563. if (vm._watcher) {
  46564. vm._watcher.update();
  46565. }
  46566. };
  46567. Vue.prototype.$destroy = function () {
  46568. var vm = this;
  46569. if (vm._isBeingDestroyed) {
  46570. return
  46571. }
  46572. callHook(vm, 'beforeDestroy');
  46573. vm._isBeingDestroyed = true;
  46574. // remove self from parent
  46575. var parent = vm.$parent;
  46576. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  46577. remove(parent.$children, vm);
  46578. }
  46579. // teardown watchers
  46580. if (vm._watcher) {
  46581. vm._watcher.teardown();
  46582. }
  46583. var i = vm._watchers.length;
  46584. while (i--) {
  46585. vm._watchers[i].teardown();
  46586. }
  46587. // remove reference from data ob
  46588. // frozen object may not have observer.
  46589. if (vm._data.__ob__) {
  46590. vm._data.__ob__.vmCount--;
  46591. }
  46592. // call the last hook...
  46593. vm._isDestroyed = true;
  46594. // invoke destroy hooks on current rendered tree
  46595. vm.__patch__(vm._vnode, null);
  46596. // fire destroyed hook
  46597. callHook(vm, 'destroyed');
  46598. // turn off all instance listeners.
  46599. vm.$off();
  46600. // remove __vue__ reference
  46601. if (vm.$el) {
  46602. vm.$el.__vue__ = null;
  46603. }
  46604. // release circular reference (#6759)
  46605. if (vm.$vnode) {
  46606. vm.$vnode.parent = null;
  46607. }
  46608. };
  46609. }
  46610. function mountComponent (
  46611. vm,
  46612. el,
  46613. hydrating
  46614. ) {
  46615. vm.$el = el;
  46616. if (!vm.$options.render) {
  46617. vm.$options.render = createEmptyVNode;
  46618. {
  46619. /* istanbul ignore if */
  46620. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  46621. vm.$options.el || el) {
  46622. warn(
  46623. 'You are using the runtime-only build of Vue where the template ' +
  46624. 'compiler is not available. Either pre-compile the templates into ' +
  46625. 'render functions, or use the compiler-included build.',
  46626. vm
  46627. );
  46628. } else {
  46629. warn(
  46630. 'Failed to mount component: template or render function not defined.',
  46631. vm
  46632. );
  46633. }
  46634. }
  46635. }
  46636. callHook(vm, 'beforeMount');
  46637. var updateComponent;
  46638. /* istanbul ignore if */
  46639. if (config.performance && mark) {
  46640. updateComponent = function () {
  46641. var name = vm._name;
  46642. var id = vm._uid;
  46643. var startTag = "vue-perf-start:" + id;
  46644. var endTag = "vue-perf-end:" + id;
  46645. mark(startTag);
  46646. var vnode = vm._render();
  46647. mark(endTag);
  46648. measure(("vue " + name + " render"), startTag, endTag);
  46649. mark(startTag);
  46650. vm._update(vnode, hydrating);
  46651. mark(endTag);
  46652. measure(("vue " + name + " patch"), startTag, endTag);
  46653. };
  46654. } else {
  46655. updateComponent = function () {
  46656. vm._update(vm._render(), hydrating);
  46657. };
  46658. }
  46659. // we set this to vm._watcher inside the watcher's constructor
  46660. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  46661. // component's mounted hook), which relies on vm._watcher being already defined
  46662. new Watcher(vm, updateComponent, noop, {
  46663. before: function before () {
  46664. if (vm._isMounted && !vm._isDestroyed) {
  46665. callHook(vm, 'beforeUpdate');
  46666. }
  46667. }
  46668. }, true /* isRenderWatcher */);
  46669. hydrating = false;
  46670. // manually mounted instance, call mounted on self
  46671. // mounted is called for render-created child components in its inserted hook
  46672. if (vm.$vnode == null) {
  46673. vm._isMounted = true;
  46674. callHook(vm, 'mounted');
  46675. }
  46676. return vm
  46677. }
  46678. function updateChildComponent (
  46679. vm,
  46680. propsData,
  46681. listeners,
  46682. parentVnode,
  46683. renderChildren
  46684. ) {
  46685. {
  46686. isUpdatingChildComponent = true;
  46687. }
  46688. // determine whether component has slot children
  46689. // we need to do this before overwriting $options._renderChildren.
  46690. // check if there are dynamic scopedSlots (hand-written or compiled but with
  46691. // dynamic slot names). Static scoped slots compiled from template has the
  46692. // "$stable" marker.
  46693. var newScopedSlots = parentVnode.data.scopedSlots;
  46694. var oldScopedSlots = vm.$scopedSlots;
  46695. var hasDynamicScopedSlot = !!(
  46696. (newScopedSlots && !newScopedSlots.$stable) ||
  46697. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  46698. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  46699. );
  46700. // Any static slot children from the parent may have changed during parent's
  46701. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  46702. // update is necessary to ensure correctness.
  46703. var needsForceUpdate = !!(
  46704. renderChildren || // has new static slots
  46705. vm.$options._renderChildren || // has old static slots
  46706. hasDynamicScopedSlot
  46707. );
  46708. vm.$options._parentVnode = parentVnode;
  46709. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  46710. if (vm._vnode) { // update child tree's parent
  46711. vm._vnode.parent = parentVnode;
  46712. }
  46713. vm.$options._renderChildren = renderChildren;
  46714. // update $attrs and $listeners hash
  46715. // these are also reactive so they may trigger child update if the child
  46716. // used them during render
  46717. vm.$attrs = parentVnode.data.attrs || emptyObject;
  46718. vm.$listeners = listeners || emptyObject;
  46719. // update props
  46720. if (propsData && vm.$options.props) {
  46721. toggleObserving(false);
  46722. var props = vm._props;
  46723. var propKeys = vm.$options._propKeys || [];
  46724. for (var i = 0; i < propKeys.length; i++) {
  46725. var key = propKeys[i];
  46726. var propOptions = vm.$options.props; // wtf flow?
  46727. props[key] = validateProp(key, propOptions, propsData, vm);
  46728. }
  46729. toggleObserving(true);
  46730. // keep a copy of raw propsData
  46731. vm.$options.propsData = propsData;
  46732. }
  46733. // update listeners
  46734. listeners = listeners || emptyObject;
  46735. var oldListeners = vm.$options._parentListeners;
  46736. vm.$options._parentListeners = listeners;
  46737. updateComponentListeners(vm, listeners, oldListeners);
  46738. // resolve slots + force update if has children
  46739. if (needsForceUpdate) {
  46740. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  46741. vm.$forceUpdate();
  46742. }
  46743. {
  46744. isUpdatingChildComponent = false;
  46745. }
  46746. }
  46747. function isInInactiveTree (vm) {
  46748. while (vm && (vm = vm.$parent)) {
  46749. if (vm._inactive) { return true }
  46750. }
  46751. return false
  46752. }
  46753. function activateChildComponent (vm, direct) {
  46754. if (direct) {
  46755. vm._directInactive = false;
  46756. if (isInInactiveTree(vm)) {
  46757. return
  46758. }
  46759. } else if (vm._directInactive) {
  46760. return
  46761. }
  46762. if (vm._inactive || vm._inactive === null) {
  46763. vm._inactive = false;
  46764. for (var i = 0; i < vm.$children.length; i++) {
  46765. activateChildComponent(vm.$children[i]);
  46766. }
  46767. callHook(vm, 'activated');
  46768. }
  46769. }
  46770. function deactivateChildComponent (vm, direct) {
  46771. if (direct) {
  46772. vm._directInactive = true;
  46773. if (isInInactiveTree(vm)) {
  46774. return
  46775. }
  46776. }
  46777. if (!vm._inactive) {
  46778. vm._inactive = true;
  46779. for (var i = 0; i < vm.$children.length; i++) {
  46780. deactivateChildComponent(vm.$children[i]);
  46781. }
  46782. callHook(vm, 'deactivated');
  46783. }
  46784. }
  46785. function callHook (vm, hook) {
  46786. // #7573 disable dep collection when invoking lifecycle hooks
  46787. pushTarget();
  46788. var handlers = vm.$options[hook];
  46789. var info = hook + " hook";
  46790. if (handlers) {
  46791. for (var i = 0, j = handlers.length; i < j; i++) {
  46792. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  46793. }
  46794. }
  46795. if (vm._hasHookEvent) {
  46796. vm.$emit('hook:' + hook);
  46797. }
  46798. popTarget();
  46799. }
  46800. /* */
  46801. var MAX_UPDATE_COUNT = 100;
  46802. var queue = [];
  46803. var activatedChildren = [];
  46804. var has = {};
  46805. var circular = {};
  46806. var waiting = false;
  46807. var flushing = false;
  46808. var index = 0;
  46809. /**
  46810. * Reset the scheduler's state.
  46811. */
  46812. function resetSchedulerState () {
  46813. index = queue.length = activatedChildren.length = 0;
  46814. has = {};
  46815. {
  46816. circular = {};
  46817. }
  46818. waiting = flushing = false;
  46819. }
  46820. // Async edge case #6566 requires saving the timestamp when event listeners are
  46821. // attached. However, calling performance.now() has a perf overhead especially
  46822. // if the page has thousands of event listeners. Instead, we take a timestamp
  46823. // every time the scheduler flushes and use that for all event listeners
  46824. // attached during that flush.
  46825. var currentFlushTimestamp = 0;
  46826. // Async edge case fix requires storing an event listener's attach timestamp.
  46827. var getNow = Date.now;
  46828. // Determine what event timestamp the browser is using. Annoyingly, the
  46829. // timestamp can either be hi-res (relative to page load) or low-res
  46830. // (relative to UNIX epoch), so in order to compare time we have to use the
  46831. // same timestamp type when saving the flush timestamp.
  46832. // All IE versions use low-res event timestamps, and have problematic clock
  46833. // implementations (#9632)
  46834. if (inBrowser && !isIE) {
  46835. var performance = window.performance;
  46836. if (
  46837. performance &&
  46838. typeof performance.now === 'function' &&
  46839. getNow() > document.createEvent('Event').timeStamp
  46840. ) {
  46841. // if the event timestamp, although evaluated AFTER the Date.now(), is
  46842. // smaller than it, it means the event is using a hi-res timestamp,
  46843. // and we need to use the hi-res version for event listener timestamps as
  46844. // well.
  46845. getNow = function () { return performance.now(); };
  46846. }
  46847. }
  46848. /**
  46849. * Flush both queues and run the watchers.
  46850. */
  46851. function flushSchedulerQueue () {
  46852. currentFlushTimestamp = getNow();
  46853. flushing = true;
  46854. var watcher, id;
  46855. // Sort queue before flush.
  46856. // This ensures that:
  46857. // 1. Components are updated from parent to child. (because parent is always
  46858. // created before the child)
  46859. // 2. A component's user watchers are run before its render watcher (because
  46860. // user watchers are created before the render watcher)
  46861. // 3. If a component is destroyed during a parent component's watcher run,
  46862. // its watchers can be skipped.
  46863. queue.sort(function (a, b) { return a.id - b.id; });
  46864. // do not cache length because more watchers might be pushed
  46865. // as we run existing watchers
  46866. for (index = 0; index < queue.length; index++) {
  46867. watcher = queue[index];
  46868. if (watcher.before) {
  46869. watcher.before();
  46870. }
  46871. id = watcher.id;
  46872. has[id] = null;
  46873. watcher.run();
  46874. // in dev build, check and stop circular updates.
  46875. if (has[id] != null) {
  46876. circular[id] = (circular[id] || 0) + 1;
  46877. if (circular[id] > MAX_UPDATE_COUNT) {
  46878. warn(
  46879. 'You may have an infinite update loop ' + (
  46880. watcher.user
  46881. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  46882. : "in a component render function."
  46883. ),
  46884. watcher.vm
  46885. );
  46886. break
  46887. }
  46888. }
  46889. }
  46890. // keep copies of post queues before resetting state
  46891. var activatedQueue = activatedChildren.slice();
  46892. var updatedQueue = queue.slice();
  46893. resetSchedulerState();
  46894. // call component updated and activated hooks
  46895. callActivatedHooks(activatedQueue);
  46896. callUpdatedHooks(updatedQueue);
  46897. // devtool hook
  46898. /* istanbul ignore if */
  46899. if (devtools && config.devtools) {
  46900. devtools.emit('flush');
  46901. }
  46902. }
  46903. function callUpdatedHooks (queue) {
  46904. var i = queue.length;
  46905. while (i--) {
  46906. var watcher = queue[i];
  46907. var vm = watcher.vm;
  46908. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  46909. callHook(vm, 'updated');
  46910. }
  46911. }
  46912. }
  46913. /**
  46914. * Queue a kept-alive component that was activated during patch.
  46915. * The queue will be processed after the entire tree has been patched.
  46916. */
  46917. function queueActivatedComponent (vm) {
  46918. // setting _inactive to false here so that a render function can
  46919. // rely on checking whether it's in an inactive tree (e.g. router-view)
  46920. vm._inactive = false;
  46921. activatedChildren.push(vm);
  46922. }
  46923. function callActivatedHooks (queue) {
  46924. for (var i = 0; i < queue.length; i++) {
  46925. queue[i]._inactive = true;
  46926. activateChildComponent(queue[i], true /* true */);
  46927. }
  46928. }
  46929. /**
  46930. * Push a watcher into the watcher queue.
  46931. * Jobs with duplicate IDs will be skipped unless it's
  46932. * pushed when the queue is being flushed.
  46933. */
  46934. function queueWatcher (watcher) {
  46935. var id = watcher.id;
  46936. if (has[id] == null) {
  46937. has[id] = true;
  46938. if (!flushing) {
  46939. queue.push(watcher);
  46940. } else {
  46941. // if already flushing, splice the watcher based on its id
  46942. // if already past its id, it will be run next immediately.
  46943. var i = queue.length - 1;
  46944. while (i > index && queue[i].id > watcher.id) {
  46945. i--;
  46946. }
  46947. queue.splice(i + 1, 0, watcher);
  46948. }
  46949. // queue the flush
  46950. if (!waiting) {
  46951. waiting = true;
  46952. if (!config.async) {
  46953. flushSchedulerQueue();
  46954. return
  46955. }
  46956. nextTick(flushSchedulerQueue);
  46957. }
  46958. }
  46959. }
  46960. /* */
  46961. var uid$2 = 0;
  46962. /**
  46963. * A watcher parses an expression, collects dependencies,
  46964. * and fires callback when the expression value changes.
  46965. * This is used for both the $watch() api and directives.
  46966. */
  46967. var Watcher = function Watcher (
  46968. vm,
  46969. expOrFn,
  46970. cb,
  46971. options,
  46972. isRenderWatcher
  46973. ) {
  46974. this.vm = vm;
  46975. if (isRenderWatcher) {
  46976. vm._watcher = this;
  46977. }
  46978. vm._watchers.push(this);
  46979. // options
  46980. if (options) {
  46981. this.deep = !!options.deep;
  46982. this.user = !!options.user;
  46983. this.lazy = !!options.lazy;
  46984. this.sync = !!options.sync;
  46985. this.before = options.before;
  46986. } else {
  46987. this.deep = this.user = this.lazy = this.sync = false;
  46988. }
  46989. this.cb = cb;
  46990. this.id = ++uid$2; // uid for batching
  46991. this.active = true;
  46992. this.dirty = this.lazy; // for lazy watchers
  46993. this.deps = [];
  46994. this.newDeps = [];
  46995. this.depIds = new _Set();
  46996. this.newDepIds = new _Set();
  46997. this.expression = expOrFn.toString();
  46998. // parse expression for getter
  46999. if (typeof expOrFn === 'function') {
  47000. this.getter = expOrFn;
  47001. } else {
  47002. this.getter = parsePath(expOrFn);
  47003. if (!this.getter) {
  47004. this.getter = noop;
  47005. warn(
  47006. "Failed watching path: \"" + expOrFn + "\" " +
  47007. 'Watcher only accepts simple dot-delimited paths. ' +
  47008. 'For full control, use a function instead.',
  47009. vm
  47010. );
  47011. }
  47012. }
  47013. this.value = this.lazy
  47014. ? undefined
  47015. : this.get();
  47016. };
  47017. /**
  47018. * Evaluate the getter, and re-collect dependencies.
  47019. */
  47020. Watcher.prototype.get = function get () {
  47021. pushTarget(this);
  47022. var value;
  47023. var vm = this.vm;
  47024. try {
  47025. value = this.getter.call(vm, vm);
  47026. } catch (e) {
  47027. if (this.user) {
  47028. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  47029. } else {
  47030. throw e
  47031. }
  47032. } finally {
  47033. // "touch" every property so they are all tracked as
  47034. // dependencies for deep watching
  47035. if (this.deep) {
  47036. traverse(value);
  47037. }
  47038. popTarget();
  47039. this.cleanupDeps();
  47040. }
  47041. return value
  47042. };
  47043. /**
  47044. * Add a dependency to this directive.
  47045. */
  47046. Watcher.prototype.addDep = function addDep (dep) {
  47047. var id = dep.id;
  47048. if (!this.newDepIds.has(id)) {
  47049. this.newDepIds.add(id);
  47050. this.newDeps.push(dep);
  47051. if (!this.depIds.has(id)) {
  47052. dep.addSub(this);
  47053. }
  47054. }
  47055. };
  47056. /**
  47057. * Clean up for dependency collection.
  47058. */
  47059. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  47060. var i = this.deps.length;
  47061. while (i--) {
  47062. var dep = this.deps[i];
  47063. if (!this.newDepIds.has(dep.id)) {
  47064. dep.removeSub(this);
  47065. }
  47066. }
  47067. var tmp = this.depIds;
  47068. this.depIds = this.newDepIds;
  47069. this.newDepIds = tmp;
  47070. this.newDepIds.clear();
  47071. tmp = this.deps;
  47072. this.deps = this.newDeps;
  47073. this.newDeps = tmp;
  47074. this.newDeps.length = 0;
  47075. };
  47076. /**
  47077. * Subscriber interface.
  47078. * Will be called when a dependency changes.
  47079. */
  47080. Watcher.prototype.update = function update () {
  47081. /* istanbul ignore else */
  47082. if (this.lazy) {
  47083. this.dirty = true;
  47084. } else if (this.sync) {
  47085. this.run();
  47086. } else {
  47087. queueWatcher(this);
  47088. }
  47089. };
  47090. /**
  47091. * Scheduler job interface.
  47092. * Will be called by the scheduler.
  47093. */
  47094. Watcher.prototype.run = function run () {
  47095. if (this.active) {
  47096. var value = this.get();
  47097. if (
  47098. value !== this.value ||
  47099. // Deep watchers and watchers on Object/Arrays should fire even
  47100. // when the value is the same, because the value may
  47101. // have mutated.
  47102. isObject(value) ||
  47103. this.deep
  47104. ) {
  47105. // set new value
  47106. var oldValue = this.value;
  47107. this.value = value;
  47108. if (this.user) {
  47109. try {
  47110. this.cb.call(this.vm, value, oldValue);
  47111. } catch (e) {
  47112. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  47113. }
  47114. } else {
  47115. this.cb.call(this.vm, value, oldValue);
  47116. }
  47117. }
  47118. }
  47119. };
  47120. /**
  47121. * Evaluate the value of the watcher.
  47122. * This only gets called for lazy watchers.
  47123. */
  47124. Watcher.prototype.evaluate = function evaluate () {
  47125. this.value = this.get();
  47126. this.dirty = false;
  47127. };
  47128. /**
  47129. * Depend on all deps collected by this watcher.
  47130. */
  47131. Watcher.prototype.depend = function depend () {
  47132. var i = this.deps.length;
  47133. while (i--) {
  47134. this.deps[i].depend();
  47135. }
  47136. };
  47137. /**
  47138. * Remove self from all dependencies' subscriber list.
  47139. */
  47140. Watcher.prototype.teardown = function teardown () {
  47141. if (this.active) {
  47142. // remove self from vm's watcher list
  47143. // this is a somewhat expensive operation so we skip it
  47144. // if the vm is being destroyed.
  47145. if (!this.vm._isBeingDestroyed) {
  47146. remove(this.vm._watchers, this);
  47147. }
  47148. var i = this.deps.length;
  47149. while (i--) {
  47150. this.deps[i].removeSub(this);
  47151. }
  47152. this.active = false;
  47153. }
  47154. };
  47155. /* */
  47156. var sharedPropertyDefinition = {
  47157. enumerable: true,
  47158. configurable: true,
  47159. get: noop,
  47160. set: noop
  47161. };
  47162. function proxy (target, sourceKey, key) {
  47163. sharedPropertyDefinition.get = function proxyGetter () {
  47164. return this[sourceKey][key]
  47165. };
  47166. sharedPropertyDefinition.set = function proxySetter (val) {
  47167. this[sourceKey][key] = val;
  47168. };
  47169. Object.defineProperty(target, key, sharedPropertyDefinition);
  47170. }
  47171. function initState (vm) {
  47172. vm._watchers = [];
  47173. var opts = vm.$options;
  47174. if (opts.props) { initProps(vm, opts.props); }
  47175. if (opts.methods) { initMethods(vm, opts.methods); }
  47176. if (opts.data) {
  47177. initData(vm);
  47178. } else {
  47179. observe(vm._data = {}, true /* asRootData */);
  47180. }
  47181. if (opts.computed) { initComputed(vm, opts.computed); }
  47182. if (opts.watch && opts.watch !== nativeWatch) {
  47183. initWatch(vm, opts.watch);
  47184. }
  47185. }
  47186. function initProps (vm, propsOptions) {
  47187. var propsData = vm.$options.propsData || {};
  47188. var props = vm._props = {};
  47189. // cache prop keys so that future props updates can iterate using Array
  47190. // instead of dynamic object key enumeration.
  47191. var keys = vm.$options._propKeys = [];
  47192. var isRoot = !vm.$parent;
  47193. // root instance props should be converted
  47194. if (!isRoot) {
  47195. toggleObserving(false);
  47196. }
  47197. var loop = function ( key ) {
  47198. keys.push(key);
  47199. var value = validateProp(key, propsOptions, propsData, vm);
  47200. /* istanbul ignore else */
  47201. {
  47202. var hyphenatedKey = hyphenate(key);
  47203. if (isReservedAttribute(hyphenatedKey) ||
  47204. config.isReservedAttr(hyphenatedKey)) {
  47205. warn(
  47206. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  47207. vm
  47208. );
  47209. }
  47210. defineReactive$$1(props, key, value, function () {
  47211. if (!isRoot && !isUpdatingChildComponent) {
  47212. warn(
  47213. "Avoid mutating a prop directly since the value will be " +
  47214. "overwritten whenever the parent component re-renders. " +
  47215. "Instead, use a data or computed property based on the prop's " +
  47216. "value. Prop being mutated: \"" + key + "\"",
  47217. vm
  47218. );
  47219. }
  47220. });
  47221. }
  47222. // static props are already proxied on the component's prototype
  47223. // during Vue.extend(). We only need to proxy props defined at
  47224. // instantiation here.
  47225. if (!(key in vm)) {
  47226. proxy(vm, "_props", key);
  47227. }
  47228. };
  47229. for (var key in propsOptions) loop( key );
  47230. toggleObserving(true);
  47231. }
  47232. function initData (vm) {
  47233. var data = vm.$options.data;
  47234. data = vm._data = typeof data === 'function'
  47235. ? getData(data, vm)
  47236. : data || {};
  47237. if (!isPlainObject(data)) {
  47238. data = {};
  47239. warn(
  47240. 'data functions should return an object:\n' +
  47241. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  47242. vm
  47243. );
  47244. }
  47245. // proxy data on instance
  47246. var keys = Object.keys(data);
  47247. var props = vm.$options.props;
  47248. var methods = vm.$options.methods;
  47249. var i = keys.length;
  47250. while (i--) {
  47251. var key = keys[i];
  47252. {
  47253. if (methods && hasOwn(methods, key)) {
  47254. warn(
  47255. ("Method \"" + key + "\" has already been defined as a data property."),
  47256. vm
  47257. );
  47258. }
  47259. }
  47260. if (props && hasOwn(props, key)) {
  47261. warn(
  47262. "The data property \"" + key + "\" is already declared as a prop. " +
  47263. "Use prop default value instead.",
  47264. vm
  47265. );
  47266. } else if (!isReserved(key)) {
  47267. proxy(vm, "_data", key);
  47268. }
  47269. }
  47270. // observe data
  47271. observe(data, true /* asRootData */);
  47272. }
  47273. function getData (data, vm) {
  47274. // #7573 disable dep collection when invoking data getters
  47275. pushTarget();
  47276. try {
  47277. return data.call(vm, vm)
  47278. } catch (e) {
  47279. handleError(e, vm, "data()");
  47280. return {}
  47281. } finally {
  47282. popTarget();
  47283. }
  47284. }
  47285. var computedWatcherOptions = { lazy: true };
  47286. function initComputed (vm, computed) {
  47287. // $flow-disable-line
  47288. var watchers = vm._computedWatchers = Object.create(null);
  47289. // computed properties are just getters during SSR
  47290. var isSSR = isServerRendering();
  47291. for (var key in computed) {
  47292. var userDef = computed[key];
  47293. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  47294. if (getter == null) {
  47295. warn(
  47296. ("Getter is missing for computed property \"" + key + "\"."),
  47297. vm
  47298. );
  47299. }
  47300. if (!isSSR) {
  47301. // create internal watcher for the computed property.
  47302. watchers[key] = new Watcher(
  47303. vm,
  47304. getter || noop,
  47305. noop,
  47306. computedWatcherOptions
  47307. );
  47308. }
  47309. // component-defined computed properties are already defined on the
  47310. // component prototype. We only need to define computed properties defined
  47311. // at instantiation here.
  47312. if (!(key in vm)) {
  47313. defineComputed(vm, key, userDef);
  47314. } else {
  47315. if (key in vm.$data) {
  47316. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  47317. } else if (vm.$options.props && key in vm.$options.props) {
  47318. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  47319. }
  47320. }
  47321. }
  47322. }
  47323. function defineComputed (
  47324. target,
  47325. key,
  47326. userDef
  47327. ) {
  47328. var shouldCache = !isServerRendering();
  47329. if (typeof userDef === 'function') {
  47330. sharedPropertyDefinition.get = shouldCache
  47331. ? createComputedGetter(key)
  47332. : createGetterInvoker(userDef);
  47333. sharedPropertyDefinition.set = noop;
  47334. } else {
  47335. sharedPropertyDefinition.get = userDef.get
  47336. ? shouldCache && userDef.cache !== false
  47337. ? createComputedGetter(key)
  47338. : createGetterInvoker(userDef.get)
  47339. : noop;
  47340. sharedPropertyDefinition.set = userDef.set || noop;
  47341. }
  47342. if (sharedPropertyDefinition.set === noop) {
  47343. sharedPropertyDefinition.set = function () {
  47344. warn(
  47345. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  47346. this
  47347. );
  47348. };
  47349. }
  47350. Object.defineProperty(target, key, sharedPropertyDefinition);
  47351. }
  47352. function createComputedGetter (key) {
  47353. return function computedGetter () {
  47354. var watcher = this._computedWatchers && this._computedWatchers[key];
  47355. if (watcher) {
  47356. if (watcher.dirty) {
  47357. watcher.evaluate();
  47358. }
  47359. if (Dep.target) {
  47360. watcher.depend();
  47361. }
  47362. return watcher.value
  47363. }
  47364. }
  47365. }
  47366. function createGetterInvoker(fn) {
  47367. return function computedGetter () {
  47368. return fn.call(this, this)
  47369. }
  47370. }
  47371. function initMethods (vm, methods) {
  47372. var props = vm.$options.props;
  47373. for (var key in methods) {
  47374. {
  47375. if (typeof methods[key] !== 'function') {
  47376. warn(
  47377. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  47378. "Did you reference the function correctly?",
  47379. vm
  47380. );
  47381. }
  47382. if (props && hasOwn(props, key)) {
  47383. warn(
  47384. ("Method \"" + key + "\" has already been defined as a prop."),
  47385. vm
  47386. );
  47387. }
  47388. if ((key in vm) && isReserved(key)) {
  47389. warn(
  47390. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  47391. "Avoid defining component methods that start with _ or $."
  47392. );
  47393. }
  47394. }
  47395. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  47396. }
  47397. }
  47398. function initWatch (vm, watch) {
  47399. for (var key in watch) {
  47400. var handler = watch[key];
  47401. if (Array.isArray(handler)) {
  47402. for (var i = 0; i < handler.length; i++) {
  47403. createWatcher(vm, key, handler[i]);
  47404. }
  47405. } else {
  47406. createWatcher(vm, key, handler);
  47407. }
  47408. }
  47409. }
  47410. function createWatcher (
  47411. vm,
  47412. expOrFn,
  47413. handler,
  47414. options
  47415. ) {
  47416. if (isPlainObject(handler)) {
  47417. options = handler;
  47418. handler = handler.handler;
  47419. }
  47420. if (typeof handler === 'string') {
  47421. handler = vm[handler];
  47422. }
  47423. return vm.$watch(expOrFn, handler, options)
  47424. }
  47425. function stateMixin (Vue) {
  47426. // flow somehow has problems with directly declared definition object
  47427. // when using Object.defineProperty, so we have to procedurally build up
  47428. // the object here.
  47429. var dataDef = {};
  47430. dataDef.get = function () { return this._data };
  47431. var propsDef = {};
  47432. propsDef.get = function () { return this._props };
  47433. {
  47434. dataDef.set = function () {
  47435. warn(
  47436. 'Avoid replacing instance root $data. ' +
  47437. 'Use nested data properties instead.',
  47438. this
  47439. );
  47440. };
  47441. propsDef.set = function () {
  47442. warn("$props is readonly.", this);
  47443. };
  47444. }
  47445. Object.defineProperty(Vue.prototype, '$data', dataDef);
  47446. Object.defineProperty(Vue.prototype, '$props', propsDef);
  47447. Vue.prototype.$set = set;
  47448. Vue.prototype.$delete = del;
  47449. Vue.prototype.$watch = function (
  47450. expOrFn,
  47451. cb,
  47452. options
  47453. ) {
  47454. var vm = this;
  47455. if (isPlainObject(cb)) {
  47456. return createWatcher(vm, expOrFn, cb, options)
  47457. }
  47458. options = options || {};
  47459. options.user = true;
  47460. var watcher = new Watcher(vm, expOrFn, cb, options);
  47461. if (options.immediate) {
  47462. try {
  47463. cb.call(vm, watcher.value);
  47464. } catch (error) {
  47465. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  47466. }
  47467. }
  47468. return function unwatchFn () {
  47469. watcher.teardown();
  47470. }
  47471. };
  47472. }
  47473. /* */
  47474. var uid$3 = 0;
  47475. function initMixin (Vue) {
  47476. Vue.prototype._init = function (options) {
  47477. var vm = this;
  47478. // a uid
  47479. vm._uid = uid$3++;
  47480. var startTag, endTag;
  47481. /* istanbul ignore if */
  47482. if (config.performance && mark) {
  47483. startTag = "vue-perf-start:" + (vm._uid);
  47484. endTag = "vue-perf-end:" + (vm._uid);
  47485. mark(startTag);
  47486. }
  47487. // a flag to avoid this being observed
  47488. vm._isVue = true;
  47489. // merge options
  47490. if (options && options._isComponent) {
  47491. // optimize internal component instantiation
  47492. // since dynamic options merging is pretty slow, and none of the
  47493. // internal component options needs special treatment.
  47494. initInternalComponent(vm, options);
  47495. } else {
  47496. vm.$options = mergeOptions(
  47497. resolveConstructorOptions(vm.constructor),
  47498. options || {},
  47499. vm
  47500. );
  47501. }
  47502. /* istanbul ignore else */
  47503. {
  47504. initProxy(vm);
  47505. }
  47506. // expose real self
  47507. vm._self = vm;
  47508. initLifecycle(vm);
  47509. initEvents(vm);
  47510. initRender(vm);
  47511. callHook(vm, 'beforeCreate');
  47512. initInjections(vm); // resolve injections before data/props
  47513. initState(vm);
  47514. initProvide(vm); // resolve provide after data/props
  47515. callHook(vm, 'created');
  47516. /* istanbul ignore if */
  47517. if (config.performance && mark) {
  47518. vm._name = formatComponentName(vm, false);
  47519. mark(endTag);
  47520. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  47521. }
  47522. if (vm.$options.el) {
  47523. vm.$mount(vm.$options.el);
  47524. }
  47525. };
  47526. }
  47527. function initInternalComponent (vm, options) {
  47528. var opts = vm.$options = Object.create(vm.constructor.options);
  47529. // doing this because it's faster than dynamic enumeration.
  47530. var parentVnode = options._parentVnode;
  47531. opts.parent = options.parent;
  47532. opts._parentVnode = parentVnode;
  47533. var vnodeComponentOptions = parentVnode.componentOptions;
  47534. opts.propsData = vnodeComponentOptions.propsData;
  47535. opts._parentListeners = vnodeComponentOptions.listeners;
  47536. opts._renderChildren = vnodeComponentOptions.children;
  47537. opts._componentTag = vnodeComponentOptions.tag;
  47538. if (options.render) {
  47539. opts.render = options.render;
  47540. opts.staticRenderFns = options.staticRenderFns;
  47541. }
  47542. }
  47543. function resolveConstructorOptions (Ctor) {
  47544. var options = Ctor.options;
  47545. if (Ctor.super) {
  47546. var superOptions = resolveConstructorOptions(Ctor.super);
  47547. var cachedSuperOptions = Ctor.superOptions;
  47548. if (superOptions !== cachedSuperOptions) {
  47549. // super option changed,
  47550. // need to resolve new options.
  47551. Ctor.superOptions = superOptions;
  47552. // check if there are any late-modified/attached options (#4976)
  47553. var modifiedOptions = resolveModifiedOptions(Ctor);
  47554. // update base extend options
  47555. if (modifiedOptions) {
  47556. extend(Ctor.extendOptions, modifiedOptions);
  47557. }
  47558. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  47559. if (options.name) {
  47560. options.components[options.name] = Ctor;
  47561. }
  47562. }
  47563. }
  47564. return options
  47565. }
  47566. function resolveModifiedOptions (Ctor) {
  47567. var modified;
  47568. var latest = Ctor.options;
  47569. var sealed = Ctor.sealedOptions;
  47570. for (var key in latest) {
  47571. if (latest[key] !== sealed[key]) {
  47572. if (!modified) { modified = {}; }
  47573. modified[key] = latest[key];
  47574. }
  47575. }
  47576. return modified
  47577. }
  47578. function Vue (options) {
  47579. if (!(this instanceof Vue)
  47580. ) {
  47581. warn('Vue is a constructor and should be called with the `new` keyword');
  47582. }
  47583. this._init(options);
  47584. }
  47585. initMixin(Vue);
  47586. stateMixin(Vue);
  47587. eventsMixin(Vue);
  47588. lifecycleMixin(Vue);
  47589. renderMixin(Vue);
  47590. /* */
  47591. function initUse (Vue) {
  47592. Vue.use = function (plugin) {
  47593. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  47594. if (installedPlugins.indexOf(plugin) > -1) {
  47595. return this
  47596. }
  47597. // additional parameters
  47598. var args = toArray(arguments, 1);
  47599. args.unshift(this);
  47600. if (typeof plugin.install === 'function') {
  47601. plugin.install.apply(plugin, args);
  47602. } else if (typeof plugin === 'function') {
  47603. plugin.apply(null, args);
  47604. }
  47605. installedPlugins.push(plugin);
  47606. return this
  47607. };
  47608. }
  47609. /* */
  47610. function initMixin$1 (Vue) {
  47611. Vue.mixin = function (mixin) {
  47612. this.options = mergeOptions(this.options, mixin);
  47613. return this
  47614. };
  47615. }
  47616. /* */
  47617. function initExtend (Vue) {
  47618. /**
  47619. * Each instance constructor, including Vue, has a unique
  47620. * cid. This enables us to create wrapped "child
  47621. * constructors" for prototypal inheritance and cache them.
  47622. */
  47623. Vue.cid = 0;
  47624. var cid = 1;
  47625. /**
  47626. * Class inheritance
  47627. */
  47628. Vue.extend = function (extendOptions) {
  47629. extendOptions = extendOptions || {};
  47630. var Super = this;
  47631. var SuperId = Super.cid;
  47632. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  47633. if (cachedCtors[SuperId]) {
  47634. return cachedCtors[SuperId]
  47635. }
  47636. var name = extendOptions.name || Super.options.name;
  47637. if (name) {
  47638. validateComponentName(name);
  47639. }
  47640. var Sub = function VueComponent (options) {
  47641. this._init(options);
  47642. };
  47643. Sub.prototype = Object.create(Super.prototype);
  47644. Sub.prototype.constructor = Sub;
  47645. Sub.cid = cid++;
  47646. Sub.options = mergeOptions(
  47647. Super.options,
  47648. extendOptions
  47649. );
  47650. Sub['super'] = Super;
  47651. // For props and computed properties, we define the proxy getters on
  47652. // the Vue instances at extension time, on the extended prototype. This
  47653. // avoids Object.defineProperty calls for each instance created.
  47654. if (Sub.options.props) {
  47655. initProps$1(Sub);
  47656. }
  47657. if (Sub.options.computed) {
  47658. initComputed$1(Sub);
  47659. }
  47660. // allow further extension/mixin/plugin usage
  47661. Sub.extend = Super.extend;
  47662. Sub.mixin = Super.mixin;
  47663. Sub.use = Super.use;
  47664. // create asset registers, so extended classes
  47665. // can have their private assets too.
  47666. ASSET_TYPES.forEach(function (type) {
  47667. Sub[type] = Super[type];
  47668. });
  47669. // enable recursive self-lookup
  47670. if (name) {
  47671. Sub.options.components[name] = Sub;
  47672. }
  47673. // keep a reference to the super options at extension time.
  47674. // later at instantiation we can check if Super's options have
  47675. // been updated.
  47676. Sub.superOptions = Super.options;
  47677. Sub.extendOptions = extendOptions;
  47678. Sub.sealedOptions = extend({}, Sub.options);
  47679. // cache constructor
  47680. cachedCtors[SuperId] = Sub;
  47681. return Sub
  47682. };
  47683. }
  47684. function initProps$1 (Comp) {
  47685. var props = Comp.options.props;
  47686. for (var key in props) {
  47687. proxy(Comp.prototype, "_props", key);
  47688. }
  47689. }
  47690. function initComputed$1 (Comp) {
  47691. var computed = Comp.options.computed;
  47692. for (var key in computed) {
  47693. defineComputed(Comp.prototype, key, computed[key]);
  47694. }
  47695. }
  47696. /* */
  47697. function initAssetRegisters (Vue) {
  47698. /**
  47699. * Create asset registration methods.
  47700. */
  47701. ASSET_TYPES.forEach(function (type) {
  47702. Vue[type] = function (
  47703. id,
  47704. definition
  47705. ) {
  47706. if (!definition) {
  47707. return this.options[type + 's'][id]
  47708. } else {
  47709. /* istanbul ignore if */
  47710. if (type === 'component') {
  47711. validateComponentName(id);
  47712. }
  47713. if (type === 'component' && isPlainObject(definition)) {
  47714. definition.name = definition.name || id;
  47715. definition = this.options._base.extend(definition);
  47716. }
  47717. if (type === 'directive' && typeof definition === 'function') {
  47718. definition = { bind: definition, update: definition };
  47719. }
  47720. this.options[type + 's'][id] = definition;
  47721. return definition
  47722. }
  47723. };
  47724. });
  47725. }
  47726. /* */
  47727. function getComponentName (opts) {
  47728. return opts && (opts.Ctor.options.name || opts.tag)
  47729. }
  47730. function matches (pattern, name) {
  47731. if (Array.isArray(pattern)) {
  47732. return pattern.indexOf(name) > -1
  47733. } else if (typeof pattern === 'string') {
  47734. return pattern.split(',').indexOf(name) > -1
  47735. } else if (isRegExp(pattern)) {
  47736. return pattern.test(name)
  47737. }
  47738. /* istanbul ignore next */
  47739. return false
  47740. }
  47741. function pruneCache (keepAliveInstance, filter) {
  47742. var cache = keepAliveInstance.cache;
  47743. var keys = keepAliveInstance.keys;
  47744. var _vnode = keepAliveInstance._vnode;
  47745. for (var key in cache) {
  47746. var cachedNode = cache[key];
  47747. if (cachedNode) {
  47748. var name = getComponentName(cachedNode.componentOptions);
  47749. if (name && !filter(name)) {
  47750. pruneCacheEntry(cache, key, keys, _vnode);
  47751. }
  47752. }
  47753. }
  47754. }
  47755. function pruneCacheEntry (
  47756. cache,
  47757. key,
  47758. keys,
  47759. current
  47760. ) {
  47761. var cached$$1 = cache[key];
  47762. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  47763. cached$$1.componentInstance.$destroy();
  47764. }
  47765. cache[key] = null;
  47766. remove(keys, key);
  47767. }
  47768. var patternTypes = [String, RegExp, Array];
  47769. var KeepAlive = {
  47770. name: 'keep-alive',
  47771. abstract: true,
  47772. props: {
  47773. include: patternTypes,
  47774. exclude: patternTypes,
  47775. max: [String, Number]
  47776. },
  47777. created: function created () {
  47778. this.cache = Object.create(null);
  47779. this.keys = [];
  47780. },
  47781. destroyed: function destroyed () {
  47782. for (var key in this.cache) {
  47783. pruneCacheEntry(this.cache, key, this.keys);
  47784. }
  47785. },
  47786. mounted: function mounted () {
  47787. var this$1 = this;
  47788. this.$watch('include', function (val) {
  47789. pruneCache(this$1, function (name) { return matches(val, name); });
  47790. });
  47791. this.$watch('exclude', function (val) {
  47792. pruneCache(this$1, function (name) { return !matches(val, name); });
  47793. });
  47794. },
  47795. render: function render () {
  47796. var slot = this.$slots.default;
  47797. var vnode = getFirstComponentChild(slot);
  47798. var componentOptions = vnode && vnode.componentOptions;
  47799. if (componentOptions) {
  47800. // check pattern
  47801. var name = getComponentName(componentOptions);
  47802. var ref = this;
  47803. var include = ref.include;
  47804. var exclude = ref.exclude;
  47805. if (
  47806. // not included
  47807. (include && (!name || !matches(include, name))) ||
  47808. // excluded
  47809. (exclude && name && matches(exclude, name))
  47810. ) {
  47811. return vnode
  47812. }
  47813. var ref$1 = this;
  47814. var cache = ref$1.cache;
  47815. var keys = ref$1.keys;
  47816. var key = vnode.key == null
  47817. // same constructor may get registered as different local components
  47818. // so cid alone is not enough (#3269)
  47819. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  47820. : vnode.key;
  47821. if (cache[key]) {
  47822. vnode.componentInstance = cache[key].componentInstance;
  47823. // make current key freshest
  47824. remove(keys, key);
  47825. keys.push(key);
  47826. } else {
  47827. cache[key] = vnode;
  47828. keys.push(key);
  47829. // prune oldest entry
  47830. if (this.max && keys.length > parseInt(this.max)) {
  47831. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  47832. }
  47833. }
  47834. vnode.data.keepAlive = true;
  47835. }
  47836. return vnode || (slot && slot[0])
  47837. }
  47838. };
  47839. var builtInComponents = {
  47840. KeepAlive: KeepAlive
  47841. };
  47842. /* */
  47843. function initGlobalAPI (Vue) {
  47844. // config
  47845. var configDef = {};
  47846. configDef.get = function () { return config; };
  47847. {
  47848. configDef.set = function () {
  47849. warn(
  47850. 'Do not replace the Vue.config object, set individual fields instead.'
  47851. );
  47852. };
  47853. }
  47854. Object.defineProperty(Vue, 'config', configDef);
  47855. // exposed util methods.
  47856. // NOTE: these are not considered part of the public API - avoid relying on
  47857. // them unless you are aware of the risk.
  47858. Vue.util = {
  47859. warn: warn,
  47860. extend: extend,
  47861. mergeOptions: mergeOptions,
  47862. defineReactive: defineReactive$$1
  47863. };
  47864. Vue.set = set;
  47865. Vue.delete = del;
  47866. Vue.nextTick = nextTick;
  47867. // 2.6 explicit observable API
  47868. Vue.observable = function (obj) {
  47869. observe(obj);
  47870. return obj
  47871. };
  47872. Vue.options = Object.create(null);
  47873. ASSET_TYPES.forEach(function (type) {
  47874. Vue.options[type + 's'] = Object.create(null);
  47875. });
  47876. // this is used to identify the "base" constructor to extend all plain-object
  47877. // components with in Weex's multi-instance scenarios.
  47878. Vue.options._base = Vue;
  47879. extend(Vue.options.components, builtInComponents);
  47880. initUse(Vue);
  47881. initMixin$1(Vue);
  47882. initExtend(Vue);
  47883. initAssetRegisters(Vue);
  47884. }
  47885. initGlobalAPI(Vue);
  47886. Object.defineProperty(Vue.prototype, '$isServer', {
  47887. get: isServerRendering
  47888. });
  47889. Object.defineProperty(Vue.prototype, '$ssrContext', {
  47890. get: function get () {
  47891. /* istanbul ignore next */
  47892. return this.$vnode && this.$vnode.ssrContext
  47893. }
  47894. });
  47895. // expose FunctionalRenderContext for ssr runtime helper installation
  47896. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  47897. value: FunctionalRenderContext
  47898. });
  47899. Vue.version = '2.6.11';
  47900. /* */
  47901. // these are reserved for web because they are directly compiled away
  47902. // during template compilation
  47903. var isReservedAttr = makeMap('style,class');
  47904. // attributes that should be using props for binding
  47905. var acceptValue = makeMap('input,textarea,option,select,progress');
  47906. var mustUseProp = function (tag, type, attr) {
  47907. return (
  47908. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  47909. (attr === 'selected' && tag === 'option') ||
  47910. (attr === 'checked' && tag === 'input') ||
  47911. (attr === 'muted' && tag === 'video')
  47912. )
  47913. };
  47914. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  47915. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  47916. var convertEnumeratedValue = function (key, value) {
  47917. return isFalsyAttrValue(value) || value === 'false'
  47918. ? 'false'
  47919. // allow arbitrary string value for contenteditable
  47920. : key === 'contenteditable' && isValidContentEditableValue(value)
  47921. ? value
  47922. : 'true'
  47923. };
  47924. var isBooleanAttr = makeMap(
  47925. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  47926. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  47927. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  47928. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  47929. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  47930. 'truespeed,typemustmatch,visible'
  47931. );
  47932. var xlinkNS = 'http://www.w3.org/1999/xlink';
  47933. var isXlink = function (name) {
  47934. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  47935. };
  47936. var getXlinkProp = function (name) {
  47937. return isXlink(name) ? name.slice(6, name.length) : ''
  47938. };
  47939. var isFalsyAttrValue = function (val) {
  47940. return val == null || val === false
  47941. };
  47942. /* */
  47943. function genClassForVnode (vnode) {
  47944. var data = vnode.data;
  47945. var parentNode = vnode;
  47946. var childNode = vnode;
  47947. while (isDef(childNode.componentInstance)) {
  47948. childNode = childNode.componentInstance._vnode;
  47949. if (childNode && childNode.data) {
  47950. data = mergeClassData(childNode.data, data);
  47951. }
  47952. }
  47953. while (isDef(parentNode = parentNode.parent)) {
  47954. if (parentNode && parentNode.data) {
  47955. data = mergeClassData(data, parentNode.data);
  47956. }
  47957. }
  47958. return renderClass(data.staticClass, data.class)
  47959. }
  47960. function mergeClassData (child, parent) {
  47961. return {
  47962. staticClass: concat(child.staticClass, parent.staticClass),
  47963. class: isDef(child.class)
  47964. ? [child.class, parent.class]
  47965. : parent.class
  47966. }
  47967. }
  47968. function renderClass (
  47969. staticClass,
  47970. dynamicClass
  47971. ) {
  47972. if (isDef(staticClass) || isDef(dynamicClass)) {
  47973. return concat(staticClass, stringifyClass(dynamicClass))
  47974. }
  47975. /* istanbul ignore next */
  47976. return ''
  47977. }
  47978. function concat (a, b) {
  47979. return a ? b ? (a + ' ' + b) : a : (b || '')
  47980. }
  47981. function stringifyClass (value) {
  47982. if (Array.isArray(value)) {
  47983. return stringifyArray(value)
  47984. }
  47985. if (isObject(value)) {
  47986. return stringifyObject(value)
  47987. }
  47988. if (typeof value === 'string') {
  47989. return value
  47990. }
  47991. /* istanbul ignore next */
  47992. return ''
  47993. }
  47994. function stringifyArray (value) {
  47995. var res = '';
  47996. var stringified;
  47997. for (var i = 0, l = value.length; i < l; i++) {
  47998. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  47999. if (res) { res += ' '; }
  48000. res += stringified;
  48001. }
  48002. }
  48003. return res
  48004. }
  48005. function stringifyObject (value) {
  48006. var res = '';
  48007. for (var key in value) {
  48008. if (value[key]) {
  48009. if (res) { res += ' '; }
  48010. res += key;
  48011. }
  48012. }
  48013. return res
  48014. }
  48015. /* */
  48016. var namespaceMap = {
  48017. svg: 'http://www.w3.org/2000/svg',
  48018. math: 'http://www.w3.org/1998/Math/MathML'
  48019. };
  48020. var isHTMLTag = makeMap(
  48021. 'html,body,base,head,link,meta,style,title,' +
  48022. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  48023. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  48024. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  48025. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  48026. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  48027. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  48028. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  48029. 'output,progress,select,textarea,' +
  48030. 'details,dialog,menu,menuitem,summary,' +
  48031. 'content,element,shadow,template,blockquote,iframe,tfoot'
  48032. );
  48033. // this map is intentionally selective, only covering SVG elements that may
  48034. // contain child elements.
  48035. var isSVG = makeMap(
  48036. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  48037. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  48038. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  48039. true
  48040. );
  48041. var isPreTag = function (tag) { return tag === 'pre'; };
  48042. var isReservedTag = function (tag) {
  48043. return isHTMLTag(tag) || isSVG(tag)
  48044. };
  48045. function getTagNamespace (tag) {
  48046. if (isSVG(tag)) {
  48047. return 'svg'
  48048. }
  48049. // basic support for MathML
  48050. // note it doesn't support other MathML elements being component roots
  48051. if (tag === 'math') {
  48052. return 'math'
  48053. }
  48054. }
  48055. var unknownElementCache = Object.create(null);
  48056. function isUnknownElement (tag) {
  48057. /* istanbul ignore if */
  48058. if (!inBrowser) {
  48059. return true
  48060. }
  48061. if (isReservedTag(tag)) {
  48062. return false
  48063. }
  48064. tag = tag.toLowerCase();
  48065. /* istanbul ignore if */
  48066. if (unknownElementCache[tag] != null) {
  48067. return unknownElementCache[tag]
  48068. }
  48069. var el = document.createElement(tag);
  48070. if (tag.indexOf('-') > -1) {
  48071. // http://stackoverflow.com/a/28210364/1070244
  48072. return (unknownElementCache[tag] = (
  48073. el.constructor === window.HTMLUnknownElement ||
  48074. el.constructor === window.HTMLElement
  48075. ))
  48076. } else {
  48077. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  48078. }
  48079. }
  48080. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  48081. /* */
  48082. /**
  48083. * Query an element selector if it's not an element already.
  48084. */
  48085. function query (el) {
  48086. if (typeof el === 'string') {
  48087. var selected = document.querySelector(el);
  48088. if (!selected) {
  48089. warn(
  48090. 'Cannot find element: ' + el
  48091. );
  48092. return document.createElement('div')
  48093. }
  48094. return selected
  48095. } else {
  48096. return el
  48097. }
  48098. }
  48099. /* */
  48100. function createElement$1 (tagName, vnode) {
  48101. var elm = document.createElement(tagName);
  48102. if (tagName !== 'select') {
  48103. return elm
  48104. }
  48105. // false or null will remove the attribute but undefined will not
  48106. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  48107. elm.setAttribute('multiple', 'multiple');
  48108. }
  48109. return elm
  48110. }
  48111. function createElementNS (namespace, tagName) {
  48112. return document.createElementNS(namespaceMap[namespace], tagName)
  48113. }
  48114. function createTextNode (text) {
  48115. return document.createTextNode(text)
  48116. }
  48117. function createComment (text) {
  48118. return document.createComment(text)
  48119. }
  48120. function insertBefore (parentNode, newNode, referenceNode) {
  48121. parentNode.insertBefore(newNode, referenceNode);
  48122. }
  48123. function removeChild (node, child) {
  48124. node.removeChild(child);
  48125. }
  48126. function appendChild (node, child) {
  48127. node.appendChild(child);
  48128. }
  48129. function parentNode (node) {
  48130. return node.parentNode
  48131. }
  48132. function nextSibling (node) {
  48133. return node.nextSibling
  48134. }
  48135. function tagName (node) {
  48136. return node.tagName
  48137. }
  48138. function setTextContent (node, text) {
  48139. node.textContent = text;
  48140. }
  48141. function setStyleScope (node, scopeId) {
  48142. node.setAttribute(scopeId, '');
  48143. }
  48144. var nodeOps = /*#__PURE__*/Object.freeze({
  48145. createElement: createElement$1,
  48146. createElementNS: createElementNS,
  48147. createTextNode: createTextNode,
  48148. createComment: createComment,
  48149. insertBefore: insertBefore,
  48150. removeChild: removeChild,
  48151. appendChild: appendChild,
  48152. parentNode: parentNode,
  48153. nextSibling: nextSibling,
  48154. tagName: tagName,
  48155. setTextContent: setTextContent,
  48156. setStyleScope: setStyleScope
  48157. });
  48158. /* */
  48159. var ref = {
  48160. create: function create (_, vnode) {
  48161. registerRef(vnode);
  48162. },
  48163. update: function update (oldVnode, vnode) {
  48164. if (oldVnode.data.ref !== vnode.data.ref) {
  48165. registerRef(oldVnode, true);
  48166. registerRef(vnode);
  48167. }
  48168. },
  48169. destroy: function destroy (vnode) {
  48170. registerRef(vnode, true);
  48171. }
  48172. };
  48173. function registerRef (vnode, isRemoval) {
  48174. var key = vnode.data.ref;
  48175. if (!isDef(key)) { return }
  48176. var vm = vnode.context;
  48177. var ref = vnode.componentInstance || vnode.elm;
  48178. var refs = vm.$refs;
  48179. if (isRemoval) {
  48180. if (Array.isArray(refs[key])) {
  48181. remove(refs[key], ref);
  48182. } else if (refs[key] === ref) {
  48183. refs[key] = undefined;
  48184. }
  48185. } else {
  48186. if (vnode.data.refInFor) {
  48187. if (!Array.isArray(refs[key])) {
  48188. refs[key] = [ref];
  48189. } else if (refs[key].indexOf(ref) < 0) {
  48190. // $flow-disable-line
  48191. refs[key].push(ref);
  48192. }
  48193. } else {
  48194. refs[key] = ref;
  48195. }
  48196. }
  48197. }
  48198. /**
  48199. * Virtual DOM patching algorithm based on Snabbdom by
  48200. * Simon Friis Vindum (@paldepind)
  48201. * Licensed under the MIT License
  48202. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  48203. *
  48204. * modified by Evan You (@yyx990803)
  48205. *
  48206. * Not type-checking this because this file is perf-critical and the cost
  48207. * of making flow understand it is not worth it.
  48208. */
  48209. var emptyNode = new VNode('', {}, []);
  48210. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  48211. function sameVnode (a, b) {
  48212. return (
  48213. a.key === b.key && (
  48214. (
  48215. a.tag === b.tag &&
  48216. a.isComment === b.isComment &&
  48217. isDef(a.data) === isDef(b.data) &&
  48218. sameInputType(a, b)
  48219. ) || (
  48220. isTrue(a.isAsyncPlaceholder) &&
  48221. a.asyncFactory === b.asyncFactory &&
  48222. isUndef(b.asyncFactory.error)
  48223. )
  48224. )
  48225. )
  48226. }
  48227. function sameInputType (a, b) {
  48228. if (a.tag !== 'input') { return true }
  48229. var i;
  48230. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  48231. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  48232. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  48233. }
  48234. function createKeyToOldIdx (children, beginIdx, endIdx) {
  48235. var i, key;
  48236. var map = {};
  48237. for (i = beginIdx; i <= endIdx; ++i) {
  48238. key = children[i].key;
  48239. if (isDef(key)) { map[key] = i; }
  48240. }
  48241. return map
  48242. }
  48243. function createPatchFunction (backend) {
  48244. var i, j;
  48245. var cbs = {};
  48246. var modules = backend.modules;
  48247. var nodeOps = backend.nodeOps;
  48248. for (i = 0; i < hooks.length; ++i) {
  48249. cbs[hooks[i]] = [];
  48250. for (j = 0; j < modules.length; ++j) {
  48251. if (isDef(modules[j][hooks[i]])) {
  48252. cbs[hooks[i]].push(modules[j][hooks[i]]);
  48253. }
  48254. }
  48255. }
  48256. function emptyNodeAt (elm) {
  48257. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  48258. }
  48259. function createRmCb (childElm, listeners) {
  48260. function remove$$1 () {
  48261. if (--remove$$1.listeners === 0) {
  48262. removeNode(childElm);
  48263. }
  48264. }
  48265. remove$$1.listeners = listeners;
  48266. return remove$$1
  48267. }
  48268. function removeNode (el) {
  48269. var parent = nodeOps.parentNode(el);
  48270. // element may have already been removed due to v-html / v-text
  48271. if (isDef(parent)) {
  48272. nodeOps.removeChild(parent, el);
  48273. }
  48274. }
  48275. function isUnknownElement$$1 (vnode, inVPre) {
  48276. return (
  48277. !inVPre &&
  48278. !vnode.ns &&
  48279. !(
  48280. config.ignoredElements.length &&
  48281. config.ignoredElements.some(function (ignore) {
  48282. return isRegExp(ignore)
  48283. ? ignore.test(vnode.tag)
  48284. : ignore === vnode.tag
  48285. })
  48286. ) &&
  48287. config.isUnknownElement(vnode.tag)
  48288. )
  48289. }
  48290. var creatingElmInVPre = 0;
  48291. function createElm (
  48292. vnode,
  48293. insertedVnodeQueue,
  48294. parentElm,
  48295. refElm,
  48296. nested,
  48297. ownerArray,
  48298. index
  48299. ) {
  48300. if (isDef(vnode.elm) && isDef(ownerArray)) {
  48301. // This vnode was used in a previous render!
  48302. // now it's used as a new node, overwriting its elm would cause
  48303. // potential patch errors down the road when it's used as an insertion
  48304. // reference node. Instead, we clone the node on-demand before creating
  48305. // associated DOM element for it.
  48306. vnode = ownerArray[index] = cloneVNode(vnode);
  48307. }
  48308. vnode.isRootInsert = !nested; // for transition enter check
  48309. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  48310. return
  48311. }
  48312. var data = vnode.data;
  48313. var children = vnode.children;
  48314. var tag = vnode.tag;
  48315. if (isDef(tag)) {
  48316. {
  48317. if (data && data.pre) {
  48318. creatingElmInVPre++;
  48319. }
  48320. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  48321. warn(
  48322. 'Unknown custom element: <' + tag + '> - did you ' +
  48323. 'register the component correctly? For recursive components, ' +
  48324. 'make sure to provide the "name" option.',
  48325. vnode.context
  48326. );
  48327. }
  48328. }
  48329. vnode.elm = vnode.ns
  48330. ? nodeOps.createElementNS(vnode.ns, tag)
  48331. : nodeOps.createElement(tag, vnode);
  48332. setScope(vnode);
  48333. /* istanbul ignore if */
  48334. {
  48335. createChildren(vnode, children, insertedVnodeQueue);
  48336. if (isDef(data)) {
  48337. invokeCreateHooks(vnode, insertedVnodeQueue);
  48338. }
  48339. insert(parentElm, vnode.elm, refElm);
  48340. }
  48341. if (data && data.pre) {
  48342. creatingElmInVPre--;
  48343. }
  48344. } else if (isTrue(vnode.isComment)) {
  48345. vnode.elm = nodeOps.createComment(vnode.text);
  48346. insert(parentElm, vnode.elm, refElm);
  48347. } else {
  48348. vnode.elm = nodeOps.createTextNode(vnode.text);
  48349. insert(parentElm, vnode.elm, refElm);
  48350. }
  48351. }
  48352. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  48353. var i = vnode.data;
  48354. if (isDef(i)) {
  48355. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  48356. if (isDef(i = i.hook) && isDef(i = i.init)) {
  48357. i(vnode, false /* hydrating */);
  48358. }
  48359. // after calling the init hook, if the vnode is a child component
  48360. // it should've created a child instance and mounted it. the child
  48361. // component also has set the placeholder vnode's elm.
  48362. // in that case we can just return the element and be done.
  48363. if (isDef(vnode.componentInstance)) {
  48364. initComponent(vnode, insertedVnodeQueue);
  48365. insert(parentElm, vnode.elm, refElm);
  48366. if (isTrue(isReactivated)) {
  48367. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  48368. }
  48369. return true
  48370. }
  48371. }
  48372. }
  48373. function initComponent (vnode, insertedVnodeQueue) {
  48374. if (isDef(vnode.data.pendingInsert)) {
  48375. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  48376. vnode.data.pendingInsert = null;
  48377. }
  48378. vnode.elm = vnode.componentInstance.$el;
  48379. if (isPatchable(vnode)) {
  48380. invokeCreateHooks(vnode, insertedVnodeQueue);
  48381. setScope(vnode);
  48382. } else {
  48383. // empty component root.
  48384. // skip all element-related modules except for ref (#3455)
  48385. registerRef(vnode);
  48386. // make sure to invoke the insert hook
  48387. insertedVnodeQueue.push(vnode);
  48388. }
  48389. }
  48390. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  48391. var i;
  48392. // hack for #4339: a reactivated component with inner transition
  48393. // does not trigger because the inner node's created hooks are not called
  48394. // again. It's not ideal to involve module-specific logic in here but
  48395. // there doesn't seem to be a better way to do it.
  48396. var innerNode = vnode;
  48397. while (innerNode.componentInstance) {
  48398. innerNode = innerNode.componentInstance._vnode;
  48399. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  48400. for (i = 0; i < cbs.activate.length; ++i) {
  48401. cbs.activate[i](emptyNode, innerNode);
  48402. }
  48403. insertedVnodeQueue.push(innerNode);
  48404. break
  48405. }
  48406. }
  48407. // unlike a newly created component,
  48408. // a reactivated keep-alive component doesn't insert itself
  48409. insert(parentElm, vnode.elm, refElm);
  48410. }
  48411. function insert (parent, elm, ref$$1) {
  48412. if (isDef(parent)) {
  48413. if (isDef(ref$$1)) {
  48414. if (nodeOps.parentNode(ref$$1) === parent) {
  48415. nodeOps.insertBefore(parent, elm, ref$$1);
  48416. }
  48417. } else {
  48418. nodeOps.appendChild(parent, elm);
  48419. }
  48420. }
  48421. }
  48422. function createChildren (vnode, children, insertedVnodeQueue) {
  48423. if (Array.isArray(children)) {
  48424. {
  48425. checkDuplicateKeys(children);
  48426. }
  48427. for (var i = 0; i < children.length; ++i) {
  48428. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  48429. }
  48430. } else if (isPrimitive(vnode.text)) {
  48431. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  48432. }
  48433. }
  48434. function isPatchable (vnode) {
  48435. while (vnode.componentInstance) {
  48436. vnode = vnode.componentInstance._vnode;
  48437. }
  48438. return isDef(vnode.tag)
  48439. }
  48440. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  48441. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  48442. cbs.create[i$1](emptyNode, vnode);
  48443. }
  48444. i = vnode.data.hook; // Reuse variable
  48445. if (isDef(i)) {
  48446. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  48447. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  48448. }
  48449. }
  48450. // set scope id attribute for scoped CSS.
  48451. // this is implemented as a special case to avoid the overhead
  48452. // of going through the normal attribute patching process.
  48453. function setScope (vnode) {
  48454. var i;
  48455. if (isDef(i = vnode.fnScopeId)) {
  48456. nodeOps.setStyleScope(vnode.elm, i);
  48457. } else {
  48458. var ancestor = vnode;
  48459. while (ancestor) {
  48460. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  48461. nodeOps.setStyleScope(vnode.elm, i);
  48462. }
  48463. ancestor = ancestor.parent;
  48464. }
  48465. }
  48466. // for slot content they should also get the scopeId from the host instance.
  48467. if (isDef(i = activeInstance) &&
  48468. i !== vnode.context &&
  48469. i !== vnode.fnContext &&
  48470. isDef(i = i.$options._scopeId)
  48471. ) {
  48472. nodeOps.setStyleScope(vnode.elm, i);
  48473. }
  48474. }
  48475. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  48476. for (; startIdx <= endIdx; ++startIdx) {
  48477. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  48478. }
  48479. }
  48480. function invokeDestroyHook (vnode) {
  48481. var i, j;
  48482. var data = vnode.data;
  48483. if (isDef(data)) {
  48484. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  48485. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  48486. }
  48487. if (isDef(i = vnode.children)) {
  48488. for (j = 0; j < vnode.children.length; ++j) {
  48489. invokeDestroyHook(vnode.children[j]);
  48490. }
  48491. }
  48492. }
  48493. function removeVnodes (vnodes, startIdx, endIdx) {
  48494. for (; startIdx <= endIdx; ++startIdx) {
  48495. var ch = vnodes[startIdx];
  48496. if (isDef(ch)) {
  48497. if (isDef(ch.tag)) {
  48498. removeAndInvokeRemoveHook(ch);
  48499. invokeDestroyHook(ch);
  48500. } else { // Text node
  48501. removeNode(ch.elm);
  48502. }
  48503. }
  48504. }
  48505. }
  48506. function removeAndInvokeRemoveHook (vnode, rm) {
  48507. if (isDef(rm) || isDef(vnode.data)) {
  48508. var i;
  48509. var listeners = cbs.remove.length + 1;
  48510. if (isDef(rm)) {
  48511. // we have a recursively passed down rm callback
  48512. // increase the listeners count
  48513. rm.listeners += listeners;
  48514. } else {
  48515. // directly removing
  48516. rm = createRmCb(vnode.elm, listeners);
  48517. }
  48518. // recursively invoke hooks on child component root node
  48519. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  48520. removeAndInvokeRemoveHook(i, rm);
  48521. }
  48522. for (i = 0; i < cbs.remove.length; ++i) {
  48523. cbs.remove[i](vnode, rm);
  48524. }
  48525. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  48526. i(vnode, rm);
  48527. } else {
  48528. rm();
  48529. }
  48530. } else {
  48531. removeNode(vnode.elm);
  48532. }
  48533. }
  48534. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  48535. var oldStartIdx = 0;
  48536. var newStartIdx = 0;
  48537. var oldEndIdx = oldCh.length - 1;
  48538. var oldStartVnode = oldCh[0];
  48539. var oldEndVnode = oldCh[oldEndIdx];
  48540. var newEndIdx = newCh.length - 1;
  48541. var newStartVnode = newCh[0];
  48542. var newEndVnode = newCh[newEndIdx];
  48543. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  48544. // removeOnly is a special flag used only by <transition-group>
  48545. // to ensure removed elements stay in correct relative positions
  48546. // during leaving transitions
  48547. var canMove = !removeOnly;
  48548. {
  48549. checkDuplicateKeys(newCh);
  48550. }
  48551. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  48552. if (isUndef(oldStartVnode)) {
  48553. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  48554. } else if (isUndef(oldEndVnode)) {
  48555. oldEndVnode = oldCh[--oldEndIdx];
  48556. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  48557. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  48558. oldStartVnode = oldCh[++oldStartIdx];
  48559. newStartVnode = newCh[++newStartIdx];
  48560. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  48561. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  48562. oldEndVnode = oldCh[--oldEndIdx];
  48563. newEndVnode = newCh[--newEndIdx];
  48564. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  48565. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  48566. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  48567. oldStartVnode = oldCh[++oldStartIdx];
  48568. newEndVnode = newCh[--newEndIdx];
  48569. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  48570. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  48571. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  48572. oldEndVnode = oldCh[--oldEndIdx];
  48573. newStartVnode = newCh[++newStartIdx];
  48574. } else {
  48575. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  48576. idxInOld = isDef(newStartVnode.key)
  48577. ? oldKeyToIdx[newStartVnode.key]
  48578. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  48579. if (isUndef(idxInOld)) { // New element
  48580. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  48581. } else {
  48582. vnodeToMove = oldCh[idxInOld];
  48583. if (sameVnode(vnodeToMove, newStartVnode)) {
  48584. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  48585. oldCh[idxInOld] = undefined;
  48586. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  48587. } else {
  48588. // same key but different element. treat as new element
  48589. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  48590. }
  48591. }
  48592. newStartVnode = newCh[++newStartIdx];
  48593. }
  48594. }
  48595. if (oldStartIdx > oldEndIdx) {
  48596. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  48597. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  48598. } else if (newStartIdx > newEndIdx) {
  48599. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  48600. }
  48601. }
  48602. function checkDuplicateKeys (children) {
  48603. var seenKeys = {};
  48604. for (var i = 0; i < children.length; i++) {
  48605. var vnode = children[i];
  48606. var key = vnode.key;
  48607. if (isDef(key)) {
  48608. if (seenKeys[key]) {
  48609. warn(
  48610. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  48611. vnode.context
  48612. );
  48613. } else {
  48614. seenKeys[key] = true;
  48615. }
  48616. }
  48617. }
  48618. }
  48619. function findIdxInOld (node, oldCh, start, end) {
  48620. for (var i = start; i < end; i++) {
  48621. var c = oldCh[i];
  48622. if (isDef(c) && sameVnode(node, c)) { return i }
  48623. }
  48624. }
  48625. function patchVnode (
  48626. oldVnode,
  48627. vnode,
  48628. insertedVnodeQueue,
  48629. ownerArray,
  48630. index,
  48631. removeOnly
  48632. ) {
  48633. if (oldVnode === vnode) {
  48634. return
  48635. }
  48636. if (isDef(vnode.elm) && isDef(ownerArray)) {
  48637. // clone reused vnode
  48638. vnode = ownerArray[index] = cloneVNode(vnode);
  48639. }
  48640. var elm = vnode.elm = oldVnode.elm;
  48641. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  48642. if (isDef(vnode.asyncFactory.resolved)) {
  48643. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  48644. } else {
  48645. vnode.isAsyncPlaceholder = true;
  48646. }
  48647. return
  48648. }
  48649. // reuse element for static trees.
  48650. // note we only do this if the vnode is cloned -
  48651. // if the new node is not cloned it means the render functions have been
  48652. // reset by the hot-reload-api and we need to do a proper re-render.
  48653. if (isTrue(vnode.isStatic) &&
  48654. isTrue(oldVnode.isStatic) &&
  48655. vnode.key === oldVnode.key &&
  48656. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  48657. ) {
  48658. vnode.componentInstance = oldVnode.componentInstance;
  48659. return
  48660. }
  48661. var i;
  48662. var data = vnode.data;
  48663. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  48664. i(oldVnode, vnode);
  48665. }
  48666. var oldCh = oldVnode.children;
  48667. var ch = vnode.children;
  48668. if (isDef(data) && isPatchable(vnode)) {
  48669. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  48670. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  48671. }
  48672. if (isUndef(vnode.text)) {
  48673. if (isDef(oldCh) && isDef(ch)) {
  48674. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  48675. } else if (isDef(ch)) {
  48676. {
  48677. checkDuplicateKeys(ch);
  48678. }
  48679. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  48680. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  48681. } else if (isDef(oldCh)) {
  48682. removeVnodes(oldCh, 0, oldCh.length - 1);
  48683. } else if (isDef(oldVnode.text)) {
  48684. nodeOps.setTextContent(elm, '');
  48685. }
  48686. } else if (oldVnode.text !== vnode.text) {
  48687. nodeOps.setTextContent(elm, vnode.text);
  48688. }
  48689. if (isDef(data)) {
  48690. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  48691. }
  48692. }
  48693. function invokeInsertHook (vnode, queue, initial) {
  48694. // delay insert hooks for component root nodes, invoke them after the
  48695. // element is really inserted
  48696. if (isTrue(initial) && isDef(vnode.parent)) {
  48697. vnode.parent.data.pendingInsert = queue;
  48698. } else {
  48699. for (var i = 0; i < queue.length; ++i) {
  48700. queue[i].data.hook.insert(queue[i]);
  48701. }
  48702. }
  48703. }
  48704. var hydrationBailed = false;
  48705. // list of modules that can skip create hook during hydration because they
  48706. // are already rendered on the client or has no need for initialization
  48707. // Note: style is excluded because it relies on initial clone for future
  48708. // deep updates (#7063).
  48709. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  48710. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  48711. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  48712. var i;
  48713. var tag = vnode.tag;
  48714. var data = vnode.data;
  48715. var children = vnode.children;
  48716. inVPre = inVPre || (data && data.pre);
  48717. vnode.elm = elm;
  48718. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  48719. vnode.isAsyncPlaceholder = true;
  48720. return true
  48721. }
  48722. // assert node match
  48723. {
  48724. if (!assertNodeMatch(elm, vnode, inVPre)) {
  48725. return false
  48726. }
  48727. }
  48728. if (isDef(data)) {
  48729. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  48730. if (isDef(i = vnode.componentInstance)) {
  48731. // child component. it should have hydrated its own tree.
  48732. initComponent(vnode, insertedVnodeQueue);
  48733. return true
  48734. }
  48735. }
  48736. if (isDef(tag)) {
  48737. if (isDef(children)) {
  48738. // empty element, allow client to pick up and populate children
  48739. if (!elm.hasChildNodes()) {
  48740. createChildren(vnode, children, insertedVnodeQueue);
  48741. } else {
  48742. // v-html and domProps: innerHTML
  48743. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  48744. if (i !== elm.innerHTML) {
  48745. /* istanbul ignore if */
  48746. if (typeof console !== 'undefined' &&
  48747. !hydrationBailed
  48748. ) {
  48749. hydrationBailed = true;
  48750. console.warn('Parent: ', elm);
  48751. console.warn('server innerHTML: ', i);
  48752. console.warn('client innerHTML: ', elm.innerHTML);
  48753. }
  48754. return false
  48755. }
  48756. } else {
  48757. // iterate and compare children lists
  48758. var childrenMatch = true;
  48759. var childNode = elm.firstChild;
  48760. for (var i$1 = 0; i$1 < children.length; i$1++) {
  48761. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  48762. childrenMatch = false;
  48763. break
  48764. }
  48765. childNode = childNode.nextSibling;
  48766. }
  48767. // if childNode is not null, it means the actual childNodes list is
  48768. // longer than the virtual children list.
  48769. if (!childrenMatch || childNode) {
  48770. /* istanbul ignore if */
  48771. if (typeof console !== 'undefined' &&
  48772. !hydrationBailed
  48773. ) {
  48774. hydrationBailed = true;
  48775. console.warn('Parent: ', elm);
  48776. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  48777. }
  48778. return false
  48779. }
  48780. }
  48781. }
  48782. }
  48783. if (isDef(data)) {
  48784. var fullInvoke = false;
  48785. for (var key in data) {
  48786. if (!isRenderedModule(key)) {
  48787. fullInvoke = true;
  48788. invokeCreateHooks(vnode, insertedVnodeQueue);
  48789. break
  48790. }
  48791. }
  48792. if (!fullInvoke && data['class']) {
  48793. // ensure collecting deps for deep class bindings for future updates
  48794. traverse(data['class']);
  48795. }
  48796. }
  48797. } else if (elm.data !== vnode.text) {
  48798. elm.data = vnode.text;
  48799. }
  48800. return true
  48801. }
  48802. function assertNodeMatch (node, vnode, inVPre) {
  48803. if (isDef(vnode.tag)) {
  48804. return vnode.tag.indexOf('vue-component') === 0 || (
  48805. !isUnknownElement$$1(vnode, inVPre) &&
  48806. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  48807. )
  48808. } else {
  48809. return node.nodeType === (vnode.isComment ? 8 : 3)
  48810. }
  48811. }
  48812. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  48813. if (isUndef(vnode)) {
  48814. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  48815. return
  48816. }
  48817. var isInitialPatch = false;
  48818. var insertedVnodeQueue = [];
  48819. if (isUndef(oldVnode)) {
  48820. // empty mount (likely as component), create new root element
  48821. isInitialPatch = true;
  48822. createElm(vnode, insertedVnodeQueue);
  48823. } else {
  48824. var isRealElement = isDef(oldVnode.nodeType);
  48825. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  48826. // patch existing root node
  48827. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  48828. } else {
  48829. if (isRealElement) {
  48830. // mounting to a real element
  48831. // check if this is server-rendered content and if we can perform
  48832. // a successful hydration.
  48833. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  48834. oldVnode.removeAttribute(SSR_ATTR);
  48835. hydrating = true;
  48836. }
  48837. if (isTrue(hydrating)) {
  48838. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  48839. invokeInsertHook(vnode, insertedVnodeQueue, true);
  48840. return oldVnode
  48841. } else {
  48842. warn(
  48843. 'The client-side rendered virtual DOM tree is not matching ' +
  48844. 'server-rendered content. This is likely caused by incorrect ' +
  48845. 'HTML markup, for example nesting block-level elements inside ' +
  48846. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  48847. 'full client-side render.'
  48848. );
  48849. }
  48850. }
  48851. // either not server-rendered, or hydration failed.
  48852. // create an empty node and replace it
  48853. oldVnode = emptyNodeAt(oldVnode);
  48854. }
  48855. // replacing existing element
  48856. var oldElm = oldVnode.elm;
  48857. var parentElm = nodeOps.parentNode(oldElm);
  48858. // create new node
  48859. createElm(
  48860. vnode,
  48861. insertedVnodeQueue,
  48862. // extremely rare edge case: do not insert if old element is in a
  48863. // leaving transition. Only happens when combining transition +
  48864. // keep-alive + HOCs. (#4590)
  48865. oldElm._leaveCb ? null : parentElm,
  48866. nodeOps.nextSibling(oldElm)
  48867. );
  48868. // update parent placeholder node element, recursively
  48869. if (isDef(vnode.parent)) {
  48870. var ancestor = vnode.parent;
  48871. var patchable = isPatchable(vnode);
  48872. while (ancestor) {
  48873. for (var i = 0; i < cbs.destroy.length; ++i) {
  48874. cbs.destroy[i](ancestor);
  48875. }
  48876. ancestor.elm = vnode.elm;
  48877. if (patchable) {
  48878. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  48879. cbs.create[i$1](emptyNode, ancestor);
  48880. }
  48881. // #6513
  48882. // invoke insert hooks that may have been merged by create hooks.
  48883. // e.g. for directives that uses the "inserted" hook.
  48884. var insert = ancestor.data.hook.insert;
  48885. if (insert.merged) {
  48886. // start at index 1 to avoid re-invoking component mounted hook
  48887. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  48888. insert.fns[i$2]();
  48889. }
  48890. }
  48891. } else {
  48892. registerRef(ancestor);
  48893. }
  48894. ancestor = ancestor.parent;
  48895. }
  48896. }
  48897. // destroy old node
  48898. if (isDef(parentElm)) {
  48899. removeVnodes([oldVnode], 0, 0);
  48900. } else if (isDef(oldVnode.tag)) {
  48901. invokeDestroyHook(oldVnode);
  48902. }
  48903. }
  48904. }
  48905. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  48906. return vnode.elm
  48907. }
  48908. }
  48909. /* */
  48910. var directives = {
  48911. create: updateDirectives,
  48912. update: updateDirectives,
  48913. destroy: function unbindDirectives (vnode) {
  48914. updateDirectives(vnode, emptyNode);
  48915. }
  48916. };
  48917. function updateDirectives (oldVnode, vnode) {
  48918. if (oldVnode.data.directives || vnode.data.directives) {
  48919. _update(oldVnode, vnode);
  48920. }
  48921. }
  48922. function _update (oldVnode, vnode) {
  48923. var isCreate = oldVnode === emptyNode;
  48924. var isDestroy = vnode === emptyNode;
  48925. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  48926. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  48927. var dirsWithInsert = [];
  48928. var dirsWithPostpatch = [];
  48929. var key, oldDir, dir;
  48930. for (key in newDirs) {
  48931. oldDir = oldDirs[key];
  48932. dir = newDirs[key];
  48933. if (!oldDir) {
  48934. // new directive, bind
  48935. callHook$1(dir, 'bind', vnode, oldVnode);
  48936. if (dir.def && dir.def.inserted) {
  48937. dirsWithInsert.push(dir);
  48938. }
  48939. } else {
  48940. // existing directive, update
  48941. dir.oldValue = oldDir.value;
  48942. dir.oldArg = oldDir.arg;
  48943. callHook$1(dir, 'update', vnode, oldVnode);
  48944. if (dir.def && dir.def.componentUpdated) {
  48945. dirsWithPostpatch.push(dir);
  48946. }
  48947. }
  48948. }
  48949. if (dirsWithInsert.length) {
  48950. var callInsert = function () {
  48951. for (var i = 0; i < dirsWithInsert.length; i++) {
  48952. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  48953. }
  48954. };
  48955. if (isCreate) {
  48956. mergeVNodeHook(vnode, 'insert', callInsert);
  48957. } else {
  48958. callInsert();
  48959. }
  48960. }
  48961. if (dirsWithPostpatch.length) {
  48962. mergeVNodeHook(vnode, 'postpatch', function () {
  48963. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  48964. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  48965. }
  48966. });
  48967. }
  48968. if (!isCreate) {
  48969. for (key in oldDirs) {
  48970. if (!newDirs[key]) {
  48971. // no longer present, unbind
  48972. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  48973. }
  48974. }
  48975. }
  48976. }
  48977. var emptyModifiers = Object.create(null);
  48978. function normalizeDirectives$1 (
  48979. dirs,
  48980. vm
  48981. ) {
  48982. var res = Object.create(null);
  48983. if (!dirs) {
  48984. // $flow-disable-line
  48985. return res
  48986. }
  48987. var i, dir;
  48988. for (i = 0; i < dirs.length; i++) {
  48989. dir = dirs[i];
  48990. if (!dir.modifiers) {
  48991. // $flow-disable-line
  48992. dir.modifiers = emptyModifiers;
  48993. }
  48994. res[getRawDirName(dir)] = dir;
  48995. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  48996. }
  48997. // $flow-disable-line
  48998. return res
  48999. }
  49000. function getRawDirName (dir) {
  49001. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  49002. }
  49003. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  49004. var fn = dir.def && dir.def[hook];
  49005. if (fn) {
  49006. try {
  49007. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  49008. } catch (e) {
  49009. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  49010. }
  49011. }
  49012. }
  49013. var baseModules = [
  49014. ref,
  49015. directives
  49016. ];
  49017. /* */
  49018. function updateAttrs (oldVnode, vnode) {
  49019. var opts = vnode.componentOptions;
  49020. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  49021. return
  49022. }
  49023. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  49024. return
  49025. }
  49026. var key, cur, old;
  49027. var elm = vnode.elm;
  49028. var oldAttrs = oldVnode.data.attrs || {};
  49029. var attrs = vnode.data.attrs || {};
  49030. // clone observed objects, as the user probably wants to mutate it
  49031. if (isDef(attrs.__ob__)) {
  49032. attrs = vnode.data.attrs = extend({}, attrs);
  49033. }
  49034. for (key in attrs) {
  49035. cur = attrs[key];
  49036. old = oldAttrs[key];
  49037. if (old !== cur) {
  49038. setAttr(elm, key, cur);
  49039. }
  49040. }
  49041. // #4391: in IE9, setting type can reset value for input[type=radio]
  49042. // #6666: IE/Edge forces progress value down to 1 before setting a max
  49043. /* istanbul ignore if */
  49044. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  49045. setAttr(elm, 'value', attrs.value);
  49046. }
  49047. for (key in oldAttrs) {
  49048. if (isUndef(attrs[key])) {
  49049. if (isXlink(key)) {
  49050. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  49051. } else if (!isEnumeratedAttr(key)) {
  49052. elm.removeAttribute(key);
  49053. }
  49054. }
  49055. }
  49056. }
  49057. function setAttr (el, key, value) {
  49058. if (el.tagName.indexOf('-') > -1) {
  49059. baseSetAttr(el, key, value);
  49060. } else if (isBooleanAttr(key)) {
  49061. // set attribute for blank value
  49062. // e.g. <option disabled>Select one</option>
  49063. if (isFalsyAttrValue(value)) {
  49064. el.removeAttribute(key);
  49065. } else {
  49066. // technically allowfullscreen is a boolean attribute for <iframe>,
  49067. // but Flash expects a value of "true" when used on <embed> tag
  49068. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  49069. ? 'true'
  49070. : key;
  49071. el.setAttribute(key, value);
  49072. }
  49073. } else if (isEnumeratedAttr(key)) {
  49074. el.setAttribute(key, convertEnumeratedValue(key, value));
  49075. } else if (isXlink(key)) {
  49076. if (isFalsyAttrValue(value)) {
  49077. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  49078. } else {
  49079. el.setAttributeNS(xlinkNS, key, value);
  49080. }
  49081. } else {
  49082. baseSetAttr(el, key, value);
  49083. }
  49084. }
  49085. function baseSetAttr (el, key, value) {
  49086. if (isFalsyAttrValue(value)) {
  49087. el.removeAttribute(key);
  49088. } else {
  49089. // #7138: IE10 & 11 fires input event when setting placeholder on
  49090. // <textarea>... block the first input event and remove the blocker
  49091. // immediately.
  49092. /* istanbul ignore if */
  49093. if (
  49094. isIE && !isIE9 &&
  49095. el.tagName === 'TEXTAREA' &&
  49096. key === 'placeholder' && value !== '' && !el.__ieph
  49097. ) {
  49098. var blocker = function (e) {
  49099. e.stopImmediatePropagation();
  49100. el.removeEventListener('input', blocker);
  49101. };
  49102. el.addEventListener('input', blocker);
  49103. // $flow-disable-line
  49104. el.__ieph = true; /* IE placeholder patched */
  49105. }
  49106. el.setAttribute(key, value);
  49107. }
  49108. }
  49109. var attrs = {
  49110. create: updateAttrs,
  49111. update: updateAttrs
  49112. };
  49113. /* */
  49114. function updateClass (oldVnode, vnode) {
  49115. var el = vnode.elm;
  49116. var data = vnode.data;
  49117. var oldData = oldVnode.data;
  49118. if (
  49119. isUndef(data.staticClass) &&
  49120. isUndef(data.class) && (
  49121. isUndef(oldData) || (
  49122. isUndef(oldData.staticClass) &&
  49123. isUndef(oldData.class)
  49124. )
  49125. )
  49126. ) {
  49127. return
  49128. }
  49129. var cls = genClassForVnode(vnode);
  49130. // handle transition classes
  49131. var transitionClass = el._transitionClasses;
  49132. if (isDef(transitionClass)) {
  49133. cls = concat(cls, stringifyClass(transitionClass));
  49134. }
  49135. // set the class
  49136. if (cls !== el._prevClass) {
  49137. el.setAttribute('class', cls);
  49138. el._prevClass = cls;
  49139. }
  49140. }
  49141. var klass = {
  49142. create: updateClass,
  49143. update: updateClass
  49144. };
  49145. /* */
  49146. var validDivisionCharRE = /[\w).+\-_$\]]/;
  49147. function parseFilters (exp) {
  49148. var inSingle = false;
  49149. var inDouble = false;
  49150. var inTemplateString = false;
  49151. var inRegex = false;
  49152. var curly = 0;
  49153. var square = 0;
  49154. var paren = 0;
  49155. var lastFilterIndex = 0;
  49156. var c, prev, i, expression, filters;
  49157. for (i = 0; i < exp.length; i++) {
  49158. prev = c;
  49159. c = exp.charCodeAt(i);
  49160. if (inSingle) {
  49161. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  49162. } else if (inDouble) {
  49163. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  49164. } else if (inTemplateString) {
  49165. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  49166. } else if (inRegex) {
  49167. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  49168. } else if (
  49169. c === 0x7C && // pipe
  49170. exp.charCodeAt(i + 1) !== 0x7C &&
  49171. exp.charCodeAt(i - 1) !== 0x7C &&
  49172. !curly && !square && !paren
  49173. ) {
  49174. if (expression === undefined) {
  49175. // first filter, end of expression
  49176. lastFilterIndex = i + 1;
  49177. expression = exp.slice(0, i).trim();
  49178. } else {
  49179. pushFilter();
  49180. }
  49181. } else {
  49182. switch (c) {
  49183. case 0x22: inDouble = true; break // "
  49184. case 0x27: inSingle = true; break // '
  49185. case 0x60: inTemplateString = true; break // `
  49186. case 0x28: paren++; break // (
  49187. case 0x29: paren--; break // )
  49188. case 0x5B: square++; break // [
  49189. case 0x5D: square--; break // ]
  49190. case 0x7B: curly++; break // {
  49191. case 0x7D: curly--; break // }
  49192. }
  49193. if (c === 0x2f) { // /
  49194. var j = i - 1;
  49195. var p = (void 0);
  49196. // find first non-whitespace prev char
  49197. for (; j >= 0; j--) {
  49198. p = exp.charAt(j);
  49199. if (p !== ' ') { break }
  49200. }
  49201. if (!p || !validDivisionCharRE.test(p)) {
  49202. inRegex = true;
  49203. }
  49204. }
  49205. }
  49206. }
  49207. if (expression === undefined) {
  49208. expression = exp.slice(0, i).trim();
  49209. } else if (lastFilterIndex !== 0) {
  49210. pushFilter();
  49211. }
  49212. function pushFilter () {
  49213. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  49214. lastFilterIndex = i + 1;
  49215. }
  49216. if (filters) {
  49217. for (i = 0; i < filters.length; i++) {
  49218. expression = wrapFilter(expression, filters[i]);
  49219. }
  49220. }
  49221. return expression
  49222. }
  49223. function wrapFilter (exp, filter) {
  49224. var i = filter.indexOf('(');
  49225. if (i < 0) {
  49226. // _f: resolveFilter
  49227. return ("_f(\"" + filter + "\")(" + exp + ")")
  49228. } else {
  49229. var name = filter.slice(0, i);
  49230. var args = filter.slice(i + 1);
  49231. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  49232. }
  49233. }
  49234. /* */
  49235. /* eslint-disable no-unused-vars */
  49236. function baseWarn (msg, range) {
  49237. console.error(("[Vue compiler]: " + msg));
  49238. }
  49239. /* eslint-enable no-unused-vars */
  49240. function pluckModuleFunction (
  49241. modules,
  49242. key
  49243. ) {
  49244. return modules
  49245. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  49246. : []
  49247. }
  49248. function addProp (el, name, value, range, dynamic) {
  49249. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  49250. el.plain = false;
  49251. }
  49252. function addAttr (el, name, value, range, dynamic) {
  49253. var attrs = dynamic
  49254. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  49255. : (el.attrs || (el.attrs = []));
  49256. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  49257. el.plain = false;
  49258. }
  49259. // add a raw attr (use this in preTransforms)
  49260. function addRawAttr (el, name, value, range) {
  49261. el.attrsMap[name] = value;
  49262. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  49263. }
  49264. function addDirective (
  49265. el,
  49266. name,
  49267. rawName,
  49268. value,
  49269. arg,
  49270. isDynamicArg,
  49271. modifiers,
  49272. range
  49273. ) {
  49274. (el.directives || (el.directives = [])).push(rangeSetItem({
  49275. name: name,
  49276. rawName: rawName,
  49277. value: value,
  49278. arg: arg,
  49279. isDynamicArg: isDynamicArg,
  49280. modifiers: modifiers
  49281. }, range));
  49282. el.plain = false;
  49283. }
  49284. function prependModifierMarker (symbol, name, dynamic) {
  49285. return dynamic
  49286. ? ("_p(" + name + ",\"" + symbol + "\")")
  49287. : symbol + name // mark the event as captured
  49288. }
  49289. function addHandler (
  49290. el,
  49291. name,
  49292. value,
  49293. modifiers,
  49294. important,
  49295. warn,
  49296. range,
  49297. dynamic
  49298. ) {
  49299. modifiers = modifiers || emptyObject;
  49300. // warn prevent and passive modifier
  49301. /* istanbul ignore if */
  49302. if (
  49303. warn &&
  49304. modifiers.prevent && modifiers.passive
  49305. ) {
  49306. warn(
  49307. 'passive and prevent can\'t be used together. ' +
  49308. 'Passive handler can\'t prevent default event.',
  49309. range
  49310. );
  49311. }
  49312. // normalize click.right and click.middle since they don't actually fire
  49313. // this is technically browser-specific, but at least for now browsers are
  49314. // the only target envs that have right/middle clicks.
  49315. if (modifiers.right) {
  49316. if (dynamic) {
  49317. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  49318. } else if (name === 'click') {
  49319. name = 'contextmenu';
  49320. delete modifiers.right;
  49321. }
  49322. } else if (modifiers.middle) {
  49323. if (dynamic) {
  49324. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  49325. } else if (name === 'click') {
  49326. name = 'mouseup';
  49327. }
  49328. }
  49329. // check capture modifier
  49330. if (modifiers.capture) {
  49331. delete modifiers.capture;
  49332. name = prependModifierMarker('!', name, dynamic);
  49333. }
  49334. if (modifiers.once) {
  49335. delete modifiers.once;
  49336. name = prependModifierMarker('~', name, dynamic);
  49337. }
  49338. /* istanbul ignore if */
  49339. if (modifiers.passive) {
  49340. delete modifiers.passive;
  49341. name = prependModifierMarker('&', name, dynamic);
  49342. }
  49343. var events;
  49344. if (modifiers.native) {
  49345. delete modifiers.native;
  49346. events = el.nativeEvents || (el.nativeEvents = {});
  49347. } else {
  49348. events = el.events || (el.events = {});
  49349. }
  49350. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  49351. if (modifiers !== emptyObject) {
  49352. newHandler.modifiers = modifiers;
  49353. }
  49354. var handlers = events[name];
  49355. /* istanbul ignore if */
  49356. if (Array.isArray(handlers)) {
  49357. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  49358. } else if (handlers) {
  49359. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  49360. } else {
  49361. events[name] = newHandler;
  49362. }
  49363. el.plain = false;
  49364. }
  49365. function getRawBindingAttr (
  49366. el,
  49367. name
  49368. ) {
  49369. return el.rawAttrsMap[':' + name] ||
  49370. el.rawAttrsMap['v-bind:' + name] ||
  49371. el.rawAttrsMap[name]
  49372. }
  49373. function getBindingAttr (
  49374. el,
  49375. name,
  49376. getStatic
  49377. ) {
  49378. var dynamicValue =
  49379. getAndRemoveAttr(el, ':' + name) ||
  49380. getAndRemoveAttr(el, 'v-bind:' + name);
  49381. if (dynamicValue != null) {
  49382. return parseFilters(dynamicValue)
  49383. } else if (getStatic !== false) {
  49384. var staticValue = getAndRemoveAttr(el, name);
  49385. if (staticValue != null) {
  49386. return JSON.stringify(staticValue)
  49387. }
  49388. }
  49389. }
  49390. // note: this only removes the attr from the Array (attrsList) so that it
  49391. // doesn't get processed by processAttrs.
  49392. // By default it does NOT remove it from the map (attrsMap) because the map is
  49393. // needed during codegen.
  49394. function getAndRemoveAttr (
  49395. el,
  49396. name,
  49397. removeFromMap
  49398. ) {
  49399. var val;
  49400. if ((val = el.attrsMap[name]) != null) {
  49401. var list = el.attrsList;
  49402. for (var i = 0, l = list.length; i < l; i++) {
  49403. if (list[i].name === name) {
  49404. list.splice(i, 1);
  49405. break
  49406. }
  49407. }
  49408. }
  49409. if (removeFromMap) {
  49410. delete el.attrsMap[name];
  49411. }
  49412. return val
  49413. }
  49414. function getAndRemoveAttrByRegex (
  49415. el,
  49416. name
  49417. ) {
  49418. var list = el.attrsList;
  49419. for (var i = 0, l = list.length; i < l; i++) {
  49420. var attr = list[i];
  49421. if (name.test(attr.name)) {
  49422. list.splice(i, 1);
  49423. return attr
  49424. }
  49425. }
  49426. }
  49427. function rangeSetItem (
  49428. item,
  49429. range
  49430. ) {
  49431. if (range) {
  49432. if (range.start != null) {
  49433. item.start = range.start;
  49434. }
  49435. if (range.end != null) {
  49436. item.end = range.end;
  49437. }
  49438. }
  49439. return item
  49440. }
  49441. /* */
  49442. /**
  49443. * Cross-platform code generation for component v-model
  49444. */
  49445. function genComponentModel (
  49446. el,
  49447. value,
  49448. modifiers
  49449. ) {
  49450. var ref = modifiers || {};
  49451. var number = ref.number;
  49452. var trim = ref.trim;
  49453. var baseValueExpression = '$$v';
  49454. var valueExpression = baseValueExpression;
  49455. if (trim) {
  49456. valueExpression =
  49457. "(typeof " + baseValueExpression + " === 'string'" +
  49458. "? " + baseValueExpression + ".trim()" +
  49459. ": " + baseValueExpression + ")";
  49460. }
  49461. if (number) {
  49462. valueExpression = "_n(" + valueExpression + ")";
  49463. }
  49464. var assignment = genAssignmentCode(value, valueExpression);
  49465. el.model = {
  49466. value: ("(" + value + ")"),
  49467. expression: JSON.stringify(value),
  49468. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  49469. };
  49470. }
  49471. /**
  49472. * Cross-platform codegen helper for generating v-model value assignment code.
  49473. */
  49474. function genAssignmentCode (
  49475. value,
  49476. assignment
  49477. ) {
  49478. var res = parseModel(value);
  49479. if (res.key === null) {
  49480. return (value + "=" + assignment)
  49481. } else {
  49482. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  49483. }
  49484. }
  49485. /**
  49486. * Parse a v-model expression into a base path and a final key segment.
  49487. * Handles both dot-path and possible square brackets.
  49488. *
  49489. * Possible cases:
  49490. *
  49491. * - test
  49492. * - test[key]
  49493. * - test[test1[key]]
  49494. * - test["a"][key]
  49495. * - xxx.test[a[a].test1[key]]
  49496. * - test.xxx.a["asa"][test1[key]]
  49497. *
  49498. */
  49499. var len, str, chr, index$1, expressionPos, expressionEndPos;
  49500. function parseModel (val) {
  49501. // Fix https://github.com/vuejs/vue/pull/7730
  49502. // allow v-model="obj.val " (trailing whitespace)
  49503. val = val.trim();
  49504. len = val.length;
  49505. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  49506. index$1 = val.lastIndexOf('.');
  49507. if (index$1 > -1) {
  49508. return {
  49509. exp: val.slice(0, index$1),
  49510. key: '"' + val.slice(index$1 + 1) + '"'
  49511. }
  49512. } else {
  49513. return {
  49514. exp: val,
  49515. key: null
  49516. }
  49517. }
  49518. }
  49519. str = val;
  49520. index$1 = expressionPos = expressionEndPos = 0;
  49521. while (!eof()) {
  49522. chr = next();
  49523. /* istanbul ignore if */
  49524. if (isStringStart(chr)) {
  49525. parseString(chr);
  49526. } else if (chr === 0x5B) {
  49527. parseBracket(chr);
  49528. }
  49529. }
  49530. return {
  49531. exp: val.slice(0, expressionPos),
  49532. key: val.slice(expressionPos + 1, expressionEndPos)
  49533. }
  49534. }
  49535. function next () {
  49536. return str.charCodeAt(++index$1)
  49537. }
  49538. function eof () {
  49539. return index$1 >= len
  49540. }
  49541. function isStringStart (chr) {
  49542. return chr === 0x22 || chr === 0x27
  49543. }
  49544. function parseBracket (chr) {
  49545. var inBracket = 1;
  49546. expressionPos = index$1;
  49547. while (!eof()) {
  49548. chr = next();
  49549. if (isStringStart(chr)) {
  49550. parseString(chr);
  49551. continue
  49552. }
  49553. if (chr === 0x5B) { inBracket++; }
  49554. if (chr === 0x5D) { inBracket--; }
  49555. if (inBracket === 0) {
  49556. expressionEndPos = index$1;
  49557. break
  49558. }
  49559. }
  49560. }
  49561. function parseString (chr) {
  49562. var stringQuote = chr;
  49563. while (!eof()) {
  49564. chr = next();
  49565. if (chr === stringQuote) {
  49566. break
  49567. }
  49568. }
  49569. }
  49570. /* */
  49571. var warn$1;
  49572. // in some cases, the event used has to be determined at runtime
  49573. // so we used some reserved tokens during compile.
  49574. var RANGE_TOKEN = '__r';
  49575. var CHECKBOX_RADIO_TOKEN = '__c';
  49576. function model (
  49577. el,
  49578. dir,
  49579. _warn
  49580. ) {
  49581. warn$1 = _warn;
  49582. var value = dir.value;
  49583. var modifiers = dir.modifiers;
  49584. var tag = el.tag;
  49585. var type = el.attrsMap.type;
  49586. {
  49587. // inputs with type="file" are read only and setting the input's
  49588. // value will throw an error.
  49589. if (tag === 'input' && type === 'file') {
  49590. warn$1(
  49591. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  49592. "File inputs are read only. Use a v-on:change listener instead.",
  49593. el.rawAttrsMap['v-model']
  49594. );
  49595. }
  49596. }
  49597. if (el.component) {
  49598. genComponentModel(el, value, modifiers);
  49599. // component v-model doesn't need extra runtime
  49600. return false
  49601. } else if (tag === 'select') {
  49602. genSelect(el, value, modifiers);
  49603. } else if (tag === 'input' && type === 'checkbox') {
  49604. genCheckboxModel(el, value, modifiers);
  49605. } else if (tag === 'input' && type === 'radio') {
  49606. genRadioModel(el, value, modifiers);
  49607. } else if (tag === 'input' || tag === 'textarea') {
  49608. genDefaultModel(el, value, modifiers);
  49609. } else if (!config.isReservedTag(tag)) {
  49610. genComponentModel(el, value, modifiers);
  49611. // component v-model doesn't need extra runtime
  49612. return false
  49613. } else {
  49614. warn$1(
  49615. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  49616. "v-model is not supported on this element type. " +
  49617. 'If you are working with contenteditable, it\'s recommended to ' +
  49618. 'wrap a library dedicated for that purpose inside a custom component.',
  49619. el.rawAttrsMap['v-model']
  49620. );
  49621. }
  49622. // ensure runtime directive metadata
  49623. return true
  49624. }
  49625. function genCheckboxModel (
  49626. el,
  49627. value,
  49628. modifiers
  49629. ) {
  49630. var number = modifiers && modifiers.number;
  49631. var valueBinding = getBindingAttr(el, 'value') || 'null';
  49632. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  49633. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  49634. addProp(el, 'checked',
  49635. "Array.isArray(" + value + ")" +
  49636. "?_i(" + value + "," + valueBinding + ")>-1" + (
  49637. trueValueBinding === 'true'
  49638. ? (":(" + value + ")")
  49639. : (":_q(" + value + "," + trueValueBinding + ")")
  49640. )
  49641. );
  49642. addHandler(el, 'change',
  49643. "var $$a=" + value + "," +
  49644. '$$el=$event.target,' +
  49645. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  49646. 'if(Array.isArray($$a)){' +
  49647. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  49648. '$$i=_i($$a,$$v);' +
  49649. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  49650. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  49651. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  49652. null, true
  49653. );
  49654. }
  49655. function genRadioModel (
  49656. el,
  49657. value,
  49658. modifiers
  49659. ) {
  49660. var number = modifiers && modifiers.number;
  49661. var valueBinding = getBindingAttr(el, 'value') || 'null';
  49662. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  49663. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  49664. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  49665. }
  49666. function genSelect (
  49667. el,
  49668. value,
  49669. modifiers
  49670. ) {
  49671. var number = modifiers && modifiers.number;
  49672. var selectedVal = "Array.prototype.filter" +
  49673. ".call($event.target.options,function(o){return o.selected})" +
  49674. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  49675. "return " + (number ? '_n(val)' : 'val') + "})";
  49676. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  49677. var code = "var $$selectedVal = " + selectedVal + ";";
  49678. code = code + " " + (genAssignmentCode(value, assignment));
  49679. addHandler(el, 'change', code, null, true);
  49680. }
  49681. function genDefaultModel (
  49682. el,
  49683. value,
  49684. modifiers
  49685. ) {
  49686. var type = el.attrsMap.type;
  49687. // warn if v-bind:value conflicts with v-model
  49688. // except for inputs with v-bind:type
  49689. {
  49690. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  49691. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  49692. if (value$1 && !typeBinding) {
  49693. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  49694. warn$1(
  49695. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  49696. 'because the latter already expands to a value binding internally',
  49697. el.rawAttrsMap[binding]
  49698. );
  49699. }
  49700. }
  49701. var ref = modifiers || {};
  49702. var lazy = ref.lazy;
  49703. var number = ref.number;
  49704. var trim = ref.trim;
  49705. var needCompositionGuard = !lazy && type !== 'range';
  49706. var event = lazy
  49707. ? 'change'
  49708. : type === 'range'
  49709. ? RANGE_TOKEN
  49710. : 'input';
  49711. var valueExpression = '$event.target.value';
  49712. if (trim) {
  49713. valueExpression = "$event.target.value.trim()";
  49714. }
  49715. if (number) {
  49716. valueExpression = "_n(" + valueExpression + ")";
  49717. }
  49718. var code = genAssignmentCode(value, valueExpression);
  49719. if (needCompositionGuard) {
  49720. code = "if($event.target.composing)return;" + code;
  49721. }
  49722. addProp(el, 'value', ("(" + value + ")"));
  49723. addHandler(el, event, code, null, true);
  49724. if (trim || number) {
  49725. addHandler(el, 'blur', '$forceUpdate()');
  49726. }
  49727. }
  49728. /* */
  49729. // normalize v-model event tokens that can only be determined at runtime.
  49730. // it's important to place the event as the first in the array because
  49731. // the whole point is ensuring the v-model callback gets called before
  49732. // user-attached handlers.
  49733. function normalizeEvents (on) {
  49734. /* istanbul ignore if */
  49735. if (isDef(on[RANGE_TOKEN])) {
  49736. // IE input[type=range] only supports `change` event
  49737. var event = isIE ? 'change' : 'input';
  49738. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  49739. delete on[RANGE_TOKEN];
  49740. }
  49741. // This was originally intended to fix #4521 but no longer necessary
  49742. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  49743. /* istanbul ignore if */
  49744. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  49745. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  49746. delete on[CHECKBOX_RADIO_TOKEN];
  49747. }
  49748. }
  49749. var target$1;
  49750. function createOnceHandler$1 (event, handler, capture) {
  49751. var _target = target$1; // save current target element in closure
  49752. return function onceHandler () {
  49753. var res = handler.apply(null, arguments);
  49754. if (res !== null) {
  49755. remove$2(event, onceHandler, capture, _target);
  49756. }
  49757. }
  49758. }
  49759. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  49760. // implementation and does not fire microtasks in between event propagation, so
  49761. // safe to exclude.
  49762. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  49763. function add$1 (
  49764. name,
  49765. handler,
  49766. capture,
  49767. passive
  49768. ) {
  49769. // async edge case #6566: inner click event triggers patch, event handler
  49770. // attached to outer element during patch, and triggered again. This
  49771. // happens because browsers fire microtask ticks between event propagation.
  49772. // the solution is simple: we save the timestamp when a handler is attached,
  49773. // and the handler would only fire if the event passed to it was fired
  49774. // AFTER it was attached.
  49775. if (useMicrotaskFix) {
  49776. var attachedTimestamp = currentFlushTimestamp;
  49777. var original = handler;
  49778. handler = original._wrapper = function (e) {
  49779. if (
  49780. // no bubbling, should always fire.
  49781. // this is just a safety net in case event.timeStamp is unreliable in
  49782. // certain weird environments...
  49783. e.target === e.currentTarget ||
  49784. // event is fired after handler attachment
  49785. e.timeStamp >= attachedTimestamp ||
  49786. // bail for environments that have buggy event.timeStamp implementations
  49787. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  49788. // #9681 QtWebEngine event.timeStamp is negative value
  49789. e.timeStamp <= 0 ||
  49790. // #9448 bail if event is fired in another document in a multi-page
  49791. // electron/nw.js app, since event.timeStamp will be using a different
  49792. // starting reference
  49793. e.target.ownerDocument !== document
  49794. ) {
  49795. return original.apply(this, arguments)
  49796. }
  49797. };
  49798. }
  49799. target$1.addEventListener(
  49800. name,
  49801. handler,
  49802. supportsPassive
  49803. ? { capture: capture, passive: passive }
  49804. : capture
  49805. );
  49806. }
  49807. function remove$2 (
  49808. name,
  49809. handler,
  49810. capture,
  49811. _target
  49812. ) {
  49813. (_target || target$1).removeEventListener(
  49814. name,
  49815. handler._wrapper || handler,
  49816. capture
  49817. );
  49818. }
  49819. function updateDOMListeners (oldVnode, vnode) {
  49820. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  49821. return
  49822. }
  49823. var on = vnode.data.on || {};
  49824. var oldOn = oldVnode.data.on || {};
  49825. target$1 = vnode.elm;
  49826. normalizeEvents(on);
  49827. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  49828. target$1 = undefined;
  49829. }
  49830. var events = {
  49831. create: updateDOMListeners,
  49832. update: updateDOMListeners
  49833. };
  49834. /* */
  49835. var svgContainer;
  49836. function updateDOMProps (oldVnode, vnode) {
  49837. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  49838. return
  49839. }
  49840. var key, cur;
  49841. var elm = vnode.elm;
  49842. var oldProps = oldVnode.data.domProps || {};
  49843. var props = vnode.data.domProps || {};
  49844. // clone observed objects, as the user probably wants to mutate it
  49845. if (isDef(props.__ob__)) {
  49846. props = vnode.data.domProps = extend({}, props);
  49847. }
  49848. for (key in oldProps) {
  49849. if (!(key in props)) {
  49850. elm[key] = '';
  49851. }
  49852. }
  49853. for (key in props) {
  49854. cur = props[key];
  49855. // ignore children if the node has textContent or innerHTML,
  49856. // as these will throw away existing DOM nodes and cause removal errors
  49857. // on subsequent patches (#3360)
  49858. if (key === 'textContent' || key === 'innerHTML') {
  49859. if (vnode.children) { vnode.children.length = 0; }
  49860. if (cur === oldProps[key]) { continue }
  49861. // #6601 work around Chrome version <= 55 bug where single textNode
  49862. // replaced by innerHTML/textContent retains its parentNode property
  49863. if (elm.childNodes.length === 1) {
  49864. elm.removeChild(elm.childNodes[0]);
  49865. }
  49866. }
  49867. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  49868. // store value as _value as well since
  49869. // non-string values will be stringified
  49870. elm._value = cur;
  49871. // avoid resetting cursor position when value is the same
  49872. var strCur = isUndef(cur) ? '' : String(cur);
  49873. if (shouldUpdateValue(elm, strCur)) {
  49874. elm.value = strCur;
  49875. }
  49876. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  49877. // IE doesn't support innerHTML for SVG elements
  49878. svgContainer = svgContainer || document.createElement('div');
  49879. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  49880. var svg = svgContainer.firstChild;
  49881. while (elm.firstChild) {
  49882. elm.removeChild(elm.firstChild);
  49883. }
  49884. while (svg.firstChild) {
  49885. elm.appendChild(svg.firstChild);
  49886. }
  49887. } else if (
  49888. // skip the update if old and new VDOM state is the same.
  49889. // `value` is handled separately because the DOM value may be temporarily
  49890. // out of sync with VDOM state due to focus, composition and modifiers.
  49891. // This #4521 by skipping the unnecesarry `checked` update.
  49892. cur !== oldProps[key]
  49893. ) {
  49894. // some property updates can throw
  49895. // e.g. `value` on <progress> w/ non-finite value
  49896. try {
  49897. elm[key] = cur;
  49898. } catch (e) {}
  49899. }
  49900. }
  49901. }
  49902. // check platforms/web/util/attrs.js acceptValue
  49903. function shouldUpdateValue (elm, checkVal) {
  49904. return (!elm.composing && (
  49905. elm.tagName === 'OPTION' ||
  49906. isNotInFocusAndDirty(elm, checkVal) ||
  49907. isDirtyWithModifiers(elm, checkVal)
  49908. ))
  49909. }
  49910. function isNotInFocusAndDirty (elm, checkVal) {
  49911. // return true when textbox (.number and .trim) loses focus and its value is
  49912. // not equal to the updated value
  49913. var notInFocus = true;
  49914. // #6157
  49915. // work around IE bug when accessing document.activeElement in an iframe
  49916. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  49917. return notInFocus && elm.value !== checkVal
  49918. }
  49919. function isDirtyWithModifiers (elm, newVal) {
  49920. var value = elm.value;
  49921. var modifiers = elm._vModifiers; // injected by v-model runtime
  49922. if (isDef(modifiers)) {
  49923. if (modifiers.number) {
  49924. return toNumber(value) !== toNumber(newVal)
  49925. }
  49926. if (modifiers.trim) {
  49927. return value.trim() !== newVal.trim()
  49928. }
  49929. }
  49930. return value !== newVal
  49931. }
  49932. var domProps = {
  49933. create: updateDOMProps,
  49934. update: updateDOMProps
  49935. };
  49936. /* */
  49937. var parseStyleText = cached(function (cssText) {
  49938. var res = {};
  49939. var listDelimiter = /;(?![^(]*\))/g;
  49940. var propertyDelimiter = /:(.+)/;
  49941. cssText.split(listDelimiter).forEach(function (item) {
  49942. if (item) {
  49943. var tmp = item.split(propertyDelimiter);
  49944. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  49945. }
  49946. });
  49947. return res
  49948. });
  49949. // merge static and dynamic style data on the same vnode
  49950. function normalizeStyleData (data) {
  49951. var style = normalizeStyleBinding(data.style);
  49952. // static style is pre-processed into an object during compilation
  49953. // and is always a fresh object, so it's safe to merge into it
  49954. return data.staticStyle
  49955. ? extend(data.staticStyle, style)
  49956. : style
  49957. }
  49958. // normalize possible array / string values into Object
  49959. function normalizeStyleBinding (bindingStyle) {
  49960. if (Array.isArray(bindingStyle)) {
  49961. return toObject(bindingStyle)
  49962. }
  49963. if (typeof bindingStyle === 'string') {
  49964. return parseStyleText(bindingStyle)
  49965. }
  49966. return bindingStyle
  49967. }
  49968. /**
  49969. * parent component style should be after child's
  49970. * so that parent component's style could override it
  49971. */
  49972. function getStyle (vnode, checkChild) {
  49973. var res = {};
  49974. var styleData;
  49975. if (checkChild) {
  49976. var childNode = vnode;
  49977. while (childNode.componentInstance) {
  49978. childNode = childNode.componentInstance._vnode;
  49979. if (
  49980. childNode && childNode.data &&
  49981. (styleData = normalizeStyleData(childNode.data))
  49982. ) {
  49983. extend(res, styleData);
  49984. }
  49985. }
  49986. }
  49987. if ((styleData = normalizeStyleData(vnode.data))) {
  49988. extend(res, styleData);
  49989. }
  49990. var parentNode = vnode;
  49991. while ((parentNode = parentNode.parent)) {
  49992. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  49993. extend(res, styleData);
  49994. }
  49995. }
  49996. return res
  49997. }
  49998. /* */
  49999. var cssVarRE = /^--/;
  50000. var importantRE = /\s*!important$/;
  50001. var setProp = function (el, name, val) {
  50002. /* istanbul ignore if */
  50003. if (cssVarRE.test(name)) {
  50004. el.style.setProperty(name, val);
  50005. } else if (importantRE.test(val)) {
  50006. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  50007. } else {
  50008. var normalizedName = normalize(name);
  50009. if (Array.isArray(val)) {
  50010. // Support values array created by autoprefixer, e.g.
  50011. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  50012. // Set them one by one, and the browser will only set those it can recognize
  50013. for (var i = 0, len = val.length; i < len; i++) {
  50014. el.style[normalizedName] = val[i];
  50015. }
  50016. } else {
  50017. el.style[normalizedName] = val;
  50018. }
  50019. }
  50020. };
  50021. var vendorNames = ['Webkit', 'Moz', 'ms'];
  50022. var emptyStyle;
  50023. var normalize = cached(function (prop) {
  50024. emptyStyle = emptyStyle || document.createElement('div').style;
  50025. prop = camelize(prop);
  50026. if (prop !== 'filter' && (prop in emptyStyle)) {
  50027. return prop
  50028. }
  50029. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  50030. for (var i = 0; i < vendorNames.length; i++) {
  50031. var name = vendorNames[i] + capName;
  50032. if (name in emptyStyle) {
  50033. return name
  50034. }
  50035. }
  50036. });
  50037. function updateStyle (oldVnode, vnode) {
  50038. var data = vnode.data;
  50039. var oldData = oldVnode.data;
  50040. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  50041. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  50042. ) {
  50043. return
  50044. }
  50045. var cur, name;
  50046. var el = vnode.elm;
  50047. var oldStaticStyle = oldData.staticStyle;
  50048. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  50049. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  50050. var oldStyle = oldStaticStyle || oldStyleBinding;
  50051. var style = normalizeStyleBinding(vnode.data.style) || {};
  50052. // store normalized style under a different key for next diff
  50053. // make sure to clone it if it's reactive, since the user likely wants
  50054. // to mutate it.
  50055. vnode.data.normalizedStyle = isDef(style.__ob__)
  50056. ? extend({}, style)
  50057. : style;
  50058. var newStyle = getStyle(vnode, true);
  50059. for (name in oldStyle) {
  50060. if (isUndef(newStyle[name])) {
  50061. setProp(el, name, '');
  50062. }
  50063. }
  50064. for (name in newStyle) {
  50065. cur = newStyle[name];
  50066. if (cur !== oldStyle[name]) {
  50067. // ie9 setting to null has no effect, must use empty string
  50068. setProp(el, name, cur == null ? '' : cur);
  50069. }
  50070. }
  50071. }
  50072. var style = {
  50073. create: updateStyle,
  50074. update: updateStyle
  50075. };
  50076. /* */
  50077. var whitespaceRE = /\s+/;
  50078. /**
  50079. * Add class with compatibility for SVG since classList is not supported on
  50080. * SVG elements in IE
  50081. */
  50082. function addClass (el, cls) {
  50083. /* istanbul ignore if */
  50084. if (!cls || !(cls = cls.trim())) {
  50085. return
  50086. }
  50087. /* istanbul ignore else */
  50088. if (el.classList) {
  50089. if (cls.indexOf(' ') > -1) {
  50090. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  50091. } else {
  50092. el.classList.add(cls);
  50093. }
  50094. } else {
  50095. var cur = " " + (el.getAttribute('class') || '') + " ";
  50096. if (cur.indexOf(' ' + cls + ' ') < 0) {
  50097. el.setAttribute('class', (cur + cls).trim());
  50098. }
  50099. }
  50100. }
  50101. /**
  50102. * Remove class with compatibility for SVG since classList is not supported on
  50103. * SVG elements in IE
  50104. */
  50105. function removeClass (el, cls) {
  50106. /* istanbul ignore if */
  50107. if (!cls || !(cls = cls.trim())) {
  50108. return
  50109. }
  50110. /* istanbul ignore else */
  50111. if (el.classList) {
  50112. if (cls.indexOf(' ') > -1) {
  50113. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  50114. } else {
  50115. el.classList.remove(cls);
  50116. }
  50117. if (!el.classList.length) {
  50118. el.removeAttribute('class');
  50119. }
  50120. } else {
  50121. var cur = " " + (el.getAttribute('class') || '') + " ";
  50122. var tar = ' ' + cls + ' ';
  50123. while (cur.indexOf(tar) >= 0) {
  50124. cur = cur.replace(tar, ' ');
  50125. }
  50126. cur = cur.trim();
  50127. if (cur) {
  50128. el.setAttribute('class', cur);
  50129. } else {
  50130. el.removeAttribute('class');
  50131. }
  50132. }
  50133. }
  50134. /* */
  50135. function resolveTransition (def$$1) {
  50136. if (!def$$1) {
  50137. return
  50138. }
  50139. /* istanbul ignore else */
  50140. if (typeof def$$1 === 'object') {
  50141. var res = {};
  50142. if (def$$1.css !== false) {
  50143. extend(res, autoCssTransition(def$$1.name || 'v'));
  50144. }
  50145. extend(res, def$$1);
  50146. return res
  50147. } else if (typeof def$$1 === 'string') {
  50148. return autoCssTransition(def$$1)
  50149. }
  50150. }
  50151. var autoCssTransition = cached(function (name) {
  50152. return {
  50153. enterClass: (name + "-enter"),
  50154. enterToClass: (name + "-enter-to"),
  50155. enterActiveClass: (name + "-enter-active"),
  50156. leaveClass: (name + "-leave"),
  50157. leaveToClass: (name + "-leave-to"),
  50158. leaveActiveClass: (name + "-leave-active")
  50159. }
  50160. });
  50161. var hasTransition = inBrowser && !isIE9;
  50162. var TRANSITION = 'transition';
  50163. var ANIMATION = 'animation';
  50164. // Transition property/event sniffing
  50165. var transitionProp = 'transition';
  50166. var transitionEndEvent = 'transitionend';
  50167. var animationProp = 'animation';
  50168. var animationEndEvent = 'animationend';
  50169. if (hasTransition) {
  50170. /* istanbul ignore if */
  50171. if (window.ontransitionend === undefined &&
  50172. window.onwebkittransitionend !== undefined
  50173. ) {
  50174. transitionProp = 'WebkitTransition';
  50175. transitionEndEvent = 'webkitTransitionEnd';
  50176. }
  50177. if (window.onanimationend === undefined &&
  50178. window.onwebkitanimationend !== undefined
  50179. ) {
  50180. animationProp = 'WebkitAnimation';
  50181. animationEndEvent = 'webkitAnimationEnd';
  50182. }
  50183. }
  50184. // binding to window is necessary to make hot reload work in IE in strict mode
  50185. var raf = inBrowser
  50186. ? window.requestAnimationFrame
  50187. ? window.requestAnimationFrame.bind(window)
  50188. : setTimeout
  50189. : /* istanbul ignore next */ function (fn) { return fn(); };
  50190. function nextFrame (fn) {
  50191. raf(function () {
  50192. raf(fn);
  50193. });
  50194. }
  50195. function addTransitionClass (el, cls) {
  50196. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  50197. if (transitionClasses.indexOf(cls) < 0) {
  50198. transitionClasses.push(cls);
  50199. addClass(el, cls);
  50200. }
  50201. }
  50202. function removeTransitionClass (el, cls) {
  50203. if (el._transitionClasses) {
  50204. remove(el._transitionClasses, cls);
  50205. }
  50206. removeClass(el, cls);
  50207. }
  50208. function whenTransitionEnds (
  50209. el,
  50210. expectedType,
  50211. cb
  50212. ) {
  50213. var ref = getTransitionInfo(el, expectedType);
  50214. var type = ref.type;
  50215. var timeout = ref.timeout;
  50216. var propCount = ref.propCount;
  50217. if (!type) { return cb() }
  50218. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  50219. var ended = 0;
  50220. var end = function () {
  50221. el.removeEventListener(event, onEnd);
  50222. cb();
  50223. };
  50224. var onEnd = function (e) {
  50225. if (e.target === el) {
  50226. if (++ended >= propCount) {
  50227. end();
  50228. }
  50229. }
  50230. };
  50231. setTimeout(function () {
  50232. if (ended < propCount) {
  50233. end();
  50234. }
  50235. }, timeout + 1);
  50236. el.addEventListener(event, onEnd);
  50237. }
  50238. var transformRE = /\b(transform|all)(,|$)/;
  50239. function getTransitionInfo (el, expectedType) {
  50240. var styles = window.getComputedStyle(el);
  50241. // JSDOM may return undefined for transition properties
  50242. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  50243. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  50244. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  50245. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  50246. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  50247. var animationTimeout = getTimeout(animationDelays, animationDurations);
  50248. var type;
  50249. var timeout = 0;
  50250. var propCount = 0;
  50251. /* istanbul ignore if */
  50252. if (expectedType === TRANSITION) {
  50253. if (transitionTimeout > 0) {
  50254. type = TRANSITION;
  50255. timeout = transitionTimeout;
  50256. propCount = transitionDurations.length;
  50257. }
  50258. } else if (expectedType === ANIMATION) {
  50259. if (animationTimeout > 0) {
  50260. type = ANIMATION;
  50261. timeout = animationTimeout;
  50262. propCount = animationDurations.length;
  50263. }
  50264. } else {
  50265. timeout = Math.max(transitionTimeout, animationTimeout);
  50266. type = timeout > 0
  50267. ? transitionTimeout > animationTimeout
  50268. ? TRANSITION
  50269. : ANIMATION
  50270. : null;
  50271. propCount = type
  50272. ? type === TRANSITION
  50273. ? transitionDurations.length
  50274. : animationDurations.length
  50275. : 0;
  50276. }
  50277. var hasTransform =
  50278. type === TRANSITION &&
  50279. transformRE.test(styles[transitionProp + 'Property']);
  50280. return {
  50281. type: type,
  50282. timeout: timeout,
  50283. propCount: propCount,
  50284. hasTransform: hasTransform
  50285. }
  50286. }
  50287. function getTimeout (delays, durations) {
  50288. /* istanbul ignore next */
  50289. while (delays.length < durations.length) {
  50290. delays = delays.concat(delays);
  50291. }
  50292. return Math.max.apply(null, durations.map(function (d, i) {
  50293. return toMs(d) + toMs(delays[i])
  50294. }))
  50295. }
  50296. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  50297. // in a locale-dependent way, using a comma instead of a dot.
  50298. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  50299. // as a floor function) causing unexpected behaviors
  50300. function toMs (s) {
  50301. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  50302. }
  50303. /* */
  50304. function enter (vnode, toggleDisplay) {
  50305. var el = vnode.elm;
  50306. // call leave callback now
  50307. if (isDef(el._leaveCb)) {
  50308. el._leaveCb.cancelled = true;
  50309. el._leaveCb();
  50310. }
  50311. var data = resolveTransition(vnode.data.transition);
  50312. if (isUndef(data)) {
  50313. return
  50314. }
  50315. /* istanbul ignore if */
  50316. if (isDef(el._enterCb) || el.nodeType !== 1) {
  50317. return
  50318. }
  50319. var css = data.css;
  50320. var type = data.type;
  50321. var enterClass = data.enterClass;
  50322. var enterToClass = data.enterToClass;
  50323. var enterActiveClass = data.enterActiveClass;
  50324. var appearClass = data.appearClass;
  50325. var appearToClass = data.appearToClass;
  50326. var appearActiveClass = data.appearActiveClass;
  50327. var beforeEnter = data.beforeEnter;
  50328. var enter = data.enter;
  50329. var afterEnter = data.afterEnter;
  50330. var enterCancelled = data.enterCancelled;
  50331. var beforeAppear = data.beforeAppear;
  50332. var appear = data.appear;
  50333. var afterAppear = data.afterAppear;
  50334. var appearCancelled = data.appearCancelled;
  50335. var duration = data.duration;
  50336. // activeInstance will always be the <transition> component managing this
  50337. // transition. One edge case to check is when the <transition> is placed
  50338. // as the root node of a child component. In that case we need to check
  50339. // <transition>'s parent for appear check.
  50340. var context = activeInstance;
  50341. var transitionNode = activeInstance.$vnode;
  50342. while (transitionNode && transitionNode.parent) {
  50343. context = transitionNode.context;
  50344. transitionNode = transitionNode.parent;
  50345. }
  50346. var isAppear = !context._isMounted || !vnode.isRootInsert;
  50347. if (isAppear && !appear && appear !== '') {
  50348. return
  50349. }
  50350. var startClass = isAppear && appearClass
  50351. ? appearClass
  50352. : enterClass;
  50353. var activeClass = isAppear && appearActiveClass
  50354. ? appearActiveClass
  50355. : enterActiveClass;
  50356. var toClass = isAppear && appearToClass
  50357. ? appearToClass
  50358. : enterToClass;
  50359. var beforeEnterHook = isAppear
  50360. ? (beforeAppear || beforeEnter)
  50361. : beforeEnter;
  50362. var enterHook = isAppear
  50363. ? (typeof appear === 'function' ? appear : enter)
  50364. : enter;
  50365. var afterEnterHook = isAppear
  50366. ? (afterAppear || afterEnter)
  50367. : afterEnter;
  50368. var enterCancelledHook = isAppear
  50369. ? (appearCancelled || enterCancelled)
  50370. : enterCancelled;
  50371. var explicitEnterDuration = toNumber(
  50372. isObject(duration)
  50373. ? duration.enter
  50374. : duration
  50375. );
  50376. if (explicitEnterDuration != null) {
  50377. checkDuration(explicitEnterDuration, 'enter', vnode);
  50378. }
  50379. var expectsCSS = css !== false && !isIE9;
  50380. var userWantsControl = getHookArgumentsLength(enterHook);
  50381. var cb = el._enterCb = once(function () {
  50382. if (expectsCSS) {
  50383. removeTransitionClass(el, toClass);
  50384. removeTransitionClass(el, activeClass);
  50385. }
  50386. if (cb.cancelled) {
  50387. if (expectsCSS) {
  50388. removeTransitionClass(el, startClass);
  50389. }
  50390. enterCancelledHook && enterCancelledHook(el);
  50391. } else {
  50392. afterEnterHook && afterEnterHook(el);
  50393. }
  50394. el._enterCb = null;
  50395. });
  50396. if (!vnode.data.show) {
  50397. // remove pending leave element on enter by injecting an insert hook
  50398. mergeVNodeHook(vnode, 'insert', function () {
  50399. var parent = el.parentNode;
  50400. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  50401. if (pendingNode &&
  50402. pendingNode.tag === vnode.tag &&
  50403. pendingNode.elm._leaveCb
  50404. ) {
  50405. pendingNode.elm._leaveCb();
  50406. }
  50407. enterHook && enterHook(el, cb);
  50408. });
  50409. }
  50410. // start enter transition
  50411. beforeEnterHook && beforeEnterHook(el);
  50412. if (expectsCSS) {
  50413. addTransitionClass(el, startClass);
  50414. addTransitionClass(el, activeClass);
  50415. nextFrame(function () {
  50416. removeTransitionClass(el, startClass);
  50417. if (!cb.cancelled) {
  50418. addTransitionClass(el, toClass);
  50419. if (!userWantsControl) {
  50420. if (isValidDuration(explicitEnterDuration)) {
  50421. setTimeout(cb, explicitEnterDuration);
  50422. } else {
  50423. whenTransitionEnds(el, type, cb);
  50424. }
  50425. }
  50426. }
  50427. });
  50428. }
  50429. if (vnode.data.show) {
  50430. toggleDisplay && toggleDisplay();
  50431. enterHook && enterHook(el, cb);
  50432. }
  50433. if (!expectsCSS && !userWantsControl) {
  50434. cb();
  50435. }
  50436. }
  50437. function leave (vnode, rm) {
  50438. var el = vnode.elm;
  50439. // call enter callback now
  50440. if (isDef(el._enterCb)) {
  50441. el._enterCb.cancelled = true;
  50442. el._enterCb();
  50443. }
  50444. var data = resolveTransition(vnode.data.transition);
  50445. if (isUndef(data) || el.nodeType !== 1) {
  50446. return rm()
  50447. }
  50448. /* istanbul ignore if */
  50449. if (isDef(el._leaveCb)) {
  50450. return
  50451. }
  50452. var css = data.css;
  50453. var type = data.type;
  50454. var leaveClass = data.leaveClass;
  50455. var leaveToClass = data.leaveToClass;
  50456. var leaveActiveClass = data.leaveActiveClass;
  50457. var beforeLeave = data.beforeLeave;
  50458. var leave = data.leave;
  50459. var afterLeave = data.afterLeave;
  50460. var leaveCancelled = data.leaveCancelled;
  50461. var delayLeave = data.delayLeave;
  50462. var duration = data.duration;
  50463. var expectsCSS = css !== false && !isIE9;
  50464. var userWantsControl = getHookArgumentsLength(leave);
  50465. var explicitLeaveDuration = toNumber(
  50466. isObject(duration)
  50467. ? duration.leave
  50468. : duration
  50469. );
  50470. if (isDef(explicitLeaveDuration)) {
  50471. checkDuration(explicitLeaveDuration, 'leave', vnode);
  50472. }
  50473. var cb = el._leaveCb = once(function () {
  50474. if (el.parentNode && el.parentNode._pending) {
  50475. el.parentNode._pending[vnode.key] = null;
  50476. }
  50477. if (expectsCSS) {
  50478. removeTransitionClass(el, leaveToClass);
  50479. removeTransitionClass(el, leaveActiveClass);
  50480. }
  50481. if (cb.cancelled) {
  50482. if (expectsCSS) {
  50483. removeTransitionClass(el, leaveClass);
  50484. }
  50485. leaveCancelled && leaveCancelled(el);
  50486. } else {
  50487. rm();
  50488. afterLeave && afterLeave(el);
  50489. }
  50490. el._leaveCb = null;
  50491. });
  50492. if (delayLeave) {
  50493. delayLeave(performLeave);
  50494. } else {
  50495. performLeave();
  50496. }
  50497. function performLeave () {
  50498. // the delayed leave may have already been cancelled
  50499. if (cb.cancelled) {
  50500. return
  50501. }
  50502. // record leaving element
  50503. if (!vnode.data.show && el.parentNode) {
  50504. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  50505. }
  50506. beforeLeave && beforeLeave(el);
  50507. if (expectsCSS) {
  50508. addTransitionClass(el, leaveClass);
  50509. addTransitionClass(el, leaveActiveClass);
  50510. nextFrame(function () {
  50511. removeTransitionClass(el, leaveClass);
  50512. if (!cb.cancelled) {
  50513. addTransitionClass(el, leaveToClass);
  50514. if (!userWantsControl) {
  50515. if (isValidDuration(explicitLeaveDuration)) {
  50516. setTimeout(cb, explicitLeaveDuration);
  50517. } else {
  50518. whenTransitionEnds(el, type, cb);
  50519. }
  50520. }
  50521. }
  50522. });
  50523. }
  50524. leave && leave(el, cb);
  50525. if (!expectsCSS && !userWantsControl) {
  50526. cb();
  50527. }
  50528. }
  50529. }
  50530. // only used in dev mode
  50531. function checkDuration (val, name, vnode) {
  50532. if (typeof val !== 'number') {
  50533. warn(
  50534. "<transition> explicit " + name + " duration is not a valid number - " +
  50535. "got " + (JSON.stringify(val)) + ".",
  50536. vnode.context
  50537. );
  50538. } else if (isNaN(val)) {
  50539. warn(
  50540. "<transition> explicit " + name + " duration is NaN - " +
  50541. 'the duration expression might be incorrect.',
  50542. vnode.context
  50543. );
  50544. }
  50545. }
  50546. function isValidDuration (val) {
  50547. return typeof val === 'number' && !isNaN(val)
  50548. }
  50549. /**
  50550. * Normalize a transition hook's argument length. The hook may be:
  50551. * - a merged hook (invoker) with the original in .fns
  50552. * - a wrapped component method (check ._length)
  50553. * - a plain function (.length)
  50554. */
  50555. function getHookArgumentsLength (fn) {
  50556. if (isUndef(fn)) {
  50557. return false
  50558. }
  50559. var invokerFns = fn.fns;
  50560. if (isDef(invokerFns)) {
  50561. // invoker
  50562. return getHookArgumentsLength(
  50563. Array.isArray(invokerFns)
  50564. ? invokerFns[0]
  50565. : invokerFns
  50566. )
  50567. } else {
  50568. return (fn._length || fn.length) > 1
  50569. }
  50570. }
  50571. function _enter (_, vnode) {
  50572. if (vnode.data.show !== true) {
  50573. enter(vnode);
  50574. }
  50575. }
  50576. var transition = inBrowser ? {
  50577. create: _enter,
  50578. activate: _enter,
  50579. remove: function remove$$1 (vnode, rm) {
  50580. /* istanbul ignore else */
  50581. if (vnode.data.show !== true) {
  50582. leave(vnode, rm);
  50583. } else {
  50584. rm();
  50585. }
  50586. }
  50587. } : {};
  50588. var platformModules = [
  50589. attrs,
  50590. klass,
  50591. events,
  50592. domProps,
  50593. style,
  50594. transition
  50595. ];
  50596. /* */
  50597. // the directive module should be applied last, after all
  50598. // built-in modules have been applied.
  50599. var modules = platformModules.concat(baseModules);
  50600. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  50601. /**
  50602. * Not type checking this file because flow doesn't like attaching
  50603. * properties to Elements.
  50604. */
  50605. /* istanbul ignore if */
  50606. if (isIE9) {
  50607. // http://www.matts411.com/post/internet-explorer-9-oninput/
  50608. document.addEventListener('selectionchange', function () {
  50609. var el = document.activeElement;
  50610. if (el && el.vmodel) {
  50611. trigger(el, 'input');
  50612. }
  50613. });
  50614. }
  50615. var directive = {
  50616. inserted: function inserted (el, binding, vnode, oldVnode) {
  50617. if (vnode.tag === 'select') {
  50618. // #6903
  50619. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  50620. mergeVNodeHook(vnode, 'postpatch', function () {
  50621. directive.componentUpdated(el, binding, vnode);
  50622. });
  50623. } else {
  50624. setSelected(el, binding, vnode.context);
  50625. }
  50626. el._vOptions = [].map.call(el.options, getValue);
  50627. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  50628. el._vModifiers = binding.modifiers;
  50629. if (!binding.modifiers.lazy) {
  50630. el.addEventListener('compositionstart', onCompositionStart);
  50631. el.addEventListener('compositionend', onCompositionEnd);
  50632. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  50633. // switching focus before confirming composition choice
  50634. // this also fixes the issue where some browsers e.g. iOS Chrome
  50635. // fires "change" instead of "input" on autocomplete.
  50636. el.addEventListener('change', onCompositionEnd);
  50637. /* istanbul ignore if */
  50638. if (isIE9) {
  50639. el.vmodel = true;
  50640. }
  50641. }
  50642. }
  50643. },
  50644. componentUpdated: function componentUpdated (el, binding, vnode) {
  50645. if (vnode.tag === 'select') {
  50646. setSelected(el, binding, vnode.context);
  50647. // in case the options rendered by v-for have changed,
  50648. // it's possible that the value is out-of-sync with the rendered options.
  50649. // detect such cases and filter out values that no longer has a matching
  50650. // option in the DOM.
  50651. var prevOptions = el._vOptions;
  50652. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  50653. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  50654. // trigger change event if
  50655. // no matching option found for at least one value
  50656. var needReset = el.multiple
  50657. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  50658. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  50659. if (needReset) {
  50660. trigger(el, 'change');
  50661. }
  50662. }
  50663. }
  50664. }
  50665. };
  50666. function setSelected (el, binding, vm) {
  50667. actuallySetSelected(el, binding, vm);
  50668. /* istanbul ignore if */
  50669. if (isIE || isEdge) {
  50670. setTimeout(function () {
  50671. actuallySetSelected(el, binding, vm);
  50672. }, 0);
  50673. }
  50674. }
  50675. function actuallySetSelected (el, binding, vm) {
  50676. var value = binding.value;
  50677. var isMultiple = el.multiple;
  50678. if (isMultiple && !Array.isArray(value)) {
  50679. warn(
  50680. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  50681. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  50682. vm
  50683. );
  50684. return
  50685. }
  50686. var selected, option;
  50687. for (var i = 0, l = el.options.length; i < l; i++) {
  50688. option = el.options[i];
  50689. if (isMultiple) {
  50690. selected = looseIndexOf(value, getValue(option)) > -1;
  50691. if (option.selected !== selected) {
  50692. option.selected = selected;
  50693. }
  50694. } else {
  50695. if (looseEqual(getValue(option), value)) {
  50696. if (el.selectedIndex !== i) {
  50697. el.selectedIndex = i;
  50698. }
  50699. return
  50700. }
  50701. }
  50702. }
  50703. if (!isMultiple) {
  50704. el.selectedIndex = -1;
  50705. }
  50706. }
  50707. function hasNoMatchingOption (value, options) {
  50708. return options.every(function (o) { return !looseEqual(o, value); })
  50709. }
  50710. function getValue (option) {
  50711. return '_value' in option
  50712. ? option._value
  50713. : option.value
  50714. }
  50715. function onCompositionStart (e) {
  50716. e.target.composing = true;
  50717. }
  50718. function onCompositionEnd (e) {
  50719. // prevent triggering an input event for no reason
  50720. if (!e.target.composing) { return }
  50721. e.target.composing = false;
  50722. trigger(e.target, 'input');
  50723. }
  50724. function trigger (el, type) {
  50725. var e = document.createEvent('HTMLEvents');
  50726. e.initEvent(type, true, true);
  50727. el.dispatchEvent(e);
  50728. }
  50729. /* */
  50730. // recursively search for possible transition defined inside the component root
  50731. function locateNode (vnode) {
  50732. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  50733. ? locateNode(vnode.componentInstance._vnode)
  50734. : vnode
  50735. }
  50736. var show = {
  50737. bind: function bind (el, ref, vnode) {
  50738. var value = ref.value;
  50739. vnode = locateNode(vnode);
  50740. var transition$$1 = vnode.data && vnode.data.transition;
  50741. var originalDisplay = el.__vOriginalDisplay =
  50742. el.style.display === 'none' ? '' : el.style.display;
  50743. if (value && transition$$1) {
  50744. vnode.data.show = true;
  50745. enter(vnode, function () {
  50746. el.style.display = originalDisplay;
  50747. });
  50748. } else {
  50749. el.style.display = value ? originalDisplay : 'none';
  50750. }
  50751. },
  50752. update: function update (el, ref, vnode) {
  50753. var value = ref.value;
  50754. var oldValue = ref.oldValue;
  50755. /* istanbul ignore if */
  50756. if (!value === !oldValue) { return }
  50757. vnode = locateNode(vnode);
  50758. var transition$$1 = vnode.data && vnode.data.transition;
  50759. if (transition$$1) {
  50760. vnode.data.show = true;
  50761. if (value) {
  50762. enter(vnode, function () {
  50763. el.style.display = el.__vOriginalDisplay;
  50764. });
  50765. } else {
  50766. leave(vnode, function () {
  50767. el.style.display = 'none';
  50768. });
  50769. }
  50770. } else {
  50771. el.style.display = value ? el.__vOriginalDisplay : 'none';
  50772. }
  50773. },
  50774. unbind: function unbind (
  50775. el,
  50776. binding,
  50777. vnode,
  50778. oldVnode,
  50779. isDestroy
  50780. ) {
  50781. if (!isDestroy) {
  50782. el.style.display = el.__vOriginalDisplay;
  50783. }
  50784. }
  50785. };
  50786. var platformDirectives = {
  50787. model: directive,
  50788. show: show
  50789. };
  50790. /* */
  50791. var transitionProps = {
  50792. name: String,
  50793. appear: Boolean,
  50794. css: Boolean,
  50795. mode: String,
  50796. type: String,
  50797. enterClass: String,
  50798. leaveClass: String,
  50799. enterToClass: String,
  50800. leaveToClass: String,
  50801. enterActiveClass: String,
  50802. leaveActiveClass: String,
  50803. appearClass: String,
  50804. appearActiveClass: String,
  50805. appearToClass: String,
  50806. duration: [Number, String, Object]
  50807. };
  50808. // in case the child is also an abstract component, e.g. <keep-alive>
  50809. // we want to recursively retrieve the real component to be rendered
  50810. function getRealChild (vnode) {
  50811. var compOptions = vnode && vnode.componentOptions;
  50812. if (compOptions && compOptions.Ctor.options.abstract) {
  50813. return getRealChild(getFirstComponentChild(compOptions.children))
  50814. } else {
  50815. return vnode
  50816. }
  50817. }
  50818. function extractTransitionData (comp) {
  50819. var data = {};
  50820. var options = comp.$options;
  50821. // props
  50822. for (var key in options.propsData) {
  50823. data[key] = comp[key];
  50824. }
  50825. // events.
  50826. // extract listeners and pass them directly to the transition methods
  50827. var listeners = options._parentListeners;
  50828. for (var key$1 in listeners) {
  50829. data[camelize(key$1)] = listeners[key$1];
  50830. }
  50831. return data
  50832. }
  50833. function placeholder (h, rawChild) {
  50834. if (/\d-keep-alive$/.test(rawChild.tag)) {
  50835. return h('keep-alive', {
  50836. props: rawChild.componentOptions.propsData
  50837. })
  50838. }
  50839. }
  50840. function hasParentTransition (vnode) {
  50841. while ((vnode = vnode.parent)) {
  50842. if (vnode.data.transition) {
  50843. return true
  50844. }
  50845. }
  50846. }
  50847. function isSameChild (child, oldChild) {
  50848. return oldChild.key === child.key && oldChild.tag === child.tag
  50849. }
  50850. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  50851. var isVShowDirective = function (d) { return d.name === 'show'; };
  50852. var Transition = {
  50853. name: 'transition',
  50854. props: transitionProps,
  50855. abstract: true,
  50856. render: function render (h) {
  50857. var this$1 = this;
  50858. var children = this.$slots.default;
  50859. if (!children) {
  50860. return
  50861. }
  50862. // filter out text nodes (possible whitespaces)
  50863. children = children.filter(isNotTextNode);
  50864. /* istanbul ignore if */
  50865. if (!children.length) {
  50866. return
  50867. }
  50868. // warn multiple elements
  50869. if (children.length > 1) {
  50870. warn(
  50871. '<transition> can only be used on a single element. Use ' +
  50872. '<transition-group> for lists.',
  50873. this.$parent
  50874. );
  50875. }
  50876. var mode = this.mode;
  50877. // warn invalid mode
  50878. if (mode && mode !== 'in-out' && mode !== 'out-in'
  50879. ) {
  50880. warn(
  50881. 'invalid <transition> mode: ' + mode,
  50882. this.$parent
  50883. );
  50884. }
  50885. var rawChild = children[0];
  50886. // if this is a component root node and the component's
  50887. // parent container node also has transition, skip.
  50888. if (hasParentTransition(this.$vnode)) {
  50889. return rawChild
  50890. }
  50891. // apply transition data to child
  50892. // use getRealChild() to ignore abstract components e.g. keep-alive
  50893. var child = getRealChild(rawChild);
  50894. /* istanbul ignore if */
  50895. if (!child) {
  50896. return rawChild
  50897. }
  50898. if (this._leaving) {
  50899. return placeholder(h, rawChild)
  50900. }
  50901. // ensure a key that is unique to the vnode type and to this transition
  50902. // component instance. This key will be used to remove pending leaving nodes
  50903. // during entering.
  50904. var id = "__transition-" + (this._uid) + "-";
  50905. child.key = child.key == null
  50906. ? child.isComment
  50907. ? id + 'comment'
  50908. : id + child.tag
  50909. : isPrimitive(child.key)
  50910. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  50911. : child.key;
  50912. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  50913. var oldRawChild = this._vnode;
  50914. var oldChild = getRealChild(oldRawChild);
  50915. // mark v-show
  50916. // so that the transition module can hand over the control to the directive
  50917. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  50918. child.data.show = true;
  50919. }
  50920. if (
  50921. oldChild &&
  50922. oldChild.data &&
  50923. !isSameChild(child, oldChild) &&
  50924. !isAsyncPlaceholder(oldChild) &&
  50925. // #6687 component root is a comment node
  50926. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  50927. ) {
  50928. // replace old child transition data with fresh one
  50929. // important for dynamic transitions!
  50930. var oldData = oldChild.data.transition = extend({}, data);
  50931. // handle transition mode
  50932. if (mode === 'out-in') {
  50933. // return placeholder node and queue update when leave finishes
  50934. this._leaving = true;
  50935. mergeVNodeHook(oldData, 'afterLeave', function () {
  50936. this$1._leaving = false;
  50937. this$1.$forceUpdate();
  50938. });
  50939. return placeholder(h, rawChild)
  50940. } else if (mode === 'in-out') {
  50941. if (isAsyncPlaceholder(child)) {
  50942. return oldRawChild
  50943. }
  50944. var delayedLeave;
  50945. var performLeave = function () { delayedLeave(); };
  50946. mergeVNodeHook(data, 'afterEnter', performLeave);
  50947. mergeVNodeHook(data, 'enterCancelled', performLeave);
  50948. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  50949. }
  50950. }
  50951. return rawChild
  50952. }
  50953. };
  50954. /* */
  50955. var props = extend({
  50956. tag: String,
  50957. moveClass: String
  50958. }, transitionProps);
  50959. delete props.mode;
  50960. var TransitionGroup = {
  50961. props: props,
  50962. beforeMount: function beforeMount () {
  50963. var this$1 = this;
  50964. var update = this._update;
  50965. this._update = function (vnode, hydrating) {
  50966. var restoreActiveInstance = setActiveInstance(this$1);
  50967. // force removing pass
  50968. this$1.__patch__(
  50969. this$1._vnode,
  50970. this$1.kept,
  50971. false, // hydrating
  50972. true // removeOnly (!important, avoids unnecessary moves)
  50973. );
  50974. this$1._vnode = this$1.kept;
  50975. restoreActiveInstance();
  50976. update.call(this$1, vnode, hydrating);
  50977. };
  50978. },
  50979. render: function render (h) {
  50980. var tag = this.tag || this.$vnode.data.tag || 'span';
  50981. var map = Object.create(null);
  50982. var prevChildren = this.prevChildren = this.children;
  50983. var rawChildren = this.$slots.default || [];
  50984. var children = this.children = [];
  50985. var transitionData = extractTransitionData(this);
  50986. for (var i = 0; i < rawChildren.length; i++) {
  50987. var c = rawChildren[i];
  50988. if (c.tag) {
  50989. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  50990. children.push(c);
  50991. map[c.key] = c
  50992. ;(c.data || (c.data = {})).transition = transitionData;
  50993. } else {
  50994. var opts = c.componentOptions;
  50995. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  50996. warn(("<transition-group> children must be keyed: <" + name + ">"));
  50997. }
  50998. }
  50999. }
  51000. if (prevChildren) {
  51001. var kept = [];
  51002. var removed = [];
  51003. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  51004. var c$1 = prevChildren[i$1];
  51005. c$1.data.transition = transitionData;
  51006. c$1.data.pos = c$1.elm.getBoundingClientRect();
  51007. if (map[c$1.key]) {
  51008. kept.push(c$1);
  51009. } else {
  51010. removed.push(c$1);
  51011. }
  51012. }
  51013. this.kept = h(tag, null, kept);
  51014. this.removed = removed;
  51015. }
  51016. return h(tag, null, children)
  51017. },
  51018. updated: function updated () {
  51019. var children = this.prevChildren;
  51020. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  51021. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  51022. return
  51023. }
  51024. // we divide the work into three loops to avoid mixing DOM reads and writes
  51025. // in each iteration - which helps prevent layout thrashing.
  51026. children.forEach(callPendingCbs);
  51027. children.forEach(recordPosition);
  51028. children.forEach(applyTranslation);
  51029. // force reflow to put everything in position
  51030. // assign to this to avoid being removed in tree-shaking
  51031. // $flow-disable-line
  51032. this._reflow = document.body.offsetHeight;
  51033. children.forEach(function (c) {
  51034. if (c.data.moved) {
  51035. var el = c.elm;
  51036. var s = el.style;
  51037. addTransitionClass(el, moveClass);
  51038. s.transform = s.WebkitTransform = s.transitionDuration = '';
  51039. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  51040. if (e && e.target !== el) {
  51041. return
  51042. }
  51043. if (!e || /transform$/.test(e.propertyName)) {
  51044. el.removeEventListener(transitionEndEvent, cb);
  51045. el._moveCb = null;
  51046. removeTransitionClass(el, moveClass);
  51047. }
  51048. });
  51049. }
  51050. });
  51051. },
  51052. methods: {
  51053. hasMove: function hasMove (el, moveClass) {
  51054. /* istanbul ignore if */
  51055. if (!hasTransition) {
  51056. return false
  51057. }
  51058. /* istanbul ignore if */
  51059. if (this._hasMove) {
  51060. return this._hasMove
  51061. }
  51062. // Detect whether an element with the move class applied has
  51063. // CSS transitions. Since the element may be inside an entering
  51064. // transition at this very moment, we make a clone of it and remove
  51065. // all other transition classes applied to ensure only the move class
  51066. // is applied.
  51067. var clone = el.cloneNode();
  51068. if (el._transitionClasses) {
  51069. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  51070. }
  51071. addClass(clone, moveClass);
  51072. clone.style.display = 'none';
  51073. this.$el.appendChild(clone);
  51074. var info = getTransitionInfo(clone);
  51075. this.$el.removeChild(clone);
  51076. return (this._hasMove = info.hasTransform)
  51077. }
  51078. }
  51079. };
  51080. function callPendingCbs (c) {
  51081. /* istanbul ignore if */
  51082. if (c.elm._moveCb) {
  51083. c.elm._moveCb();
  51084. }
  51085. /* istanbul ignore if */
  51086. if (c.elm._enterCb) {
  51087. c.elm._enterCb();
  51088. }
  51089. }
  51090. function recordPosition (c) {
  51091. c.data.newPos = c.elm.getBoundingClientRect();
  51092. }
  51093. function applyTranslation (c) {
  51094. var oldPos = c.data.pos;
  51095. var newPos = c.data.newPos;
  51096. var dx = oldPos.left - newPos.left;
  51097. var dy = oldPos.top - newPos.top;
  51098. if (dx || dy) {
  51099. c.data.moved = true;
  51100. var s = c.elm.style;
  51101. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  51102. s.transitionDuration = '0s';
  51103. }
  51104. }
  51105. var platformComponents = {
  51106. Transition: Transition,
  51107. TransitionGroup: TransitionGroup
  51108. };
  51109. /* */
  51110. // install platform specific utils
  51111. Vue.config.mustUseProp = mustUseProp;
  51112. Vue.config.isReservedTag = isReservedTag;
  51113. Vue.config.isReservedAttr = isReservedAttr;
  51114. Vue.config.getTagNamespace = getTagNamespace;
  51115. Vue.config.isUnknownElement = isUnknownElement;
  51116. // install platform runtime directives & components
  51117. extend(Vue.options.directives, platformDirectives);
  51118. extend(Vue.options.components, platformComponents);
  51119. // install platform patch function
  51120. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  51121. // public mount method
  51122. Vue.prototype.$mount = function (
  51123. el,
  51124. hydrating
  51125. ) {
  51126. el = el && inBrowser ? query(el) : undefined;
  51127. return mountComponent(this, el, hydrating)
  51128. };
  51129. // devtools global hook
  51130. /* istanbul ignore next */
  51131. if (inBrowser) {
  51132. setTimeout(function () {
  51133. if (config.devtools) {
  51134. if (devtools) {
  51135. devtools.emit('init', Vue);
  51136. } else {
  51137. console[console.info ? 'info' : 'log'](
  51138. 'Download the Vue Devtools extension for a better development experience:\n' +
  51139. 'https://github.com/vuejs/vue-devtools'
  51140. );
  51141. }
  51142. }
  51143. if (config.productionTip !== false &&
  51144. typeof console !== 'undefined'
  51145. ) {
  51146. console[console.info ? 'info' : 'log'](
  51147. "You are running Vue in development mode.\n" +
  51148. "Make sure to turn on production mode when deploying for production.\n" +
  51149. "See more tips at https://vuejs.org/guide/deployment.html"
  51150. );
  51151. }
  51152. }, 0);
  51153. }
  51154. /* */
  51155. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  51156. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  51157. var buildRegex = cached(function (delimiters) {
  51158. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  51159. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  51160. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  51161. });
  51162. function parseText (
  51163. text,
  51164. delimiters
  51165. ) {
  51166. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  51167. if (!tagRE.test(text)) {
  51168. return
  51169. }
  51170. var tokens = [];
  51171. var rawTokens = [];
  51172. var lastIndex = tagRE.lastIndex = 0;
  51173. var match, index, tokenValue;
  51174. while ((match = tagRE.exec(text))) {
  51175. index = match.index;
  51176. // push text token
  51177. if (index > lastIndex) {
  51178. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  51179. tokens.push(JSON.stringify(tokenValue));
  51180. }
  51181. // tag token
  51182. var exp = parseFilters(match[1].trim());
  51183. tokens.push(("_s(" + exp + ")"));
  51184. rawTokens.push({ '@binding': exp });
  51185. lastIndex = index + match[0].length;
  51186. }
  51187. if (lastIndex < text.length) {
  51188. rawTokens.push(tokenValue = text.slice(lastIndex));
  51189. tokens.push(JSON.stringify(tokenValue));
  51190. }
  51191. return {
  51192. expression: tokens.join('+'),
  51193. tokens: rawTokens
  51194. }
  51195. }
  51196. /* */
  51197. function transformNode (el, options) {
  51198. var warn = options.warn || baseWarn;
  51199. var staticClass = getAndRemoveAttr(el, 'class');
  51200. if (staticClass) {
  51201. var res = parseText(staticClass, options.delimiters);
  51202. if (res) {
  51203. warn(
  51204. "class=\"" + staticClass + "\": " +
  51205. 'Interpolation inside attributes has been removed. ' +
  51206. 'Use v-bind or the colon shorthand instead. For example, ' +
  51207. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  51208. el.rawAttrsMap['class']
  51209. );
  51210. }
  51211. }
  51212. if (staticClass) {
  51213. el.staticClass = JSON.stringify(staticClass);
  51214. }
  51215. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  51216. if (classBinding) {
  51217. el.classBinding = classBinding;
  51218. }
  51219. }
  51220. function genData (el) {
  51221. var data = '';
  51222. if (el.staticClass) {
  51223. data += "staticClass:" + (el.staticClass) + ",";
  51224. }
  51225. if (el.classBinding) {
  51226. data += "class:" + (el.classBinding) + ",";
  51227. }
  51228. return data
  51229. }
  51230. var klass$1 = {
  51231. staticKeys: ['staticClass'],
  51232. transformNode: transformNode,
  51233. genData: genData
  51234. };
  51235. /* */
  51236. function transformNode$1 (el, options) {
  51237. var warn = options.warn || baseWarn;
  51238. var staticStyle = getAndRemoveAttr(el, 'style');
  51239. if (staticStyle) {
  51240. /* istanbul ignore if */
  51241. {
  51242. var res = parseText(staticStyle, options.delimiters);
  51243. if (res) {
  51244. warn(
  51245. "style=\"" + staticStyle + "\": " +
  51246. 'Interpolation inside attributes has been removed. ' +
  51247. 'Use v-bind or the colon shorthand instead. For example, ' +
  51248. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  51249. el.rawAttrsMap['style']
  51250. );
  51251. }
  51252. }
  51253. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  51254. }
  51255. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  51256. if (styleBinding) {
  51257. el.styleBinding = styleBinding;
  51258. }
  51259. }
  51260. function genData$1 (el) {
  51261. var data = '';
  51262. if (el.staticStyle) {
  51263. data += "staticStyle:" + (el.staticStyle) + ",";
  51264. }
  51265. if (el.styleBinding) {
  51266. data += "style:(" + (el.styleBinding) + "),";
  51267. }
  51268. return data
  51269. }
  51270. var style$1 = {
  51271. staticKeys: ['staticStyle'],
  51272. transformNode: transformNode$1,
  51273. genData: genData$1
  51274. };
  51275. /* */
  51276. var decoder;
  51277. var he = {
  51278. decode: function decode (html) {
  51279. decoder = decoder || document.createElement('div');
  51280. decoder.innerHTML = html;
  51281. return decoder.textContent
  51282. }
  51283. };
  51284. /* */
  51285. var isUnaryTag = makeMap(
  51286. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  51287. 'link,meta,param,source,track,wbr'
  51288. );
  51289. // Elements that you can, intentionally, leave open
  51290. // (and which close themselves)
  51291. var canBeLeftOpenTag = makeMap(
  51292. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  51293. );
  51294. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  51295. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  51296. var isNonPhrasingTag = makeMap(
  51297. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  51298. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  51299. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  51300. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  51301. 'title,tr,track'
  51302. );
  51303. /**
  51304. * Not type-checking this file because it's mostly vendor code.
  51305. */
  51306. // Regular Expressions for parsing tags and attributes
  51307. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  51308. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  51309. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  51310. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  51311. var startTagOpen = new RegExp(("^<" + qnameCapture));
  51312. var startTagClose = /^\s*(\/?)>/;
  51313. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  51314. var doctype = /^<!DOCTYPE [^>]+>/i;
  51315. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  51316. var comment = /^<!\--/;
  51317. var conditionalComment = /^<!\[/;
  51318. // Special Elements (can contain anything)
  51319. var isPlainTextElement = makeMap('script,style,textarea', true);
  51320. var reCache = {};
  51321. var decodingMap = {
  51322. '&lt;': '<',
  51323. '&gt;': '>',
  51324. '&quot;': '"',
  51325. '&amp;': '&',
  51326. '&#10;': '\n',
  51327. '&#9;': '\t',
  51328. '&#39;': "'"
  51329. };
  51330. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  51331. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  51332. // #5992
  51333. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  51334. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  51335. function decodeAttr (value, shouldDecodeNewlines) {
  51336. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  51337. return value.replace(re, function (match) { return decodingMap[match]; })
  51338. }
  51339. function parseHTML (html, options) {
  51340. var stack = [];
  51341. var expectHTML = options.expectHTML;
  51342. var isUnaryTag$$1 = options.isUnaryTag || no;
  51343. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  51344. var index = 0;
  51345. var last, lastTag;
  51346. while (html) {
  51347. last = html;
  51348. // Make sure we're not in a plaintext content element like script/style
  51349. if (!lastTag || !isPlainTextElement(lastTag)) {
  51350. var textEnd = html.indexOf('<');
  51351. if (textEnd === 0) {
  51352. // Comment:
  51353. if (comment.test(html)) {
  51354. var commentEnd = html.indexOf('-->');
  51355. if (commentEnd >= 0) {
  51356. if (options.shouldKeepComment) {
  51357. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  51358. }
  51359. advance(commentEnd + 3);
  51360. continue
  51361. }
  51362. }
  51363. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  51364. if (conditionalComment.test(html)) {
  51365. var conditionalEnd = html.indexOf(']>');
  51366. if (conditionalEnd >= 0) {
  51367. advance(conditionalEnd + 2);
  51368. continue
  51369. }
  51370. }
  51371. // Doctype:
  51372. var doctypeMatch = html.match(doctype);
  51373. if (doctypeMatch) {
  51374. advance(doctypeMatch[0].length);
  51375. continue
  51376. }
  51377. // End tag:
  51378. var endTagMatch = html.match(endTag);
  51379. if (endTagMatch) {
  51380. var curIndex = index;
  51381. advance(endTagMatch[0].length);
  51382. parseEndTag(endTagMatch[1], curIndex, index);
  51383. continue
  51384. }
  51385. // Start tag:
  51386. var startTagMatch = parseStartTag();
  51387. if (startTagMatch) {
  51388. handleStartTag(startTagMatch);
  51389. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  51390. advance(1);
  51391. }
  51392. continue
  51393. }
  51394. }
  51395. var text = (void 0), rest = (void 0), next = (void 0);
  51396. if (textEnd >= 0) {
  51397. rest = html.slice(textEnd);
  51398. while (
  51399. !endTag.test(rest) &&
  51400. !startTagOpen.test(rest) &&
  51401. !comment.test(rest) &&
  51402. !conditionalComment.test(rest)
  51403. ) {
  51404. // < in plain text, be forgiving and treat it as text
  51405. next = rest.indexOf('<', 1);
  51406. if (next < 0) { break }
  51407. textEnd += next;
  51408. rest = html.slice(textEnd);
  51409. }
  51410. text = html.substring(0, textEnd);
  51411. }
  51412. if (textEnd < 0) {
  51413. text = html;
  51414. }
  51415. if (text) {
  51416. advance(text.length);
  51417. }
  51418. if (options.chars && text) {
  51419. options.chars(text, index - text.length, index);
  51420. }
  51421. } else {
  51422. var endTagLength = 0;
  51423. var stackedTag = lastTag.toLowerCase();
  51424. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  51425. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  51426. endTagLength = endTag.length;
  51427. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  51428. text = text
  51429. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  51430. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  51431. }
  51432. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  51433. text = text.slice(1);
  51434. }
  51435. if (options.chars) {
  51436. options.chars(text);
  51437. }
  51438. return ''
  51439. });
  51440. index += html.length - rest$1.length;
  51441. html = rest$1;
  51442. parseEndTag(stackedTag, index - endTagLength, index);
  51443. }
  51444. if (html === last) {
  51445. options.chars && options.chars(html);
  51446. if (!stack.length && options.warn) {
  51447. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  51448. }
  51449. break
  51450. }
  51451. }
  51452. // Clean up any remaining tags
  51453. parseEndTag();
  51454. function advance (n) {
  51455. index += n;
  51456. html = html.substring(n);
  51457. }
  51458. function parseStartTag () {
  51459. var start = html.match(startTagOpen);
  51460. if (start) {
  51461. var match = {
  51462. tagName: start[1],
  51463. attrs: [],
  51464. start: index
  51465. };
  51466. advance(start[0].length);
  51467. var end, attr;
  51468. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  51469. attr.start = index;
  51470. advance(attr[0].length);
  51471. attr.end = index;
  51472. match.attrs.push(attr);
  51473. }
  51474. if (end) {
  51475. match.unarySlash = end[1];
  51476. advance(end[0].length);
  51477. match.end = index;
  51478. return match
  51479. }
  51480. }
  51481. }
  51482. function handleStartTag (match) {
  51483. var tagName = match.tagName;
  51484. var unarySlash = match.unarySlash;
  51485. if (expectHTML) {
  51486. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  51487. parseEndTag(lastTag);
  51488. }
  51489. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  51490. parseEndTag(tagName);
  51491. }
  51492. }
  51493. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  51494. var l = match.attrs.length;
  51495. var attrs = new Array(l);
  51496. for (var i = 0; i < l; i++) {
  51497. var args = match.attrs[i];
  51498. var value = args[3] || args[4] || args[5] || '';
  51499. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  51500. ? options.shouldDecodeNewlinesForHref
  51501. : options.shouldDecodeNewlines;
  51502. attrs[i] = {
  51503. name: args[1],
  51504. value: decodeAttr(value, shouldDecodeNewlines)
  51505. };
  51506. if (options.outputSourceRange) {
  51507. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  51508. attrs[i].end = args.end;
  51509. }
  51510. }
  51511. if (!unary) {
  51512. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  51513. lastTag = tagName;
  51514. }
  51515. if (options.start) {
  51516. options.start(tagName, attrs, unary, match.start, match.end);
  51517. }
  51518. }
  51519. function parseEndTag (tagName, start, end) {
  51520. var pos, lowerCasedTagName;
  51521. if (start == null) { start = index; }
  51522. if (end == null) { end = index; }
  51523. // Find the closest opened tag of the same type
  51524. if (tagName) {
  51525. lowerCasedTagName = tagName.toLowerCase();
  51526. for (pos = stack.length - 1; pos >= 0; pos--) {
  51527. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  51528. break
  51529. }
  51530. }
  51531. } else {
  51532. // If no tag name is provided, clean shop
  51533. pos = 0;
  51534. }
  51535. if (pos >= 0) {
  51536. // Close all the open elements, up the stack
  51537. for (var i = stack.length - 1; i >= pos; i--) {
  51538. if (i > pos || !tagName &&
  51539. options.warn
  51540. ) {
  51541. options.warn(
  51542. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  51543. { start: stack[i].start, end: stack[i].end }
  51544. );
  51545. }
  51546. if (options.end) {
  51547. options.end(stack[i].tag, start, end);
  51548. }
  51549. }
  51550. // Remove the open elements from the stack
  51551. stack.length = pos;
  51552. lastTag = pos && stack[pos - 1].tag;
  51553. } else if (lowerCasedTagName === 'br') {
  51554. if (options.start) {
  51555. options.start(tagName, [], true, start, end);
  51556. }
  51557. } else if (lowerCasedTagName === 'p') {
  51558. if (options.start) {
  51559. options.start(tagName, [], false, start, end);
  51560. }
  51561. if (options.end) {
  51562. options.end(tagName, start, end);
  51563. }
  51564. }
  51565. }
  51566. }
  51567. /* */
  51568. var onRE = /^@|^v-on:/;
  51569. var dirRE = /^v-|^@|^:|^#/;
  51570. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  51571. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  51572. var stripParensRE = /^\(|\)$/g;
  51573. var dynamicArgRE = /^\[.*\]$/;
  51574. var argRE = /:(.*)$/;
  51575. var bindRE = /^:|^\.|^v-bind:/;
  51576. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  51577. var slotRE = /^v-slot(:|$)|^#/;
  51578. var lineBreakRE = /[\r\n]/;
  51579. var whitespaceRE$1 = /\s+/g;
  51580. var invalidAttributeRE = /[\s"'<>\/=]/;
  51581. var decodeHTMLCached = cached(he.decode);
  51582. var emptySlotScopeToken = "_empty_";
  51583. // configurable state
  51584. var warn$2;
  51585. var delimiters;
  51586. var transforms;
  51587. var preTransforms;
  51588. var postTransforms;
  51589. var platformIsPreTag;
  51590. var platformMustUseProp;
  51591. var platformGetTagNamespace;
  51592. var maybeComponent;
  51593. function createASTElement (
  51594. tag,
  51595. attrs,
  51596. parent
  51597. ) {
  51598. return {
  51599. type: 1,
  51600. tag: tag,
  51601. attrsList: attrs,
  51602. attrsMap: makeAttrsMap(attrs),
  51603. rawAttrsMap: {},
  51604. parent: parent,
  51605. children: []
  51606. }
  51607. }
  51608. /**
  51609. * Convert HTML string to AST.
  51610. */
  51611. function parse (
  51612. template,
  51613. options
  51614. ) {
  51615. warn$2 = options.warn || baseWarn;
  51616. platformIsPreTag = options.isPreTag || no;
  51617. platformMustUseProp = options.mustUseProp || no;
  51618. platformGetTagNamespace = options.getTagNamespace || no;
  51619. var isReservedTag = options.isReservedTag || no;
  51620. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  51621. transforms = pluckModuleFunction(options.modules, 'transformNode');
  51622. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  51623. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  51624. delimiters = options.delimiters;
  51625. var stack = [];
  51626. var preserveWhitespace = options.preserveWhitespace !== false;
  51627. var whitespaceOption = options.whitespace;
  51628. var root;
  51629. var currentParent;
  51630. var inVPre = false;
  51631. var inPre = false;
  51632. var warned = false;
  51633. function warnOnce (msg, range) {
  51634. if (!warned) {
  51635. warned = true;
  51636. warn$2(msg, range);
  51637. }
  51638. }
  51639. function closeElement (element) {
  51640. trimEndingWhitespace(element);
  51641. if (!inVPre && !element.processed) {
  51642. element = processElement(element, options);
  51643. }
  51644. // tree management
  51645. if (!stack.length && element !== root) {
  51646. // allow root elements with v-if, v-else-if and v-else
  51647. if (root.if && (element.elseif || element.else)) {
  51648. {
  51649. checkRootConstraints(element);
  51650. }
  51651. addIfCondition(root, {
  51652. exp: element.elseif,
  51653. block: element
  51654. });
  51655. } else {
  51656. warnOnce(
  51657. "Component template should contain exactly one root element. " +
  51658. "If you are using v-if on multiple elements, " +
  51659. "use v-else-if to chain them instead.",
  51660. { start: element.start }
  51661. );
  51662. }
  51663. }
  51664. if (currentParent && !element.forbidden) {
  51665. if (element.elseif || element.else) {
  51666. processIfConditions(element, currentParent);
  51667. } else {
  51668. if (element.slotScope) {
  51669. // scoped slot
  51670. // keep it in the children list so that v-else(-if) conditions can
  51671. // find it as the prev node.
  51672. var name = element.slotTarget || '"default"'
  51673. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  51674. }
  51675. currentParent.children.push(element);
  51676. element.parent = currentParent;
  51677. }
  51678. }
  51679. // final children cleanup
  51680. // filter out scoped slots
  51681. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  51682. // remove trailing whitespace node again
  51683. trimEndingWhitespace(element);
  51684. // check pre state
  51685. if (element.pre) {
  51686. inVPre = false;
  51687. }
  51688. if (platformIsPreTag(element.tag)) {
  51689. inPre = false;
  51690. }
  51691. // apply post-transforms
  51692. for (var i = 0; i < postTransforms.length; i++) {
  51693. postTransforms[i](element, options);
  51694. }
  51695. }
  51696. function trimEndingWhitespace (el) {
  51697. // remove trailing whitespace node
  51698. if (!inPre) {
  51699. var lastNode;
  51700. while (
  51701. (lastNode = el.children[el.children.length - 1]) &&
  51702. lastNode.type === 3 &&
  51703. lastNode.text === ' '
  51704. ) {
  51705. el.children.pop();
  51706. }
  51707. }
  51708. }
  51709. function checkRootConstraints (el) {
  51710. if (el.tag === 'slot' || el.tag === 'template') {
  51711. warnOnce(
  51712. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  51713. 'contain multiple nodes.',
  51714. { start: el.start }
  51715. );
  51716. }
  51717. if (el.attrsMap.hasOwnProperty('v-for')) {
  51718. warnOnce(
  51719. 'Cannot use v-for on stateful component root element because ' +
  51720. 'it renders multiple elements.',
  51721. el.rawAttrsMap['v-for']
  51722. );
  51723. }
  51724. }
  51725. parseHTML(template, {
  51726. warn: warn$2,
  51727. expectHTML: options.expectHTML,
  51728. isUnaryTag: options.isUnaryTag,
  51729. canBeLeftOpenTag: options.canBeLeftOpenTag,
  51730. shouldDecodeNewlines: options.shouldDecodeNewlines,
  51731. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  51732. shouldKeepComment: options.comments,
  51733. outputSourceRange: options.outputSourceRange,
  51734. start: function start (tag, attrs, unary, start$1, end) {
  51735. // check namespace.
  51736. // inherit parent ns if there is one
  51737. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  51738. // handle IE svg bug
  51739. /* istanbul ignore if */
  51740. if (isIE && ns === 'svg') {
  51741. attrs = guardIESVGBug(attrs);
  51742. }
  51743. var element = createASTElement(tag, attrs, currentParent);
  51744. if (ns) {
  51745. element.ns = ns;
  51746. }
  51747. {
  51748. if (options.outputSourceRange) {
  51749. element.start = start$1;
  51750. element.end = end;
  51751. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  51752. cumulated[attr.name] = attr;
  51753. return cumulated
  51754. }, {});
  51755. }
  51756. attrs.forEach(function (attr) {
  51757. if (invalidAttributeRE.test(attr.name)) {
  51758. warn$2(
  51759. "Invalid dynamic argument expression: attribute names cannot contain " +
  51760. "spaces, quotes, <, >, / or =.",
  51761. {
  51762. start: attr.start + attr.name.indexOf("["),
  51763. end: attr.start + attr.name.length
  51764. }
  51765. );
  51766. }
  51767. });
  51768. }
  51769. if (isForbiddenTag(element) && !isServerRendering()) {
  51770. element.forbidden = true;
  51771. warn$2(
  51772. 'Templates should only be responsible for mapping the state to the ' +
  51773. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  51774. "<" + tag + ">" + ', as they will not be parsed.',
  51775. { start: element.start }
  51776. );
  51777. }
  51778. // apply pre-transforms
  51779. for (var i = 0; i < preTransforms.length; i++) {
  51780. element = preTransforms[i](element, options) || element;
  51781. }
  51782. if (!inVPre) {
  51783. processPre(element);
  51784. if (element.pre) {
  51785. inVPre = true;
  51786. }
  51787. }
  51788. if (platformIsPreTag(element.tag)) {
  51789. inPre = true;
  51790. }
  51791. if (inVPre) {
  51792. processRawAttrs(element);
  51793. } else if (!element.processed) {
  51794. // structural directives
  51795. processFor(element);
  51796. processIf(element);
  51797. processOnce(element);
  51798. }
  51799. if (!root) {
  51800. root = element;
  51801. {
  51802. checkRootConstraints(root);
  51803. }
  51804. }
  51805. if (!unary) {
  51806. currentParent = element;
  51807. stack.push(element);
  51808. } else {
  51809. closeElement(element);
  51810. }
  51811. },
  51812. end: function end (tag, start, end$1) {
  51813. var element = stack[stack.length - 1];
  51814. // pop stack
  51815. stack.length -= 1;
  51816. currentParent = stack[stack.length - 1];
  51817. if (options.outputSourceRange) {
  51818. element.end = end$1;
  51819. }
  51820. closeElement(element);
  51821. },
  51822. chars: function chars (text, start, end) {
  51823. if (!currentParent) {
  51824. {
  51825. if (text === template) {
  51826. warnOnce(
  51827. 'Component template requires a root element, rather than just text.',
  51828. { start: start }
  51829. );
  51830. } else if ((text = text.trim())) {
  51831. warnOnce(
  51832. ("text \"" + text + "\" outside root element will be ignored."),
  51833. { start: start }
  51834. );
  51835. }
  51836. }
  51837. return
  51838. }
  51839. // IE textarea placeholder bug
  51840. /* istanbul ignore if */
  51841. if (isIE &&
  51842. currentParent.tag === 'textarea' &&
  51843. currentParent.attrsMap.placeholder === text
  51844. ) {
  51845. return
  51846. }
  51847. var children = currentParent.children;
  51848. if (inPre || text.trim()) {
  51849. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  51850. } else if (!children.length) {
  51851. // remove the whitespace-only node right after an opening tag
  51852. text = '';
  51853. } else if (whitespaceOption) {
  51854. if (whitespaceOption === 'condense') {
  51855. // in condense mode, remove the whitespace node if it contains
  51856. // line break, otherwise condense to a single space
  51857. text = lineBreakRE.test(text) ? '' : ' ';
  51858. } else {
  51859. text = ' ';
  51860. }
  51861. } else {
  51862. text = preserveWhitespace ? ' ' : '';
  51863. }
  51864. if (text) {
  51865. if (!inPre && whitespaceOption === 'condense') {
  51866. // condense consecutive whitespaces into single space
  51867. text = text.replace(whitespaceRE$1, ' ');
  51868. }
  51869. var res;
  51870. var child;
  51871. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  51872. child = {
  51873. type: 2,
  51874. expression: res.expression,
  51875. tokens: res.tokens,
  51876. text: text
  51877. };
  51878. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  51879. child = {
  51880. type: 3,
  51881. text: text
  51882. };
  51883. }
  51884. if (child) {
  51885. if (options.outputSourceRange) {
  51886. child.start = start;
  51887. child.end = end;
  51888. }
  51889. children.push(child);
  51890. }
  51891. }
  51892. },
  51893. comment: function comment (text, start, end) {
  51894. // adding anyting as a sibling to the root node is forbidden
  51895. // comments should still be allowed, but ignored
  51896. if (currentParent) {
  51897. var child = {
  51898. type: 3,
  51899. text: text,
  51900. isComment: true
  51901. };
  51902. if (options.outputSourceRange) {
  51903. child.start = start;
  51904. child.end = end;
  51905. }
  51906. currentParent.children.push(child);
  51907. }
  51908. }
  51909. });
  51910. return root
  51911. }
  51912. function processPre (el) {
  51913. if (getAndRemoveAttr(el, 'v-pre') != null) {
  51914. el.pre = true;
  51915. }
  51916. }
  51917. function processRawAttrs (el) {
  51918. var list = el.attrsList;
  51919. var len = list.length;
  51920. if (len) {
  51921. var attrs = el.attrs = new Array(len);
  51922. for (var i = 0; i < len; i++) {
  51923. attrs[i] = {
  51924. name: list[i].name,
  51925. value: JSON.stringify(list[i].value)
  51926. };
  51927. if (list[i].start != null) {
  51928. attrs[i].start = list[i].start;
  51929. attrs[i].end = list[i].end;
  51930. }
  51931. }
  51932. } else if (!el.pre) {
  51933. // non root node in pre blocks with no attributes
  51934. el.plain = true;
  51935. }
  51936. }
  51937. function processElement (
  51938. element,
  51939. options
  51940. ) {
  51941. processKey(element);
  51942. // determine whether this is a plain element after
  51943. // removing structural attributes
  51944. element.plain = (
  51945. !element.key &&
  51946. !element.scopedSlots &&
  51947. !element.attrsList.length
  51948. );
  51949. processRef(element);
  51950. processSlotContent(element);
  51951. processSlotOutlet(element);
  51952. processComponent(element);
  51953. for (var i = 0; i < transforms.length; i++) {
  51954. element = transforms[i](element, options) || element;
  51955. }
  51956. processAttrs(element);
  51957. return element
  51958. }
  51959. function processKey (el) {
  51960. var exp = getBindingAttr(el, 'key');
  51961. if (exp) {
  51962. {
  51963. if (el.tag === 'template') {
  51964. warn$2(
  51965. "<template> cannot be keyed. Place the key on real elements instead.",
  51966. getRawBindingAttr(el, 'key')
  51967. );
  51968. }
  51969. if (el.for) {
  51970. var iterator = el.iterator2 || el.iterator1;
  51971. var parent = el.parent;
  51972. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  51973. warn$2(
  51974. "Do not use v-for index as key on <transition-group> children, " +
  51975. "this is the same as not using keys.",
  51976. getRawBindingAttr(el, 'key'),
  51977. true /* tip */
  51978. );
  51979. }
  51980. }
  51981. }
  51982. el.key = exp;
  51983. }
  51984. }
  51985. function processRef (el) {
  51986. var ref = getBindingAttr(el, 'ref');
  51987. if (ref) {
  51988. el.ref = ref;
  51989. el.refInFor = checkInFor(el);
  51990. }
  51991. }
  51992. function processFor (el) {
  51993. var exp;
  51994. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  51995. var res = parseFor(exp);
  51996. if (res) {
  51997. extend(el, res);
  51998. } else {
  51999. warn$2(
  52000. ("Invalid v-for expression: " + exp),
  52001. el.rawAttrsMap['v-for']
  52002. );
  52003. }
  52004. }
  52005. }
  52006. function parseFor (exp) {
  52007. var inMatch = exp.match(forAliasRE);
  52008. if (!inMatch) { return }
  52009. var res = {};
  52010. res.for = inMatch[2].trim();
  52011. var alias = inMatch[1].trim().replace(stripParensRE, '');
  52012. var iteratorMatch = alias.match(forIteratorRE);
  52013. if (iteratorMatch) {
  52014. res.alias = alias.replace(forIteratorRE, '').trim();
  52015. res.iterator1 = iteratorMatch[1].trim();
  52016. if (iteratorMatch[2]) {
  52017. res.iterator2 = iteratorMatch[2].trim();
  52018. }
  52019. } else {
  52020. res.alias = alias;
  52021. }
  52022. return res
  52023. }
  52024. function processIf (el) {
  52025. var exp = getAndRemoveAttr(el, 'v-if');
  52026. if (exp) {
  52027. el.if = exp;
  52028. addIfCondition(el, {
  52029. exp: exp,
  52030. block: el
  52031. });
  52032. } else {
  52033. if (getAndRemoveAttr(el, 'v-else') != null) {
  52034. el.else = true;
  52035. }
  52036. var elseif = getAndRemoveAttr(el, 'v-else-if');
  52037. if (elseif) {
  52038. el.elseif = elseif;
  52039. }
  52040. }
  52041. }
  52042. function processIfConditions (el, parent) {
  52043. var prev = findPrevElement(parent.children);
  52044. if (prev && prev.if) {
  52045. addIfCondition(prev, {
  52046. exp: el.elseif,
  52047. block: el
  52048. });
  52049. } else {
  52050. warn$2(
  52051. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  52052. "used on element <" + (el.tag) + "> without corresponding v-if.",
  52053. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  52054. );
  52055. }
  52056. }
  52057. function findPrevElement (children) {
  52058. var i = children.length;
  52059. while (i--) {
  52060. if (children[i].type === 1) {
  52061. return children[i]
  52062. } else {
  52063. if (children[i].text !== ' ') {
  52064. warn$2(
  52065. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  52066. "will be ignored.",
  52067. children[i]
  52068. );
  52069. }
  52070. children.pop();
  52071. }
  52072. }
  52073. }
  52074. function addIfCondition (el, condition) {
  52075. if (!el.ifConditions) {
  52076. el.ifConditions = [];
  52077. }
  52078. el.ifConditions.push(condition);
  52079. }
  52080. function processOnce (el) {
  52081. var once$$1 = getAndRemoveAttr(el, 'v-once');
  52082. if (once$$1 != null) {
  52083. el.once = true;
  52084. }
  52085. }
  52086. // handle content being passed to a component as slot,
  52087. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  52088. function processSlotContent (el) {
  52089. var slotScope;
  52090. if (el.tag === 'template') {
  52091. slotScope = getAndRemoveAttr(el, 'scope');
  52092. /* istanbul ignore if */
  52093. if (slotScope) {
  52094. warn$2(
  52095. "the \"scope\" attribute for scoped slots have been deprecated and " +
  52096. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  52097. "can also be used on plain elements in addition to <template> to " +
  52098. "denote scoped slots.",
  52099. el.rawAttrsMap['scope'],
  52100. true
  52101. );
  52102. }
  52103. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  52104. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  52105. /* istanbul ignore if */
  52106. if (el.attrsMap['v-for']) {
  52107. warn$2(
  52108. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  52109. "(v-for takes higher priority). Use a wrapper <template> for the " +
  52110. "scoped slot to make it clearer.",
  52111. el.rawAttrsMap['slot-scope'],
  52112. true
  52113. );
  52114. }
  52115. el.slotScope = slotScope;
  52116. }
  52117. // slot="xxx"
  52118. var slotTarget = getBindingAttr(el, 'slot');
  52119. if (slotTarget) {
  52120. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  52121. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  52122. // preserve slot as an attribute for native shadow DOM compat
  52123. // only for non-scoped slots.
  52124. if (el.tag !== 'template' && !el.slotScope) {
  52125. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  52126. }
  52127. }
  52128. // 2.6 v-slot syntax
  52129. {
  52130. if (el.tag === 'template') {
  52131. // v-slot on <template>
  52132. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  52133. if (slotBinding) {
  52134. {
  52135. if (el.slotTarget || el.slotScope) {
  52136. warn$2(
  52137. "Unexpected mixed usage of different slot syntaxes.",
  52138. el
  52139. );
  52140. }
  52141. if (el.parent && !maybeComponent(el.parent)) {
  52142. warn$2(
  52143. "<template v-slot> can only appear at the root level inside " +
  52144. "the receiving component",
  52145. el
  52146. );
  52147. }
  52148. }
  52149. var ref = getSlotName(slotBinding);
  52150. var name = ref.name;
  52151. var dynamic = ref.dynamic;
  52152. el.slotTarget = name;
  52153. el.slotTargetDynamic = dynamic;
  52154. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  52155. }
  52156. } else {
  52157. // v-slot on component, denotes default slot
  52158. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  52159. if (slotBinding$1) {
  52160. {
  52161. if (!maybeComponent(el)) {
  52162. warn$2(
  52163. "v-slot can only be used on components or <template>.",
  52164. slotBinding$1
  52165. );
  52166. }
  52167. if (el.slotScope || el.slotTarget) {
  52168. warn$2(
  52169. "Unexpected mixed usage of different slot syntaxes.",
  52170. el
  52171. );
  52172. }
  52173. if (el.scopedSlots) {
  52174. warn$2(
  52175. "To avoid scope ambiguity, the default slot should also use " +
  52176. "<template> syntax when there are other named slots.",
  52177. slotBinding$1
  52178. );
  52179. }
  52180. }
  52181. // add the component's children to its default slot
  52182. var slots = el.scopedSlots || (el.scopedSlots = {});
  52183. var ref$1 = getSlotName(slotBinding$1);
  52184. var name$1 = ref$1.name;
  52185. var dynamic$1 = ref$1.dynamic;
  52186. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  52187. slotContainer.slotTarget = name$1;
  52188. slotContainer.slotTargetDynamic = dynamic$1;
  52189. slotContainer.children = el.children.filter(function (c) {
  52190. if (!c.slotScope) {
  52191. c.parent = slotContainer;
  52192. return true
  52193. }
  52194. });
  52195. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  52196. // remove children as they are returned from scopedSlots now
  52197. el.children = [];
  52198. // mark el non-plain so data gets generated
  52199. el.plain = false;
  52200. }
  52201. }
  52202. }
  52203. }
  52204. function getSlotName (binding) {
  52205. var name = binding.name.replace(slotRE, '');
  52206. if (!name) {
  52207. if (binding.name[0] !== '#') {
  52208. name = 'default';
  52209. } else {
  52210. warn$2(
  52211. "v-slot shorthand syntax requires a slot name.",
  52212. binding
  52213. );
  52214. }
  52215. }
  52216. return dynamicArgRE.test(name)
  52217. // dynamic [name]
  52218. ? { name: name.slice(1, -1), dynamic: true }
  52219. // static name
  52220. : { name: ("\"" + name + "\""), dynamic: false }
  52221. }
  52222. // handle <slot/> outlets
  52223. function processSlotOutlet (el) {
  52224. if (el.tag === 'slot') {
  52225. el.slotName = getBindingAttr(el, 'name');
  52226. if (el.key) {
  52227. warn$2(
  52228. "`key` does not work on <slot> because slots are abstract outlets " +
  52229. "and can possibly expand into multiple elements. " +
  52230. "Use the key on a wrapping element instead.",
  52231. getRawBindingAttr(el, 'key')
  52232. );
  52233. }
  52234. }
  52235. }
  52236. function processComponent (el) {
  52237. var binding;
  52238. if ((binding = getBindingAttr(el, 'is'))) {
  52239. el.component = binding;
  52240. }
  52241. if (getAndRemoveAttr(el, 'inline-template') != null) {
  52242. el.inlineTemplate = true;
  52243. }
  52244. }
  52245. function processAttrs (el) {
  52246. var list = el.attrsList;
  52247. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  52248. for (i = 0, l = list.length; i < l; i++) {
  52249. name = rawName = list[i].name;
  52250. value = list[i].value;
  52251. if (dirRE.test(name)) {
  52252. // mark element as dynamic
  52253. el.hasBindings = true;
  52254. // modifiers
  52255. modifiers = parseModifiers(name.replace(dirRE, ''));
  52256. // support .foo shorthand syntax for the .prop modifier
  52257. if (modifiers) {
  52258. name = name.replace(modifierRE, '');
  52259. }
  52260. if (bindRE.test(name)) { // v-bind
  52261. name = name.replace(bindRE, '');
  52262. value = parseFilters(value);
  52263. isDynamic = dynamicArgRE.test(name);
  52264. if (isDynamic) {
  52265. name = name.slice(1, -1);
  52266. }
  52267. if (
  52268. value.trim().length === 0
  52269. ) {
  52270. warn$2(
  52271. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  52272. );
  52273. }
  52274. if (modifiers) {
  52275. if (modifiers.prop && !isDynamic) {
  52276. name = camelize(name);
  52277. if (name === 'innerHtml') { name = 'innerHTML'; }
  52278. }
  52279. if (modifiers.camel && !isDynamic) {
  52280. name = camelize(name);
  52281. }
  52282. if (modifiers.sync) {
  52283. syncGen = genAssignmentCode(value, "$event");
  52284. if (!isDynamic) {
  52285. addHandler(
  52286. el,
  52287. ("update:" + (camelize(name))),
  52288. syncGen,
  52289. null,
  52290. false,
  52291. warn$2,
  52292. list[i]
  52293. );
  52294. if (hyphenate(name) !== camelize(name)) {
  52295. addHandler(
  52296. el,
  52297. ("update:" + (hyphenate(name))),
  52298. syncGen,
  52299. null,
  52300. false,
  52301. warn$2,
  52302. list[i]
  52303. );
  52304. }
  52305. } else {
  52306. // handler w/ dynamic event name
  52307. addHandler(
  52308. el,
  52309. ("\"update:\"+(" + name + ")"),
  52310. syncGen,
  52311. null,
  52312. false,
  52313. warn$2,
  52314. list[i],
  52315. true // dynamic
  52316. );
  52317. }
  52318. }
  52319. }
  52320. if ((modifiers && modifiers.prop) || (
  52321. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  52322. )) {
  52323. addProp(el, name, value, list[i], isDynamic);
  52324. } else {
  52325. addAttr(el, name, value, list[i], isDynamic);
  52326. }
  52327. } else if (onRE.test(name)) { // v-on
  52328. name = name.replace(onRE, '');
  52329. isDynamic = dynamicArgRE.test(name);
  52330. if (isDynamic) {
  52331. name = name.slice(1, -1);
  52332. }
  52333. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  52334. } else { // normal directives
  52335. name = name.replace(dirRE, '');
  52336. // parse arg
  52337. var argMatch = name.match(argRE);
  52338. var arg = argMatch && argMatch[1];
  52339. isDynamic = false;
  52340. if (arg) {
  52341. name = name.slice(0, -(arg.length + 1));
  52342. if (dynamicArgRE.test(arg)) {
  52343. arg = arg.slice(1, -1);
  52344. isDynamic = true;
  52345. }
  52346. }
  52347. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  52348. if (name === 'model') {
  52349. checkForAliasModel(el, value);
  52350. }
  52351. }
  52352. } else {
  52353. // literal attribute
  52354. {
  52355. var res = parseText(value, delimiters);
  52356. if (res) {
  52357. warn$2(
  52358. name + "=\"" + value + "\": " +
  52359. 'Interpolation inside attributes has been removed. ' +
  52360. 'Use v-bind or the colon shorthand instead. For example, ' +
  52361. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  52362. list[i]
  52363. );
  52364. }
  52365. }
  52366. addAttr(el, name, JSON.stringify(value), list[i]);
  52367. // #6887 firefox doesn't update muted state if set via attribute
  52368. // even immediately after element creation
  52369. if (!el.component &&
  52370. name === 'muted' &&
  52371. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  52372. addProp(el, name, 'true', list[i]);
  52373. }
  52374. }
  52375. }
  52376. }
  52377. function checkInFor (el) {
  52378. var parent = el;
  52379. while (parent) {
  52380. if (parent.for !== undefined) {
  52381. return true
  52382. }
  52383. parent = parent.parent;
  52384. }
  52385. return false
  52386. }
  52387. function parseModifiers (name) {
  52388. var match = name.match(modifierRE);
  52389. if (match) {
  52390. var ret = {};
  52391. match.forEach(function (m) { ret[m.slice(1)] = true; });
  52392. return ret
  52393. }
  52394. }
  52395. function makeAttrsMap (attrs) {
  52396. var map = {};
  52397. for (var i = 0, l = attrs.length; i < l; i++) {
  52398. if (
  52399. map[attrs[i].name] && !isIE && !isEdge
  52400. ) {
  52401. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  52402. }
  52403. map[attrs[i].name] = attrs[i].value;
  52404. }
  52405. return map
  52406. }
  52407. // for script (e.g. type="x/template") or style, do not decode content
  52408. function isTextTag (el) {
  52409. return el.tag === 'script' || el.tag === 'style'
  52410. }
  52411. function isForbiddenTag (el) {
  52412. return (
  52413. el.tag === 'style' ||
  52414. (el.tag === 'script' && (
  52415. !el.attrsMap.type ||
  52416. el.attrsMap.type === 'text/javascript'
  52417. ))
  52418. )
  52419. }
  52420. var ieNSBug = /^xmlns:NS\d+/;
  52421. var ieNSPrefix = /^NS\d+:/;
  52422. /* istanbul ignore next */
  52423. function guardIESVGBug (attrs) {
  52424. var res = [];
  52425. for (var i = 0; i < attrs.length; i++) {
  52426. var attr = attrs[i];
  52427. if (!ieNSBug.test(attr.name)) {
  52428. attr.name = attr.name.replace(ieNSPrefix, '');
  52429. res.push(attr);
  52430. }
  52431. }
  52432. return res
  52433. }
  52434. function checkForAliasModel (el, value) {
  52435. var _el = el;
  52436. while (_el) {
  52437. if (_el.for && _el.alias === value) {
  52438. warn$2(
  52439. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  52440. "You are binding v-model directly to a v-for iteration alias. " +
  52441. "This will not be able to modify the v-for source array because " +
  52442. "writing to the alias is like modifying a function local variable. " +
  52443. "Consider using an array of objects and use v-model on an object property instead.",
  52444. el.rawAttrsMap['v-model']
  52445. );
  52446. }
  52447. _el = _el.parent;
  52448. }
  52449. }
  52450. /* */
  52451. function preTransformNode (el, options) {
  52452. if (el.tag === 'input') {
  52453. var map = el.attrsMap;
  52454. if (!map['v-model']) {
  52455. return
  52456. }
  52457. var typeBinding;
  52458. if (map[':type'] || map['v-bind:type']) {
  52459. typeBinding = getBindingAttr(el, 'type');
  52460. }
  52461. if (!map.type && !typeBinding && map['v-bind']) {
  52462. typeBinding = "(" + (map['v-bind']) + ").type";
  52463. }
  52464. if (typeBinding) {
  52465. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  52466. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  52467. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  52468. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  52469. // 1. checkbox
  52470. var branch0 = cloneASTElement(el);
  52471. // process for on the main node
  52472. processFor(branch0);
  52473. addRawAttr(branch0, 'type', 'checkbox');
  52474. processElement(branch0, options);
  52475. branch0.processed = true; // prevent it from double-processed
  52476. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  52477. addIfCondition(branch0, {
  52478. exp: branch0.if,
  52479. block: branch0
  52480. });
  52481. // 2. add radio else-if condition
  52482. var branch1 = cloneASTElement(el);
  52483. getAndRemoveAttr(branch1, 'v-for', true);
  52484. addRawAttr(branch1, 'type', 'radio');
  52485. processElement(branch1, options);
  52486. addIfCondition(branch0, {
  52487. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  52488. block: branch1
  52489. });
  52490. // 3. other
  52491. var branch2 = cloneASTElement(el);
  52492. getAndRemoveAttr(branch2, 'v-for', true);
  52493. addRawAttr(branch2, ':type', typeBinding);
  52494. processElement(branch2, options);
  52495. addIfCondition(branch0, {
  52496. exp: ifCondition,
  52497. block: branch2
  52498. });
  52499. if (hasElse) {
  52500. branch0.else = true;
  52501. } else if (elseIfCondition) {
  52502. branch0.elseif = elseIfCondition;
  52503. }
  52504. return branch0
  52505. }
  52506. }
  52507. }
  52508. function cloneASTElement (el) {
  52509. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  52510. }
  52511. var model$1 = {
  52512. preTransformNode: preTransformNode
  52513. };
  52514. var modules$1 = [
  52515. klass$1,
  52516. style$1,
  52517. model$1
  52518. ];
  52519. /* */
  52520. function text (el, dir) {
  52521. if (dir.value) {
  52522. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  52523. }
  52524. }
  52525. /* */
  52526. function html (el, dir) {
  52527. if (dir.value) {
  52528. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  52529. }
  52530. }
  52531. var directives$1 = {
  52532. model: model,
  52533. text: text,
  52534. html: html
  52535. };
  52536. /* */
  52537. var baseOptions = {
  52538. expectHTML: true,
  52539. modules: modules$1,
  52540. directives: directives$1,
  52541. isPreTag: isPreTag,
  52542. isUnaryTag: isUnaryTag,
  52543. mustUseProp: mustUseProp,
  52544. canBeLeftOpenTag: canBeLeftOpenTag,
  52545. isReservedTag: isReservedTag,
  52546. getTagNamespace: getTagNamespace,
  52547. staticKeys: genStaticKeys(modules$1)
  52548. };
  52549. /* */
  52550. var isStaticKey;
  52551. var isPlatformReservedTag;
  52552. var genStaticKeysCached = cached(genStaticKeys$1);
  52553. /**
  52554. * Goal of the optimizer: walk the generated template AST tree
  52555. * and detect sub-trees that are purely static, i.e. parts of
  52556. * the DOM that never needs to change.
  52557. *
  52558. * Once we detect these sub-trees, we can:
  52559. *
  52560. * 1. Hoist them into constants, so that we no longer need to
  52561. * create fresh nodes for them on each re-render;
  52562. * 2. Completely skip them in the patching process.
  52563. */
  52564. function optimize (root, options) {
  52565. if (!root) { return }
  52566. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  52567. isPlatformReservedTag = options.isReservedTag || no;
  52568. // first pass: mark all non-static nodes.
  52569. markStatic$1(root);
  52570. // second pass: mark static roots.
  52571. markStaticRoots(root, false);
  52572. }
  52573. function genStaticKeys$1 (keys) {
  52574. return makeMap(
  52575. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  52576. (keys ? ',' + keys : '')
  52577. )
  52578. }
  52579. function markStatic$1 (node) {
  52580. node.static = isStatic(node);
  52581. if (node.type === 1) {
  52582. // do not make component slot content static. this avoids
  52583. // 1. components not able to mutate slot nodes
  52584. // 2. static slot content fails for hot-reloading
  52585. if (
  52586. !isPlatformReservedTag(node.tag) &&
  52587. node.tag !== 'slot' &&
  52588. node.attrsMap['inline-template'] == null
  52589. ) {
  52590. return
  52591. }
  52592. for (var i = 0, l = node.children.length; i < l; i++) {
  52593. var child = node.children[i];
  52594. markStatic$1(child);
  52595. if (!child.static) {
  52596. node.static = false;
  52597. }
  52598. }
  52599. if (node.ifConditions) {
  52600. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  52601. var block = node.ifConditions[i$1].block;
  52602. markStatic$1(block);
  52603. if (!block.static) {
  52604. node.static = false;
  52605. }
  52606. }
  52607. }
  52608. }
  52609. }
  52610. function markStaticRoots (node, isInFor) {
  52611. if (node.type === 1) {
  52612. if (node.static || node.once) {
  52613. node.staticInFor = isInFor;
  52614. }
  52615. // For a node to qualify as a static root, it should have children that
  52616. // are not just static text. Otherwise the cost of hoisting out will
  52617. // outweigh the benefits and it's better off to just always render it fresh.
  52618. if (node.static && node.children.length && !(
  52619. node.children.length === 1 &&
  52620. node.children[0].type === 3
  52621. )) {
  52622. node.staticRoot = true;
  52623. return
  52624. } else {
  52625. node.staticRoot = false;
  52626. }
  52627. if (node.children) {
  52628. for (var i = 0, l = node.children.length; i < l; i++) {
  52629. markStaticRoots(node.children[i], isInFor || !!node.for);
  52630. }
  52631. }
  52632. if (node.ifConditions) {
  52633. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  52634. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  52635. }
  52636. }
  52637. }
  52638. }
  52639. function isStatic (node) {
  52640. if (node.type === 2) { // expression
  52641. return false
  52642. }
  52643. if (node.type === 3) { // text
  52644. return true
  52645. }
  52646. return !!(node.pre || (
  52647. !node.hasBindings && // no dynamic bindings
  52648. !node.if && !node.for && // not v-if or v-for or v-else
  52649. !isBuiltInTag(node.tag) && // not a built-in
  52650. isPlatformReservedTag(node.tag) && // not a component
  52651. !isDirectChildOfTemplateFor(node) &&
  52652. Object.keys(node).every(isStaticKey)
  52653. ))
  52654. }
  52655. function isDirectChildOfTemplateFor (node) {
  52656. while (node.parent) {
  52657. node = node.parent;
  52658. if (node.tag !== 'template') {
  52659. return false
  52660. }
  52661. if (node.for) {
  52662. return true
  52663. }
  52664. }
  52665. return false
  52666. }
  52667. /* */
  52668. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  52669. var fnInvokeRE = /\([^)]*?\);*$/;
  52670. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  52671. // KeyboardEvent.keyCode aliases
  52672. var keyCodes = {
  52673. esc: 27,
  52674. tab: 9,
  52675. enter: 13,
  52676. space: 32,
  52677. up: 38,
  52678. left: 37,
  52679. right: 39,
  52680. down: 40,
  52681. 'delete': [8, 46]
  52682. };
  52683. // KeyboardEvent.key aliases
  52684. var keyNames = {
  52685. // #7880: IE11 and Edge use `Esc` for Escape key name.
  52686. esc: ['Esc', 'Escape'],
  52687. tab: 'Tab',
  52688. enter: 'Enter',
  52689. // #9112: IE11 uses `Spacebar` for Space key name.
  52690. space: [' ', 'Spacebar'],
  52691. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  52692. up: ['Up', 'ArrowUp'],
  52693. left: ['Left', 'ArrowLeft'],
  52694. right: ['Right', 'ArrowRight'],
  52695. down: ['Down', 'ArrowDown'],
  52696. // #9112: IE11 uses `Del` for Delete key name.
  52697. 'delete': ['Backspace', 'Delete', 'Del']
  52698. };
  52699. // #4868: modifiers that prevent the execution of the listener
  52700. // need to explicitly return null so that we can determine whether to remove
  52701. // the listener for .once
  52702. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  52703. var modifierCode = {
  52704. stop: '$event.stopPropagation();',
  52705. prevent: '$event.preventDefault();',
  52706. self: genGuard("$event.target !== $event.currentTarget"),
  52707. ctrl: genGuard("!$event.ctrlKey"),
  52708. shift: genGuard("!$event.shiftKey"),
  52709. alt: genGuard("!$event.altKey"),
  52710. meta: genGuard("!$event.metaKey"),
  52711. left: genGuard("'button' in $event && $event.button !== 0"),
  52712. middle: genGuard("'button' in $event && $event.button !== 1"),
  52713. right: genGuard("'button' in $event && $event.button !== 2")
  52714. };
  52715. function genHandlers (
  52716. events,
  52717. isNative
  52718. ) {
  52719. var prefix = isNative ? 'nativeOn:' : 'on:';
  52720. var staticHandlers = "";
  52721. var dynamicHandlers = "";
  52722. for (var name in events) {
  52723. var handlerCode = genHandler(events[name]);
  52724. if (events[name] && events[name].dynamic) {
  52725. dynamicHandlers += name + "," + handlerCode + ",";
  52726. } else {
  52727. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  52728. }
  52729. }
  52730. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  52731. if (dynamicHandlers) {
  52732. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  52733. } else {
  52734. return prefix + staticHandlers
  52735. }
  52736. }
  52737. function genHandler (handler) {
  52738. if (!handler) {
  52739. return 'function(){}'
  52740. }
  52741. if (Array.isArray(handler)) {
  52742. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  52743. }
  52744. var isMethodPath = simplePathRE.test(handler.value);
  52745. var isFunctionExpression = fnExpRE.test(handler.value);
  52746. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  52747. if (!handler.modifiers) {
  52748. if (isMethodPath || isFunctionExpression) {
  52749. return handler.value
  52750. }
  52751. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  52752. } else {
  52753. var code = '';
  52754. var genModifierCode = '';
  52755. var keys = [];
  52756. for (var key in handler.modifiers) {
  52757. if (modifierCode[key]) {
  52758. genModifierCode += modifierCode[key];
  52759. // left/right
  52760. if (keyCodes[key]) {
  52761. keys.push(key);
  52762. }
  52763. } else if (key === 'exact') {
  52764. var modifiers = (handler.modifiers);
  52765. genModifierCode += genGuard(
  52766. ['ctrl', 'shift', 'alt', 'meta']
  52767. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  52768. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  52769. .join('||')
  52770. );
  52771. } else {
  52772. keys.push(key);
  52773. }
  52774. }
  52775. if (keys.length) {
  52776. code += genKeyFilter(keys);
  52777. }
  52778. // Make sure modifiers like prevent and stop get executed after key filtering
  52779. if (genModifierCode) {
  52780. code += genModifierCode;
  52781. }
  52782. var handlerCode = isMethodPath
  52783. ? ("return " + (handler.value) + "($event)")
  52784. : isFunctionExpression
  52785. ? ("return (" + (handler.value) + ")($event)")
  52786. : isFunctionInvocation
  52787. ? ("return " + (handler.value))
  52788. : handler.value;
  52789. return ("function($event){" + code + handlerCode + "}")
  52790. }
  52791. }
  52792. function genKeyFilter (keys) {
  52793. return (
  52794. // make sure the key filters only apply to KeyboardEvents
  52795. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  52796. // key events that do not have keyCode property...
  52797. "if(!$event.type.indexOf('key')&&" +
  52798. (keys.map(genFilterCode).join('&&')) + ")return null;"
  52799. )
  52800. }
  52801. function genFilterCode (key) {
  52802. var keyVal = parseInt(key, 10);
  52803. if (keyVal) {
  52804. return ("$event.keyCode!==" + keyVal)
  52805. }
  52806. var keyCode = keyCodes[key];
  52807. var keyName = keyNames[key];
  52808. return (
  52809. "_k($event.keyCode," +
  52810. (JSON.stringify(key)) + "," +
  52811. (JSON.stringify(keyCode)) + "," +
  52812. "$event.key," +
  52813. "" + (JSON.stringify(keyName)) +
  52814. ")"
  52815. )
  52816. }
  52817. /* */
  52818. function on (el, dir) {
  52819. if (dir.modifiers) {
  52820. warn("v-on without argument does not support modifiers.");
  52821. }
  52822. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  52823. }
  52824. /* */
  52825. function bind$1 (el, dir) {
  52826. el.wrapData = function (code) {
  52827. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  52828. };
  52829. }
  52830. /* */
  52831. var baseDirectives = {
  52832. on: on,
  52833. bind: bind$1,
  52834. cloak: noop
  52835. };
  52836. /* */
  52837. var CodegenState = function CodegenState (options) {
  52838. this.options = options;
  52839. this.warn = options.warn || baseWarn;
  52840. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  52841. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  52842. this.directives = extend(extend({}, baseDirectives), options.directives);
  52843. var isReservedTag = options.isReservedTag || no;
  52844. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  52845. this.onceId = 0;
  52846. this.staticRenderFns = [];
  52847. this.pre = false;
  52848. };
  52849. function generate (
  52850. ast,
  52851. options
  52852. ) {
  52853. var state = new CodegenState(options);
  52854. var code = ast ? genElement(ast, state) : '_c("div")';
  52855. return {
  52856. render: ("with(this){return " + code + "}"),
  52857. staticRenderFns: state.staticRenderFns
  52858. }
  52859. }
  52860. function genElement (el, state) {
  52861. if (el.parent) {
  52862. el.pre = el.pre || el.parent.pre;
  52863. }
  52864. if (el.staticRoot && !el.staticProcessed) {
  52865. return genStatic(el, state)
  52866. } else if (el.once && !el.onceProcessed) {
  52867. return genOnce(el, state)
  52868. } else if (el.for && !el.forProcessed) {
  52869. return genFor(el, state)
  52870. } else if (el.if && !el.ifProcessed) {
  52871. return genIf(el, state)
  52872. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  52873. return genChildren(el, state) || 'void 0'
  52874. } else if (el.tag === 'slot') {
  52875. return genSlot(el, state)
  52876. } else {
  52877. // component or element
  52878. var code;
  52879. if (el.component) {
  52880. code = genComponent(el.component, el, state);
  52881. } else {
  52882. var data;
  52883. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  52884. data = genData$2(el, state);
  52885. }
  52886. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  52887. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  52888. }
  52889. // module transforms
  52890. for (var i = 0; i < state.transforms.length; i++) {
  52891. code = state.transforms[i](el, code);
  52892. }
  52893. return code
  52894. }
  52895. }
  52896. // hoist static sub-trees out
  52897. function genStatic (el, state) {
  52898. el.staticProcessed = true;
  52899. // Some elements (templates) need to behave differently inside of a v-pre
  52900. // node. All pre nodes are static roots, so we can use this as a location to
  52901. // wrap a state change and reset it upon exiting the pre node.
  52902. var originalPreState = state.pre;
  52903. if (el.pre) {
  52904. state.pre = el.pre;
  52905. }
  52906. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  52907. state.pre = originalPreState;
  52908. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  52909. }
  52910. // v-once
  52911. function genOnce (el, state) {
  52912. el.onceProcessed = true;
  52913. if (el.if && !el.ifProcessed) {
  52914. return genIf(el, state)
  52915. } else if (el.staticInFor) {
  52916. var key = '';
  52917. var parent = el.parent;
  52918. while (parent) {
  52919. if (parent.for) {
  52920. key = parent.key;
  52921. break
  52922. }
  52923. parent = parent.parent;
  52924. }
  52925. if (!key) {
  52926. state.warn(
  52927. "v-once can only be used inside v-for that is keyed. ",
  52928. el.rawAttrsMap['v-once']
  52929. );
  52930. return genElement(el, state)
  52931. }
  52932. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  52933. } else {
  52934. return genStatic(el, state)
  52935. }
  52936. }
  52937. function genIf (
  52938. el,
  52939. state,
  52940. altGen,
  52941. altEmpty
  52942. ) {
  52943. el.ifProcessed = true; // avoid recursion
  52944. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  52945. }
  52946. function genIfConditions (
  52947. conditions,
  52948. state,
  52949. altGen,
  52950. altEmpty
  52951. ) {
  52952. if (!conditions.length) {
  52953. return altEmpty || '_e()'
  52954. }
  52955. var condition = conditions.shift();
  52956. if (condition.exp) {
  52957. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  52958. } else {
  52959. return ("" + (genTernaryExp(condition.block)))
  52960. }
  52961. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  52962. function genTernaryExp (el) {
  52963. return altGen
  52964. ? altGen(el, state)
  52965. : el.once
  52966. ? genOnce(el, state)
  52967. : genElement(el, state)
  52968. }
  52969. }
  52970. function genFor (
  52971. el,
  52972. state,
  52973. altGen,
  52974. altHelper
  52975. ) {
  52976. var exp = el.for;
  52977. var alias = el.alias;
  52978. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  52979. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  52980. if (state.maybeComponent(el) &&
  52981. el.tag !== 'slot' &&
  52982. el.tag !== 'template' &&
  52983. !el.key
  52984. ) {
  52985. state.warn(
  52986. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  52987. "v-for should have explicit keys. " +
  52988. "See https://vuejs.org/guide/list.html#key for more info.",
  52989. el.rawAttrsMap['v-for'],
  52990. true /* tip */
  52991. );
  52992. }
  52993. el.forProcessed = true; // avoid recursion
  52994. return (altHelper || '_l') + "((" + exp + ")," +
  52995. "function(" + alias + iterator1 + iterator2 + "){" +
  52996. "return " + ((altGen || genElement)(el, state)) +
  52997. '})'
  52998. }
  52999. function genData$2 (el, state) {
  53000. var data = '{';
  53001. // directives first.
  53002. // directives may mutate the el's other properties before they are generated.
  53003. var dirs = genDirectives(el, state);
  53004. if (dirs) { data += dirs + ','; }
  53005. // key
  53006. if (el.key) {
  53007. data += "key:" + (el.key) + ",";
  53008. }
  53009. // ref
  53010. if (el.ref) {
  53011. data += "ref:" + (el.ref) + ",";
  53012. }
  53013. if (el.refInFor) {
  53014. data += "refInFor:true,";
  53015. }
  53016. // pre
  53017. if (el.pre) {
  53018. data += "pre:true,";
  53019. }
  53020. // record original tag name for components using "is" attribute
  53021. if (el.component) {
  53022. data += "tag:\"" + (el.tag) + "\",";
  53023. }
  53024. // module data generation functions
  53025. for (var i = 0; i < state.dataGenFns.length; i++) {
  53026. data += state.dataGenFns[i](el);
  53027. }
  53028. // attributes
  53029. if (el.attrs) {
  53030. data += "attrs:" + (genProps(el.attrs)) + ",";
  53031. }
  53032. // DOM props
  53033. if (el.props) {
  53034. data += "domProps:" + (genProps(el.props)) + ",";
  53035. }
  53036. // event handlers
  53037. if (el.events) {
  53038. data += (genHandlers(el.events, false)) + ",";
  53039. }
  53040. if (el.nativeEvents) {
  53041. data += (genHandlers(el.nativeEvents, true)) + ",";
  53042. }
  53043. // slot target
  53044. // only for non-scoped slots
  53045. if (el.slotTarget && !el.slotScope) {
  53046. data += "slot:" + (el.slotTarget) + ",";
  53047. }
  53048. // scoped slots
  53049. if (el.scopedSlots) {
  53050. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  53051. }
  53052. // component v-model
  53053. if (el.model) {
  53054. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  53055. }
  53056. // inline-template
  53057. if (el.inlineTemplate) {
  53058. var inlineTemplate = genInlineTemplate(el, state);
  53059. if (inlineTemplate) {
  53060. data += inlineTemplate + ",";
  53061. }
  53062. }
  53063. data = data.replace(/,$/, '') + '}';
  53064. // v-bind dynamic argument wrap
  53065. // v-bind with dynamic arguments must be applied using the same v-bind object
  53066. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  53067. if (el.dynamicAttrs) {
  53068. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  53069. }
  53070. // v-bind data wrap
  53071. if (el.wrapData) {
  53072. data = el.wrapData(data);
  53073. }
  53074. // v-on data wrap
  53075. if (el.wrapListeners) {
  53076. data = el.wrapListeners(data);
  53077. }
  53078. return data
  53079. }
  53080. function genDirectives (el, state) {
  53081. var dirs = el.directives;
  53082. if (!dirs) { return }
  53083. var res = 'directives:[';
  53084. var hasRuntime = false;
  53085. var i, l, dir, needRuntime;
  53086. for (i = 0, l = dirs.length; i < l; i++) {
  53087. dir = dirs[i];
  53088. needRuntime = true;
  53089. var gen = state.directives[dir.name];
  53090. if (gen) {
  53091. // compile-time directive that manipulates AST.
  53092. // returns true if it also needs a runtime counterpart.
  53093. needRuntime = !!gen(el, dir, state.warn);
  53094. }
  53095. if (needRuntime) {
  53096. hasRuntime = true;
  53097. 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))) : '') + "},";
  53098. }
  53099. }
  53100. if (hasRuntime) {
  53101. return res.slice(0, -1) + ']'
  53102. }
  53103. }
  53104. function genInlineTemplate (el, state) {
  53105. var ast = el.children[0];
  53106. if (el.children.length !== 1 || ast.type !== 1) {
  53107. state.warn(
  53108. 'Inline-template components must have exactly one child element.',
  53109. { start: el.start }
  53110. );
  53111. }
  53112. if (ast && ast.type === 1) {
  53113. var inlineRenderFns = generate(ast, state.options);
  53114. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  53115. }
  53116. }
  53117. function genScopedSlots (
  53118. el,
  53119. slots,
  53120. state
  53121. ) {
  53122. // by default scoped slots are considered "stable", this allows child
  53123. // components with only scoped slots to skip forced updates from parent.
  53124. // but in some cases we have to bail-out of this optimization
  53125. // for example if the slot contains dynamic names, has v-if or v-for on them...
  53126. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  53127. var slot = slots[key];
  53128. return (
  53129. slot.slotTargetDynamic ||
  53130. slot.if ||
  53131. slot.for ||
  53132. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  53133. )
  53134. });
  53135. // #9534: if a component with scoped slots is inside a conditional branch,
  53136. // it's possible for the same component to be reused but with different
  53137. // compiled slot content. To avoid that, we generate a unique key based on
  53138. // the generated code of all the slot contents.
  53139. var needsKey = !!el.if;
  53140. // OR when it is inside another scoped slot or v-for (the reactivity may be
  53141. // disconnected due to the intermediate scope variable)
  53142. // #9438, #9506
  53143. // TODO: this can be further optimized by properly analyzing in-scope bindings
  53144. // and skip force updating ones that do not actually use scope variables.
  53145. if (!needsForceUpdate) {
  53146. var parent = el.parent;
  53147. while (parent) {
  53148. if (
  53149. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  53150. parent.for
  53151. ) {
  53152. needsForceUpdate = true;
  53153. break
  53154. }
  53155. if (parent.if) {
  53156. needsKey = true;
  53157. }
  53158. parent = parent.parent;
  53159. }
  53160. }
  53161. var generatedSlots = Object.keys(slots)
  53162. .map(function (key) { return genScopedSlot(slots[key], state); })
  53163. .join(',');
  53164. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  53165. }
  53166. function hash(str) {
  53167. var hash = 5381;
  53168. var i = str.length;
  53169. while(i) {
  53170. hash = (hash * 33) ^ str.charCodeAt(--i);
  53171. }
  53172. return hash >>> 0
  53173. }
  53174. function containsSlotChild (el) {
  53175. if (el.type === 1) {
  53176. if (el.tag === 'slot') {
  53177. return true
  53178. }
  53179. return el.children.some(containsSlotChild)
  53180. }
  53181. return false
  53182. }
  53183. function genScopedSlot (
  53184. el,
  53185. state
  53186. ) {
  53187. var isLegacySyntax = el.attrsMap['slot-scope'];
  53188. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  53189. return genIf(el, state, genScopedSlot, "null")
  53190. }
  53191. if (el.for && !el.forProcessed) {
  53192. return genFor(el, state, genScopedSlot)
  53193. }
  53194. var slotScope = el.slotScope === emptySlotScopeToken
  53195. ? ""
  53196. : String(el.slotScope);
  53197. var fn = "function(" + slotScope + "){" +
  53198. "return " + (el.tag === 'template'
  53199. ? el.if && isLegacySyntax
  53200. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  53201. : genChildren(el, state) || 'undefined'
  53202. : genElement(el, state)) + "}";
  53203. // reverse proxy v-slot without scope on this.$slots
  53204. var reverseProxy = slotScope ? "" : ",proxy:true";
  53205. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  53206. }
  53207. function genChildren (
  53208. el,
  53209. state,
  53210. checkSkip,
  53211. altGenElement,
  53212. altGenNode
  53213. ) {
  53214. var children = el.children;
  53215. if (children.length) {
  53216. var el$1 = children[0];
  53217. // optimize single v-for
  53218. if (children.length === 1 &&
  53219. el$1.for &&
  53220. el$1.tag !== 'template' &&
  53221. el$1.tag !== 'slot'
  53222. ) {
  53223. var normalizationType = checkSkip
  53224. ? state.maybeComponent(el$1) ? ",1" : ",0"
  53225. : "";
  53226. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  53227. }
  53228. var normalizationType$1 = checkSkip
  53229. ? getNormalizationType(children, state.maybeComponent)
  53230. : 0;
  53231. var gen = altGenNode || genNode;
  53232. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  53233. }
  53234. }
  53235. // determine the normalization needed for the children array.
  53236. // 0: no normalization needed
  53237. // 1: simple normalization needed (possible 1-level deep nested array)
  53238. // 2: full normalization needed
  53239. function getNormalizationType (
  53240. children,
  53241. maybeComponent
  53242. ) {
  53243. var res = 0;
  53244. for (var i = 0; i < children.length; i++) {
  53245. var el = children[i];
  53246. if (el.type !== 1) {
  53247. continue
  53248. }
  53249. if (needsNormalization(el) ||
  53250. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  53251. res = 2;
  53252. break
  53253. }
  53254. if (maybeComponent(el) ||
  53255. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  53256. res = 1;
  53257. }
  53258. }
  53259. return res
  53260. }
  53261. function needsNormalization (el) {
  53262. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  53263. }
  53264. function genNode (node, state) {
  53265. if (node.type === 1) {
  53266. return genElement(node, state)
  53267. } else if (node.type === 3 && node.isComment) {
  53268. return genComment(node)
  53269. } else {
  53270. return genText(node)
  53271. }
  53272. }
  53273. function genText (text) {
  53274. return ("_v(" + (text.type === 2
  53275. ? text.expression // no need for () because already wrapped in _s()
  53276. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  53277. }
  53278. function genComment (comment) {
  53279. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  53280. }
  53281. function genSlot (el, state) {
  53282. var slotName = el.slotName || '"default"';
  53283. var children = genChildren(el, state);
  53284. var res = "_t(" + slotName + (children ? ("," + children) : '');
  53285. var attrs = el.attrs || el.dynamicAttrs
  53286. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  53287. // slot props are camelized
  53288. name: camelize(attr.name),
  53289. value: attr.value,
  53290. dynamic: attr.dynamic
  53291. }); }))
  53292. : null;
  53293. var bind$$1 = el.attrsMap['v-bind'];
  53294. if ((attrs || bind$$1) && !children) {
  53295. res += ",null";
  53296. }
  53297. if (attrs) {
  53298. res += "," + attrs;
  53299. }
  53300. if (bind$$1) {
  53301. res += (attrs ? '' : ',null') + "," + bind$$1;
  53302. }
  53303. return res + ')'
  53304. }
  53305. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  53306. function genComponent (
  53307. componentName,
  53308. el,
  53309. state
  53310. ) {
  53311. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  53312. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  53313. }
  53314. function genProps (props) {
  53315. var staticProps = "";
  53316. var dynamicProps = "";
  53317. for (var i = 0; i < props.length; i++) {
  53318. var prop = props[i];
  53319. var value = transformSpecialNewlines(prop.value);
  53320. if (prop.dynamic) {
  53321. dynamicProps += (prop.name) + "," + value + ",";
  53322. } else {
  53323. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  53324. }
  53325. }
  53326. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  53327. if (dynamicProps) {
  53328. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  53329. } else {
  53330. return staticProps
  53331. }
  53332. }
  53333. // #3895, #4268
  53334. function transformSpecialNewlines (text) {
  53335. return text
  53336. .replace(/\u2028/g, '\\u2028')
  53337. .replace(/\u2029/g, '\\u2029')
  53338. }
  53339. /* */
  53340. // these keywords should not appear inside expressions, but operators like
  53341. // typeof, instanceof and in are allowed
  53342. var prohibitedKeywordRE = new RegExp('\\b' + (
  53343. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  53344. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  53345. 'extends,finally,continue,debugger,function,arguments'
  53346. ).split(',').join('\\b|\\b') + '\\b');
  53347. // these unary operators should not be used as property/method names
  53348. var unaryOperatorsRE = new RegExp('\\b' + (
  53349. 'delete,typeof,void'
  53350. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  53351. // strip strings in expressions
  53352. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  53353. // detect problematic expressions in a template
  53354. function detectErrors (ast, warn) {
  53355. if (ast) {
  53356. checkNode(ast, warn);
  53357. }
  53358. }
  53359. function checkNode (node, warn) {
  53360. if (node.type === 1) {
  53361. for (var name in node.attrsMap) {
  53362. if (dirRE.test(name)) {
  53363. var value = node.attrsMap[name];
  53364. if (value) {
  53365. var range = node.rawAttrsMap[name];
  53366. if (name === 'v-for') {
  53367. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  53368. } else if (name === 'v-slot' || name[0] === '#') {
  53369. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  53370. } else if (onRE.test(name)) {
  53371. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  53372. } else {
  53373. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  53374. }
  53375. }
  53376. }
  53377. }
  53378. if (node.children) {
  53379. for (var i = 0; i < node.children.length; i++) {
  53380. checkNode(node.children[i], warn);
  53381. }
  53382. }
  53383. } else if (node.type === 2) {
  53384. checkExpression(node.expression, node.text, warn, node);
  53385. }
  53386. }
  53387. function checkEvent (exp, text, warn, range) {
  53388. var stripped = exp.replace(stripStringRE, '');
  53389. var keywordMatch = stripped.match(unaryOperatorsRE);
  53390. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  53391. warn(
  53392. "avoid using JavaScript unary operator as property name: " +
  53393. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  53394. range
  53395. );
  53396. }
  53397. checkExpression(exp, text, warn, range);
  53398. }
  53399. function checkFor (node, text, warn, range) {
  53400. checkExpression(node.for || '', text, warn, range);
  53401. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  53402. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  53403. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  53404. }
  53405. function checkIdentifier (
  53406. ident,
  53407. type,
  53408. text,
  53409. warn,
  53410. range
  53411. ) {
  53412. if (typeof ident === 'string') {
  53413. try {
  53414. new Function(("var " + ident + "=_"));
  53415. } catch (e) {
  53416. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  53417. }
  53418. }
  53419. }
  53420. function checkExpression (exp, text, warn, range) {
  53421. try {
  53422. new Function(("return " + exp));
  53423. } catch (e) {
  53424. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  53425. if (keywordMatch) {
  53426. warn(
  53427. "avoid using JavaScript keyword as property name: " +
  53428. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  53429. range
  53430. );
  53431. } else {
  53432. warn(
  53433. "invalid expression: " + (e.message) + " in\n\n" +
  53434. " " + exp + "\n\n" +
  53435. " Raw expression: " + (text.trim()) + "\n",
  53436. range
  53437. );
  53438. }
  53439. }
  53440. }
  53441. function checkFunctionParameterExpression (exp, text, warn, range) {
  53442. try {
  53443. new Function(exp, '');
  53444. } catch (e) {
  53445. warn(
  53446. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  53447. " " + exp + "\n\n" +
  53448. " Raw expression: " + (text.trim()) + "\n",
  53449. range
  53450. );
  53451. }
  53452. }
  53453. /* */
  53454. var range = 2;
  53455. function generateCodeFrame (
  53456. source,
  53457. start,
  53458. end
  53459. ) {
  53460. if ( start === void 0 ) start = 0;
  53461. if ( end === void 0 ) end = source.length;
  53462. var lines = source.split(/\r?\n/);
  53463. var count = 0;
  53464. var res = [];
  53465. for (var i = 0; i < lines.length; i++) {
  53466. count += lines[i].length + 1;
  53467. if (count >= start) {
  53468. for (var j = i - range; j <= i + range || end > count; j++) {
  53469. if (j < 0 || j >= lines.length) { continue }
  53470. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  53471. var lineLength = lines[j].length;
  53472. if (j === i) {
  53473. // push underline
  53474. var pad = start - (count - lineLength) + 1;
  53475. var length = end > count ? lineLength - pad : end - start;
  53476. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  53477. } else if (j > i) {
  53478. if (end > count) {
  53479. var length$1 = Math.min(end - count, lineLength);
  53480. res.push(" | " + repeat$1("^", length$1));
  53481. }
  53482. count += lineLength + 1;
  53483. }
  53484. }
  53485. break
  53486. }
  53487. }
  53488. return res.join('\n')
  53489. }
  53490. function repeat$1 (str, n) {
  53491. var result = '';
  53492. if (n > 0) {
  53493. while (true) { // eslint-disable-line
  53494. if (n & 1) { result += str; }
  53495. n >>>= 1;
  53496. if (n <= 0) { break }
  53497. str += str;
  53498. }
  53499. }
  53500. return result
  53501. }
  53502. /* */
  53503. function createFunction (code, errors) {
  53504. try {
  53505. return new Function(code)
  53506. } catch (err) {
  53507. errors.push({ err: err, code: code });
  53508. return noop
  53509. }
  53510. }
  53511. function createCompileToFunctionFn (compile) {
  53512. var cache = Object.create(null);
  53513. return function compileToFunctions (
  53514. template,
  53515. options,
  53516. vm
  53517. ) {
  53518. options = extend({}, options);
  53519. var warn$$1 = options.warn || warn;
  53520. delete options.warn;
  53521. /* istanbul ignore if */
  53522. {
  53523. // detect possible CSP restriction
  53524. try {
  53525. new Function('return 1');
  53526. } catch (e) {
  53527. if (e.toString().match(/unsafe-eval|CSP/)) {
  53528. warn$$1(
  53529. 'It seems you are using the standalone build of Vue.js in an ' +
  53530. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  53531. 'The template compiler cannot work in this environment. Consider ' +
  53532. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  53533. 'templates into render functions.'
  53534. );
  53535. }
  53536. }
  53537. }
  53538. // check cache
  53539. var key = options.delimiters
  53540. ? String(options.delimiters) + template
  53541. : template;
  53542. if (cache[key]) {
  53543. return cache[key]
  53544. }
  53545. // compile
  53546. var compiled = compile(template, options);
  53547. // check compilation errors/tips
  53548. {
  53549. if (compiled.errors && compiled.errors.length) {
  53550. if (options.outputSourceRange) {
  53551. compiled.errors.forEach(function (e) {
  53552. warn$$1(
  53553. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  53554. generateCodeFrame(template, e.start, e.end),
  53555. vm
  53556. );
  53557. });
  53558. } else {
  53559. warn$$1(
  53560. "Error compiling template:\n\n" + template + "\n\n" +
  53561. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  53562. vm
  53563. );
  53564. }
  53565. }
  53566. if (compiled.tips && compiled.tips.length) {
  53567. if (options.outputSourceRange) {
  53568. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  53569. } else {
  53570. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  53571. }
  53572. }
  53573. }
  53574. // turn code into functions
  53575. var res = {};
  53576. var fnGenErrors = [];
  53577. res.render = createFunction(compiled.render, fnGenErrors);
  53578. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  53579. return createFunction(code, fnGenErrors)
  53580. });
  53581. // check function generation errors.
  53582. // this should only happen if there is a bug in the compiler itself.
  53583. // mostly for codegen development use
  53584. /* istanbul ignore if */
  53585. {
  53586. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  53587. warn$$1(
  53588. "Failed to generate render function:\n\n" +
  53589. fnGenErrors.map(function (ref) {
  53590. var err = ref.err;
  53591. var code = ref.code;
  53592. return ((err.toString()) + " in\n\n" + code + "\n");
  53593. }).join('\n'),
  53594. vm
  53595. );
  53596. }
  53597. }
  53598. return (cache[key] = res)
  53599. }
  53600. }
  53601. /* */
  53602. function createCompilerCreator (baseCompile) {
  53603. return function createCompiler (baseOptions) {
  53604. function compile (
  53605. template,
  53606. options
  53607. ) {
  53608. var finalOptions = Object.create(baseOptions);
  53609. var errors = [];
  53610. var tips = [];
  53611. var warn = function (msg, range, tip) {
  53612. (tip ? tips : errors).push(msg);
  53613. };
  53614. if (options) {
  53615. if (options.outputSourceRange) {
  53616. // $flow-disable-line
  53617. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  53618. warn = function (msg, range, tip) {
  53619. var data = { msg: msg };
  53620. if (range) {
  53621. if (range.start != null) {
  53622. data.start = range.start + leadingSpaceLength;
  53623. }
  53624. if (range.end != null) {
  53625. data.end = range.end + leadingSpaceLength;
  53626. }
  53627. }
  53628. (tip ? tips : errors).push(data);
  53629. };
  53630. }
  53631. // merge custom modules
  53632. if (options.modules) {
  53633. finalOptions.modules =
  53634. (baseOptions.modules || []).concat(options.modules);
  53635. }
  53636. // merge custom directives
  53637. if (options.directives) {
  53638. finalOptions.directives = extend(
  53639. Object.create(baseOptions.directives || null),
  53640. options.directives
  53641. );
  53642. }
  53643. // copy other options
  53644. for (var key in options) {
  53645. if (key !== 'modules' && key !== 'directives') {
  53646. finalOptions[key] = options[key];
  53647. }
  53648. }
  53649. }
  53650. finalOptions.warn = warn;
  53651. var compiled = baseCompile(template.trim(), finalOptions);
  53652. {
  53653. detectErrors(compiled.ast, warn);
  53654. }
  53655. compiled.errors = errors;
  53656. compiled.tips = tips;
  53657. return compiled
  53658. }
  53659. return {
  53660. compile: compile,
  53661. compileToFunctions: createCompileToFunctionFn(compile)
  53662. }
  53663. }
  53664. }
  53665. /* */
  53666. // `createCompilerCreator` allows creating compilers that use alternative
  53667. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  53668. // Here we just export a default compiler using the default parts.
  53669. var createCompiler = createCompilerCreator(function baseCompile (
  53670. template,
  53671. options
  53672. ) {
  53673. var ast = parse(template.trim(), options);
  53674. if (options.optimize !== false) {
  53675. optimize(ast, options);
  53676. }
  53677. var code = generate(ast, options);
  53678. return {
  53679. ast: ast,
  53680. render: code.render,
  53681. staticRenderFns: code.staticRenderFns
  53682. }
  53683. });
  53684. /* */
  53685. var ref$1 = createCompiler(baseOptions);
  53686. var compile = ref$1.compile;
  53687. var compileToFunctions = ref$1.compileToFunctions;
  53688. /* */
  53689. // check whether current browser encodes a char inside attribute values
  53690. var div;
  53691. function getShouldDecode (href) {
  53692. div = div || document.createElement('div');
  53693. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  53694. return div.innerHTML.indexOf('&#10;') > 0
  53695. }
  53696. // #3663: IE encodes newlines inside attribute values while other browsers don't
  53697. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  53698. // #6828: chrome encodes content in a[href]
  53699. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  53700. /* */
  53701. var idToTemplate = cached(function (id) {
  53702. var el = query(id);
  53703. return el && el.innerHTML
  53704. });
  53705. var mount = Vue.prototype.$mount;
  53706. Vue.prototype.$mount = function (
  53707. el,
  53708. hydrating
  53709. ) {
  53710. el = el && query(el);
  53711. /* istanbul ignore if */
  53712. if (el === document.body || el === document.documentElement) {
  53713. warn(
  53714. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  53715. );
  53716. return this
  53717. }
  53718. var options = this.$options;
  53719. // resolve template/el and convert to render function
  53720. if (!options.render) {
  53721. var template = options.template;
  53722. if (template) {
  53723. if (typeof template === 'string') {
  53724. if (template.charAt(0) === '#') {
  53725. template = idToTemplate(template);
  53726. /* istanbul ignore if */
  53727. if (!template) {
  53728. warn(
  53729. ("Template element not found or is empty: " + (options.template)),
  53730. this
  53731. );
  53732. }
  53733. }
  53734. } else if (template.nodeType) {
  53735. template = template.innerHTML;
  53736. } else {
  53737. {
  53738. warn('invalid template option:' + template, this);
  53739. }
  53740. return this
  53741. }
  53742. } else if (el) {
  53743. template = getOuterHTML(el);
  53744. }
  53745. if (template) {
  53746. /* istanbul ignore if */
  53747. if (config.performance && mark) {
  53748. mark('compile');
  53749. }
  53750. var ref = compileToFunctions(template, {
  53751. outputSourceRange: "development" !== 'production',
  53752. shouldDecodeNewlines: shouldDecodeNewlines,
  53753. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  53754. delimiters: options.delimiters,
  53755. comments: options.comments
  53756. }, this);
  53757. var render = ref.render;
  53758. var staticRenderFns = ref.staticRenderFns;
  53759. options.render = render;
  53760. options.staticRenderFns = staticRenderFns;
  53761. /* istanbul ignore if */
  53762. if (config.performance && mark) {
  53763. mark('compile end');
  53764. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  53765. }
  53766. }
  53767. }
  53768. return mount.call(this, el, hydrating)
  53769. };
  53770. /**
  53771. * Get outerHTML of elements, taking care
  53772. * of SVG elements in IE as well.
  53773. */
  53774. function getOuterHTML (el) {
  53775. if (el.outerHTML) {
  53776. return el.outerHTML
  53777. } else {
  53778. var container = document.createElement('div');
  53779. container.appendChild(el.cloneNode(true));
  53780. return container.innerHTML
  53781. }
  53782. }
  53783. Vue.compile = compileToFunctions;
  53784. module.exports = Vue;
  53785. /* 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))
  53786. /***/ }),
  53787. /***/ "./node_modules/vue/dist/vue.common.js":
  53788. /*!*********************************************!*\
  53789. !*** ./node_modules/vue/dist/vue.common.js ***!
  53790. \*********************************************/
  53791. /*! no static exports found */
  53792. /***/ (function(module, exports, __webpack_require__) {
  53793. if (false) {} else {
  53794. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  53795. }
  53796. /***/ }),
  53797. /***/ "./node_modules/webpack/buildin/global.js":
  53798. /*!***********************************!*\
  53799. !*** (webpack)/buildin/global.js ***!
  53800. \***********************************/
  53801. /*! no static exports found */
  53802. /***/ (function(module, exports) {
  53803. var g;
  53804. // This works in non-strict mode
  53805. g = (function() {
  53806. return this;
  53807. })();
  53808. try {
  53809. // This works if eval is allowed (see CSP)
  53810. g = g || new Function("return this")();
  53811. } catch (e) {
  53812. // This works if the window reference is available
  53813. if (typeof window === "object") g = window;
  53814. }
  53815. // g can still be undefined, but nothing to do about it...
  53816. // We return undefined, instead of nothing here, so it's
  53817. // easier to handle this case. if(!global) { ...}
  53818. module.exports = g;
  53819. /***/ }),
  53820. /***/ "./node_modules/webpack/buildin/module.js":
  53821. /*!***********************************!*\
  53822. !*** (webpack)/buildin/module.js ***!
  53823. \***********************************/
  53824. /*! no static exports found */
  53825. /***/ (function(module, exports) {
  53826. module.exports = function(module) {
  53827. if (!module.webpackPolyfill) {
  53828. module.deprecate = function() {};
  53829. module.paths = [];
  53830. // module.parent = undefined by default
  53831. if (!module.children) module.children = [];
  53832. Object.defineProperty(module, "loaded", {
  53833. enumerable: true,
  53834. get: function() {
  53835. return module.l;
  53836. }
  53837. });
  53838. Object.defineProperty(module, "id", {
  53839. enumerable: true,
  53840. get: function() {
  53841. return module.i;
  53842. }
  53843. });
  53844. module.webpackPolyfill = 1;
  53845. }
  53846. return module;
  53847. };
  53848. /***/ }),
  53849. /***/ "./resources/js/app.js":
  53850. /*!*****************************!*\
  53851. !*** ./resources/js/app.js ***!
  53852. \*****************************/
  53853. /*! no static exports found */
  53854. /***/ (function(module, exports, __webpack_require__) {
  53855. /**
  53856. * First we will load all of this project's JavaScript dependencies which
  53857. * includes Vue and other libraries. It is a great starting point when
  53858. * building robust, powerful web applications using Vue and Laravel.
  53859. */
  53860. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  53861. window.Clipboard = __webpack_require__(/*! clipboard */ "./node_modules/clipboard/dist/clipboard.js");
  53862. __webpack_require__(/*! ./notify.min.js */ "./resources/js/notify.min.js");
  53863. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  53864. /**
  53865. * The following block of code may be used to automatically register your
  53866. * Vue components. It will recursively scan this directory for the Vue
  53867. * components and automatically register them with their "basename".
  53868. *
  53869. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  53870. */
  53871. // const files = require.context('./', true, /\.vue$/i)
  53872. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  53873. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  53874. Vue.component('woinfo', __webpack_require__(/*! ./components/woinfo.vue */ "./resources/js/components/woinfo.vue")["default"]);
  53875. Vue.component('assetinfo', __webpack_require__(/*! ./components/assetinfo.vue */ "./resources/js/components/assetinfo.vue")["default"]);
  53876. Vue.component('credential', __webpack_require__(/*! ./components/credential.vue */ "./resources/js/components/credential.vue")["default"]);
  53877. Vue.component('notes', __webpack_require__(/*! ./components/notes.vue */ "./resources/js/components/notes.vue")["default"]);
  53878. /**
  53879. * Next, we will create a fresh Vue application instance and attach it to
  53880. * the page. Then, you may begin adding components to this application
  53881. * or customize the JavaScript scaffolding to fit your unique needs.
  53882. */
  53883. var app = new Vue({
  53884. el: '#app'
  53885. });
  53886. $(function () {
  53887. $('[data-toggle="tooltip"]').tooltip();
  53888. });
  53889. var clipboard = new Clipboard('.btn-clip');
  53890. clipboard.on('success', function (e) {
  53891. $('#' + e.trigger.getAttribute('id')).notify('Copied to Clipboard', {
  53892. position: "right",
  53893. className: 'success'
  53894. });
  53895. e.clearSelection();
  53896. });
  53897. /***/ }),
  53898. /***/ "./resources/js/bootstrap.js":
  53899. /*!***********************************!*\
  53900. !*** ./resources/js/bootstrap.js ***!
  53901. \***********************************/
  53902. /*! no exports provided */
  53903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53904. "use strict";
  53905. __webpack_require__.r(__webpack_exports__);
  53906. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  53907. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  53908. /**
  53909. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  53910. * for JavaScript based Bootstrap features such as modals and tabs. This
  53911. * code may be modified to fit the specific needs of your application.
  53912. */
  53913. try {
  53914. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  53915. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  53916. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  53917. } catch (e) {}
  53918. /**
  53919. * We'll load the axios HTTP library which allows us to easily issue requests
  53920. * to our Laravel back-end. This library automatically handles sending the
  53921. * CSRF token as a header based on the value of the "XSRF" token cookie.
  53922. */
  53923. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  53924. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  53925. /**
  53926. * Echo exposes an expressive API for subscribing to channels and listening
  53927. * for events that are broadcast by Laravel. Echo and event broadcasting
  53928. * allows your team to easily build robust real-time web applications.
  53929. */
  53930. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  53931. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  53932. broadcaster: 'pusher',
  53933. key: "upccrt",
  53934. wsHost: window.location.hostname,
  53935. wsPort: 6001,
  53936. disableStats: true
  53937. });
  53938. /***/ }),
  53939. /***/ "./resources/js/components/ExampleComponent.vue":
  53940. /*!******************************************************!*\
  53941. !*** ./resources/js/components/ExampleComponent.vue ***!
  53942. \******************************************************/
  53943. /*! exports provided: default */
  53944. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53945. "use strict";
  53946. __webpack_require__.r(__webpack_exports__);
  53947. /* harmony import */ var _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ExampleComponent.vue?vue&type=template&id=299e239e& */ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&");
  53948. /* harmony import */ var _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ExampleComponent.vue?vue&type=script&lang=js& */ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&");
  53949. /* 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");
  53950. /* normalize component */
  53951. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  53952. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  53953. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  53954. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  53955. false,
  53956. null,
  53957. null,
  53958. null
  53959. )
  53960. /* hot reload */
  53961. if (false) { var api; }
  53962. component.options.__file = "resources/js/components/ExampleComponent.vue"
  53963. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  53964. /***/ }),
  53965. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  53966. /*!*******************************************************************************!*\
  53967. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  53968. \*******************************************************************************/
  53969. /*! exports provided: default */
  53970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53971. "use strict";
  53972. __webpack_require__.r(__webpack_exports__);
  53973. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./ExampleComponent.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&");
  53974. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  53975. /***/ }),
  53976. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  53977. /*!*************************************************************************************!*\
  53978. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  53979. \*************************************************************************************/
  53980. /*! exports provided: render, staticRenderFns */
  53981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53982. "use strict";
  53983. __webpack_require__.r(__webpack_exports__);
  53984. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./ExampleComponent.vue?vue&type=template&id=299e239e& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&");
  53985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  53986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  53987. /***/ }),
  53988. /***/ "./resources/js/components/assetinfo.vue":
  53989. /*!***********************************************!*\
  53990. !*** ./resources/js/components/assetinfo.vue ***!
  53991. \***********************************************/
  53992. /*! exports provided: default */
  53993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53994. "use strict";
  53995. __webpack_require__.r(__webpack_exports__);
  53996. /* harmony import */ var _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./assetinfo.vue?vue&type=template&id=4fe1d2e3& */ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&");
  53997. /* harmony import */ var _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetinfo.vue?vue&type=script&lang=js& */ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&");
  53998. /* 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");
  53999. /* normalize component */
  54000. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54001. _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54002. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"],
  54003. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54004. false,
  54005. null,
  54006. null,
  54007. null
  54008. )
  54009. /* hot reload */
  54010. if (false) { var api; }
  54011. component.options.__file = "resources/js/components/assetinfo.vue"
  54012. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54013. /***/ }),
  54014. /***/ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  54015. /*!************************************************************************!*\
  54016. !*** ./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  54017. \************************************************************************/
  54018. /*! exports provided: default */
  54019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54020. "use strict";
  54021. __webpack_require__.r(__webpack_exports__);
  54022. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./assetinfo.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=script&lang=js&");
  54023. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  54024. /***/ }),
  54025. /***/ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  54026. /*!******************************************************************************!*\
  54027. !*** ./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  54028. \******************************************************************************/
  54029. /*! exports provided: render, staticRenderFns */
  54030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54031. "use strict";
  54032. __webpack_require__.r(__webpack_exports__);
  54033. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./assetinfo.vue?vue&type=template&id=4fe1d2e3& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&");
  54034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  54035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  54036. /***/ }),
  54037. /***/ "./resources/js/components/credential.vue":
  54038. /*!************************************************!*\
  54039. !*** ./resources/js/components/credential.vue ***!
  54040. \************************************************/
  54041. /*! exports provided: default */
  54042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54043. "use strict";
  54044. __webpack_require__.r(__webpack_exports__);
  54045. /* harmony import */ var _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./credential.vue?vue&type=template&id=0f5cc562& */ "./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&");
  54046. /* harmony import */ var _credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./credential.vue?vue&type=script&lang=js& */ "./resources/js/components/credential.vue?vue&type=script&lang=js&");
  54047. /* 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");
  54048. /* normalize component */
  54049. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54050. _credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54051. _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["render"],
  54052. _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54053. false,
  54054. null,
  54055. null,
  54056. null
  54057. )
  54058. /* hot reload */
  54059. if (false) { var api; }
  54060. component.options.__file = "resources/js/components/credential.vue"
  54061. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54062. /***/ }),
  54063. /***/ "./resources/js/components/credential.vue?vue&type=script&lang=js&":
  54064. /*!*************************************************************************!*\
  54065. !*** ./resources/js/components/credential.vue?vue&type=script&lang=js& ***!
  54066. \*************************************************************************/
  54067. /*! exports provided: default */
  54068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54069. "use strict";
  54070. __webpack_require__.r(__webpack_exports__);
  54071. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_credential_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!./credential.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=script&lang=js&");
  54072. /* 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_credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  54073. /***/ }),
  54074. /***/ "./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&":
  54075. /*!*******************************************************************************!*\
  54076. !*** ./resources/js/components/credential.vue?vue&type=template&id=0f5cc562& ***!
  54077. \*******************************************************************************/
  54078. /*! exports provided: render, staticRenderFns */
  54079. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54080. "use strict";
  54081. __webpack_require__.r(__webpack_exports__);
  54082. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_credential_vue_vue_type_template_id_0f5cc562___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!./credential.vue?vue&type=template&id=0f5cc562& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&");
  54083. /* 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_credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  54084. /* 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_credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  54085. /***/ }),
  54086. /***/ "./resources/js/components/notes.vue":
  54087. /*!*******************************************!*\
  54088. !*** ./resources/js/components/notes.vue ***!
  54089. \*******************************************/
  54090. /*! exports provided: default */
  54091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54092. "use strict";
  54093. __webpack_require__.r(__webpack_exports__);
  54094. /* harmony import */ var _notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./notes.vue?vue&type=template&id=73d141f4& */ "./resources/js/components/notes.vue?vue&type=template&id=73d141f4&");
  54095. /* harmony import */ var _notes_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./notes.vue?vue&type=script&lang=js& */ "./resources/js/components/notes.vue?vue&type=script&lang=js&");
  54096. /* 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");
  54097. /* normalize component */
  54098. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54099. _notes_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54100. _notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["render"],
  54101. _notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54102. false,
  54103. null,
  54104. null,
  54105. null
  54106. )
  54107. /* hot reload */
  54108. if (false) { var api; }
  54109. component.options.__file = "resources/js/components/notes.vue"
  54110. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54111. /***/ }),
  54112. /***/ "./resources/js/components/notes.vue?vue&type=script&lang=js&":
  54113. /*!********************************************************************!*\
  54114. !*** ./resources/js/components/notes.vue?vue&type=script&lang=js& ***!
  54115. \********************************************************************/
  54116. /*! exports provided: default */
  54117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54118. "use strict";
  54119. __webpack_require__.r(__webpack_exports__);
  54120. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_notes_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!./notes.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/notes.vue?vue&type=script&lang=js&");
  54121. /* 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_notes_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  54122. /***/ }),
  54123. /***/ "./resources/js/components/notes.vue?vue&type=template&id=73d141f4&":
  54124. /*!**************************************************************************!*\
  54125. !*** ./resources/js/components/notes.vue?vue&type=template&id=73d141f4& ***!
  54126. \**************************************************************************/
  54127. /*! exports provided: render, staticRenderFns */
  54128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54129. "use strict";
  54130. __webpack_require__.r(__webpack_exports__);
  54131. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_notes_vue_vue_type_template_id_73d141f4___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!./notes.vue?vue&type=template&id=73d141f4& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/notes.vue?vue&type=template&id=73d141f4&");
  54132. /* 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_notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  54133. /* 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_notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  54134. /***/ }),
  54135. /***/ "./resources/js/components/woinfo.vue":
  54136. /*!********************************************!*\
  54137. !*** ./resources/js/components/woinfo.vue ***!
  54138. \********************************************/
  54139. /*! exports provided: default */
  54140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54141. "use strict";
  54142. __webpack_require__.r(__webpack_exports__);
  54143. /* harmony import */ var _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./woinfo.vue?vue&type=template&id=33ce32de& */ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&");
  54144. /* harmony import */ var _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./woinfo.vue?vue&type=script&lang=js& */ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&");
  54145. /* 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");
  54146. /* normalize component */
  54147. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54148. _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54149. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"],
  54150. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54151. false,
  54152. null,
  54153. null,
  54154. null
  54155. )
  54156. /* hot reload */
  54157. if (false) { var api; }
  54158. component.options.__file = "resources/js/components/woinfo.vue"
  54159. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54160. /***/ }),
  54161. /***/ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  54162. /*!*********************************************************************!*\
  54163. !*** ./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  54164. \*********************************************************************/
  54165. /*! exports provided: default */
  54166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54167. "use strict";
  54168. __webpack_require__.r(__webpack_exports__);
  54169. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./woinfo.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&");
  54170. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  54171. /***/ }),
  54172. /***/ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  54173. /*!***************************************************************************!*\
  54174. !*** ./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  54175. \***************************************************************************/
  54176. /*! exports provided: render, staticRenderFns */
  54177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54178. "use strict";
  54179. __webpack_require__.r(__webpack_exports__);
  54180. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./woinfo.vue?vue&type=template&id=33ce32de& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&");
  54181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  54182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  54183. /***/ }),
  54184. /***/ "./resources/js/mixins/dateMixin.js":
  54185. /*!******************************************!*\
  54186. !*** ./resources/js/mixins/dateMixin.js ***!
  54187. \******************************************/
  54188. /*! exports provided: default */
  54189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54190. "use strict";
  54191. __webpack_require__.r(__webpack_exports__);
  54192. /* harmony default export */ __webpack_exports__["default"] = ({
  54193. methods: {
  54194. treatAsUTC: function treatAsUTC(date) {
  54195. var result = new Date(date);
  54196. result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
  54197. return result;
  54198. },
  54199. daysSinceToday: function daysSinceToday(date) {
  54200. var currentDate = new Date();
  54201. var millisecondsPerDay = 24 * 60 * 60 * 1000;
  54202. return (this.treatAsUTC(currentDate) - this.treatAsUTC(date)) / millisecondsPerDay;
  54203. },
  54204. getHRDate: function getHRDate(dateString) {
  54205. var date = new Date(dateString);
  54206. return date.toLocaleString('default', {
  54207. month: 'short',
  54208. day: 'numeric',
  54209. year: 'numeric',
  54210. hour: 'numeric',
  54211. minute: 'numeric'
  54212. });
  54213. },
  54214. isZero: function isZero(dateString) {
  54215. return dateString === '0000-00-00 00:00:00';
  54216. }
  54217. }
  54218. });
  54219. /***/ }),
  54220. /***/ "./resources/js/notify.min.js":
  54221. /*!************************************!*\
  54222. !*** ./resources/js/notify.min.js ***!
  54223. \************************************/
  54224. /*! no static exports found */
  54225. /***/ (function(module, exports, __webpack_require__) {
  54226. 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); }
  54227. (function (e) {
  54228. true ? !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (e),
  54229. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  54230. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  54231. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : undefined;
  54232. })(function (e) {
  54233. function A(t, n, i) {
  54234. typeof i == "string" && (i = {
  54235. className: i
  54236. }), 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);
  54237. }
  54238. var t = [].indexOf || function (e) {
  54239. for (var t = 0, n = this.length; t < n; t++) {
  54240. if (t in this && this[t] === e) return t;
  54241. }
  54242. return -1;
  54243. },
  54244. n = "notify",
  54245. r = n + "js",
  54246. i = n + "!blank",
  54247. s = {
  54248. t: "top",
  54249. m: "middle",
  54250. b: "bottom",
  54251. l: "left",
  54252. c: "center",
  54253. r: "right"
  54254. },
  54255. o = ["l", "c", "r"],
  54256. u = ["t", "m", "b"],
  54257. a = ["t", "b", "l", "r"],
  54258. f = {
  54259. t: "b",
  54260. m: null,
  54261. b: "t",
  54262. l: "r",
  54263. c: null,
  54264. r: "l"
  54265. },
  54266. l = function l(t) {
  54267. var n;
  54268. return n = [], e.each(t.split(/\W+/), function (e, t) {
  54269. var r;
  54270. r = t.toLowerCase().charAt(0);
  54271. if (s[r]) return n.push(r);
  54272. }), n;
  54273. },
  54274. c = {},
  54275. h = {
  54276. name: "core",
  54277. html: '<div class="' + r + '-wrapper">\n <div class="' + r + '-arrow"></div>\n <div class="' + r + '-container"></div>\n</div>',
  54278. 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}"
  54279. },
  54280. p = {
  54281. "border-radius": ["-webkit-", "-moz-"]
  54282. },
  54283. d = function d(e) {
  54284. return c[e];
  54285. },
  54286. v = function v(e) {
  54287. if (!e) throw "Missing Style name";
  54288. c[e] && delete c[e];
  54289. },
  54290. m = function m(t, i) {
  54291. if (!t) throw "Missing Style name";
  54292. if (!i) throw "Missing Style definition";
  54293. if (!i.html) throw "Missing Style HTML";
  54294. var s = c[t];
  54295. s && s.cssElem && (window.console && console.warn(n + ": overwriting style '" + t + "'"), c[t].cssElem.remove()), i.name = t, c[t] = i;
  54296. var o = "";
  54297. i.classes && e.each(i.classes, function (t, n) {
  54298. return o += "." + r + "-" + i.name + "-" + t + " {\n", e.each(n, function (t, n) {
  54299. return p[t] && e.each(p[t], function (e, r) {
  54300. return o += " " + r + t + ": " + n + ";\n";
  54301. }), o += " " + t + ": " + n + ";\n";
  54302. }), o += "}\n";
  54303. }), i.css && (o += "/* styles for " + i.name + " */\n" + i.css), o && (i.cssElem = g(o), i.cssElem.attr("id", "notify-" + i.name));
  54304. var u = {},
  54305. a = e(i.html);
  54306. y("html", a, u), y("text", a, u), i.fields = u;
  54307. },
  54308. g = function g(t) {
  54309. var n, r, i;
  54310. r = x("style"), r.attr("type", "text/css"), e("head").append(r);
  54311. try {
  54312. r.html(t);
  54313. } catch (s) {
  54314. r[0].styleSheet.cssText = t;
  54315. }
  54316. return r;
  54317. },
  54318. y = function y(t, n, r) {
  54319. var s;
  54320. return t !== "html" && (t = "text"), s = "data-notify-" + t, b(n, "[" + s + "]").each(function () {
  54321. var n;
  54322. n = e(this).attr(s), n || (n = i), r[n] = t;
  54323. });
  54324. },
  54325. b = function b(e, t) {
  54326. return e.is(t) ? e : e.find(t);
  54327. },
  54328. w = {
  54329. clickToHide: !0,
  54330. autoHide: !0,
  54331. autoHideDelay: 5e3,
  54332. arrowShow: !0,
  54333. arrowSize: 5,
  54334. breakNewLines: !0,
  54335. elementPosition: "bottom",
  54336. globalPosition: "top right",
  54337. style: "bootstrap",
  54338. className: "error",
  54339. showAnimation: "slideDown",
  54340. showDuration: 400,
  54341. hideAnimation: "slideUp",
  54342. hideDuration: 200,
  54343. gap: 5
  54344. },
  54345. E = function E(t, n) {
  54346. var r;
  54347. return r = function r() {}, r.prototype = t, e.extend(!0, new r(), n);
  54348. },
  54349. S = function S(t) {
  54350. return e.extend(w, t);
  54351. },
  54352. x = function x(t) {
  54353. return e("<" + t + "></" + t + ">");
  54354. },
  54355. T = {},
  54356. N = function N(t) {
  54357. var n;
  54358. return t.is("[type=radio]") && (n = t.parents("form:first").find("[type=radio]").filter(function (n, r) {
  54359. return e(r).attr("name") === t.attr("name");
  54360. }), t = n.first()), t;
  54361. },
  54362. C = function C(e, t, n) {
  54363. var r, i;
  54364. if (typeof n == "string") n = parseInt(n, 10);else if (typeof n != "number") return;
  54365. if (isNaN(n)) return;
  54366. 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;
  54367. },
  54368. k = function k(e, t, n) {
  54369. if (e === "l" || e === "t") return 0;
  54370. if (e === "c" || e === "m") return n / 2 - t / 2;
  54371. if (e === "r" || e === "b") return n - t;
  54372. throw "Invalid alignment";
  54373. },
  54374. L = function L(e) {
  54375. return L.e = L.e || x("div"), L.e.text(e).html();
  54376. };
  54377. A.prototype.loadHTML = function () {
  54378. var t;
  54379. t = this.getStyle(), this.userContainer = e(t.html), this.userFields = t.fields;
  54380. }, A.prototype.show = function (e, t) {
  54381. var n, r, i, s, o;
  54382. r = function (n) {
  54383. return function () {
  54384. !e && !n.elem && n.destroy();
  54385. if (t) return t();
  54386. };
  54387. }(this), o = this.container.parent().parents(":hidden").length > 0, i = this.container.add(this.arrow), n = [];
  54388. 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 {
  54389. if (!!o || !!e) return r();
  54390. s = this.options.hideAnimation, n.push(this.options.hideDuration);
  54391. }
  54392. return n.push(r), i[s].apply(i, n);
  54393. }, A.prototype.setGlobalPosition = function () {
  54394. var t = this.getPosition(),
  54395. n = t[0],
  54396. i = t[1],
  54397. o = s[n],
  54398. u = s[i],
  54399. a = n + "|" + i,
  54400. f = T[a];
  54401. if (!f || !document.body.contains(f[0])) {
  54402. f = T[a] = x("div");
  54403. var l = {};
  54404. 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);
  54405. }
  54406. return f.prepend(this.wrapper);
  54407. }, A.prototype.setElementPosition = function () {
  54408. 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;
  54409. 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"];
  54410. for (w = 0, S = B.length; w < S; w++) {
  54411. D = B[w], N = parseInt(this.elem.css("margin-" + D), 10), N && C(p, D, N);
  54412. }
  54413. b = Math.max(0, this.options.gap - (this.options.arrowShow ? i : 0)), C(p, A, b);
  54414. if (!this.options.arrowShow) this.arrow.hide();else {
  54415. 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";
  54416. for (E = 0, x = a.length; E < x; E++) {
  54417. D = a[E], P = s[D];
  54418. if (D === L) continue;
  54419. l = P === T ? n : "transparent", r["border-" + P] = i + "px solid " + l;
  54420. }
  54421. C(p, s[L], i), t.call(a, O) >= 0 && C(r, s[O], i * 2);
  54422. }
  54423. 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);
  54424. if (r) return this.arrow.removeAttr("style").css(r);
  54425. }, A.prototype.getPosition = function () {
  54426. var e, n, r, i, s, f, c, h;
  54427. h = this.options.position || (this.elem ? this.options.elementPosition : this.options.globalPosition), e = l(h), e.length === 0 && (e[0] = "b");
  54428. if (n = e[0], t.call(a, n) < 0) throw "Must be one of [" + a + "]";
  54429. 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";
  54430. return e.length === 2 && (e[2] = e[1]), e;
  54431. }, A.prototype.getStyle = function (e) {
  54432. var t;
  54433. e || (e = this.options.style), e || (e = "default"), t = c[e];
  54434. if (!t) throw "Missing style: " + e;
  54435. return t;
  54436. }, A.prototype.updateClasses = function () {
  54437. var t, n;
  54438. 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) {
  54439. return r + "-" + n.name + "-" + e;
  54440. }).join(" "), this.userContainer.attr("class", t);
  54441. }, A.prototype.run = function (t, n) {
  54442. var r, s, o, u, a;
  54443. e.isPlainObject(n) ? e.extend(this.options, n) : e.type(n) === "string" && (this.options.className = n);
  54444. if (this.container && !t) {
  54445. this.show(!1);
  54446. return;
  54447. }
  54448. if (!this.container && !t) return;
  54449. s = {}, e.isPlainObject(t) ? s = t : s[i] = t;
  54450. for (o in s) {
  54451. r = s[o], u = this.userFields[o];
  54452. if (!u) continue;
  54453. 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);
  54454. }
  54455. 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));
  54456. }, A.prototype.destroy = function () {
  54457. this.wrapper.data(r, null), this.wrapper.remove();
  54458. }, e[n] = function (t, r, i) {
  54459. return t && t.nodeName || t.jquery ? e(t)[n](r, i) : (i = r, r = t, new A(null, r, i)), t;
  54460. }, e.fn[n] = function (t, n) {
  54461. return e(this).each(function () {
  54462. var i = N(e(this)).data(r);
  54463. i && i.destroy();
  54464. var s = new A(e(this), t, n);
  54465. }), this;
  54466. }, e.extend(e[n], {
  54467. defaults: S,
  54468. addStyle: m,
  54469. removeStyle: v,
  54470. pluginOptions: w,
  54471. getStyle: d,
  54472. insertCSS: g
  54473. }), m("bootstrap", {
  54474. html: "<div>\n<span data-notify-text></span>\n</div>",
  54475. classes: {
  54476. base: {
  54477. "font-weight": "bold",
  54478. padding: "8px 15px 8px 14px",
  54479. "text-shadow": "0 1px 0 rgba(255, 255, 255, 0.5)",
  54480. "background-color": "#fcf8e3",
  54481. border: "1px solid #fbeed5",
  54482. "border-radius": "4px",
  54483. "white-space": "nowrap",
  54484. "padding-left": "25px",
  54485. "background-repeat": "no-repeat",
  54486. "background-position": "3px 7px"
  54487. },
  54488. error: {
  54489. color: "#B94A48",
  54490. "background-color": "#F2DEDE",
  54491. "border-color": "#EED3D7",
  54492. "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=)"
  54493. },
  54494. success: {
  54495. color: "#468847",
  54496. "background-color": "#DFF0D8",
  54497. "border-color": "#D6E9C6",
  54498. "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==)"
  54499. },
  54500. info: {
  54501. color: "#3A87AD",
  54502. "background-color": "#D9EDF7",
  54503. "border-color": "#BCE8F1",
  54504. "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=)"
  54505. },
  54506. warn: {
  54507. color: "#C09853",
  54508. "background-color": "#FCF8E3",
  54509. "border-color": "#FBEED5",
  54510. "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)"
  54511. }
  54512. }
  54513. }), e(function () {
  54514. g(h.css).attr("id", "core-notify"), e(document).on("click", "." + r + "-hidable", function (t) {
  54515. e(this).trigger("notify-hide");
  54516. }), e(document).on("notify-hide", "." + r + "-wrapper", function (t) {
  54517. var n = e(this).data(r);
  54518. n && n.show(!1);
  54519. });
  54520. });
  54521. });
  54522. /***/ }),
  54523. /***/ "./resources/sass/app.scss":
  54524. /*!*********************************!*\
  54525. !*** ./resources/sass/app.scss ***!
  54526. \*********************************/
  54527. /*! no static exports found */
  54528. /***/ (function(module, exports) {
  54529. // removed by extract-text-webpack-plugin
  54530. /***/ }),
  54531. /***/ 0:
  54532. /*!*************************************************************!*\
  54533. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  54534. \*************************************************************/
  54535. /*! no static exports found */
  54536. /***/ (function(module, exports, __webpack_require__) {
  54537. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  54538. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  54539. /***/ })
  54540. /******/ });